zrhoffman / rpms / 389-ds-base

Forked from rpms/389-ds-base 3 years ago
Clone

Blame SOURCES/0002-Ticket-51082-abort-when-a-empty-valueset-is-freed.patch

a26cad
From 1426f086623404ab2eacb04de7e6414177c0993a Mon Sep 17 00:00:00 2001
a26cad
From: Thierry Bordaz <tbordaz@redhat.com>
a26cad
Date: Mon, 11 May 2020 17:11:49 +0200
a26cad
Subject: [PATCH 02/12] Ticket 51082 - abort when a empty valueset is freed
a26cad
a26cad
Bug Description:
a26cad
	A large valueset (more than 10 values) manages a sorted array of values.
a26cad
        replication purges old values from a valueset (valueset_array_purge). If it purges all the values
a26cad
        the valueset is freed (slapi_valueset_done).
a26cad
        A problem is that the counter of values, in the valueset, is still reflecting the initial number
a26cad
        of values (before the purge). When the valueset is freed (because empty) a safety checking
a26cad
        detects incoherent values based on the wrong counter.
a26cad
a26cad
Fix Description:
a26cad
	When all the values have been purge reset the counter before freeing the valueset
a26cad
a26cad
https://pagure.io/389-ds-base/issue/51082
a26cad
a26cad
Reviewed by: Mark Reynolds
a26cad
a26cad
Platforms tested: F30
a26cad
a26cad
Flag Day: no
a26cad
a26cad
Doc impact: no
a26cad
---
a26cad
 .../suites/replication/acceptance_test.py     | 57 +++++++++++++++++++
a26cad
 ldap/servers/slapd/valueset.c                 |  4 ++
a26cad
 2 files changed, 61 insertions(+)
a26cad
a26cad
diff --git a/dirsrvtests/tests/suites/replication/acceptance_test.py b/dirsrvtests/tests/suites/replication/acceptance_test.py
a26cad
index c8e0a4c93..5009f4e7c 100644
a26cad
--- a/dirsrvtests/tests/suites/replication/acceptance_test.py
a26cad
+++ b/dirsrvtests/tests/suites/replication/acceptance_test.py
a26cad
@@ -500,6 +500,63 @@ def test_warining_for_invalid_replica(topo_m4):
a26cad
     assert topo_m4.ms["master1"].ds_error_log.match('.*nsds5ReplicaBackoffMax.*10.*invalid.*')
a26cad
 
a26cad
 
a26cad
+@pytest.mark.ds51082
a26cad
+def test_csnpurge_large_valueset(topo_m2):
a26cad
+    """Test csn generator test
a26cad
+
a26cad
+    :id: 63e2bdb2-0a8f-4660-9465-7b80a9f72a74
a26cad
+    :setup: MMR with 2 masters
a26cad
+    :steps:
a26cad
+        1. Create a test_user
a26cad
+        2. add a large set of values (more than 10)
a26cad
+        3. delete all the values (more than 10)
a26cad
+        4. configure the replica to purge those values (purgedelay=5s)
a26cad
+        5. Waiting for 6 second
a26cad
+        6. do a series of update
a26cad
+    :expectedresults:
a26cad
+        1. Should succeeds
a26cad
+        2. Should succeeds
a26cad
+        3. Should succeeds
a26cad
+        4. Should succeeds
a26cad
+        5. Should succeeds
a26cad
+        6. Should not crash
a26cad
+    """
a26cad
+    m1 = topo_m2.ms["master2"]
a26cad
+
a26cad
+    test_user = UserAccount(m1, TEST_ENTRY_DN)
a26cad
+    if test_user.exists():
a26cad
+        log.info('Deleting entry {}'.format(TEST_ENTRY_DN))
a26cad
+        test_user.delete()
a26cad
+    test_user.create(properties={
a26cad
+        'uid': TEST_ENTRY_NAME,
a26cad
+        'cn': TEST_ENTRY_NAME,
a26cad
+        'sn': TEST_ENTRY_NAME,
a26cad
+        'userPassword': TEST_ENTRY_NAME,
a26cad
+        'uidNumber' : '1000',
a26cad
+        'gidNumber' : '2000',
a26cad
+        'homeDirectory' : '/home/mmrepl_test',
a26cad
+    })
a26cad
+
a26cad
+    # create a large value set so that it is sorted
a26cad
+    for i in range(1,20):
a26cad
+        test_user.add('description', 'value {}'.format(str(i)))
a26cad
+
a26cad
+    # delete all values of the valueset
a26cad
+    for i in range(1,20):
a26cad
+        test_user.remove('description', 'value {}'.format(str(i)))
a26cad
+
a26cad
+    # set purging delay to 5 second and wait more that 5second
a26cad
+    replicas = Replicas(m1)
a26cad
+    replica = replicas.list()[0]
a26cad
+    log.info('nsds5ReplicaPurgeDelay to 5')
a26cad
+    replica.set('nsds5ReplicaPurgeDelay', '5')
a26cad
+    time.sleep(6)
a26cad
+
a26cad
+    # add some new values to the valueset containing entries that should be purged
a26cad
+    for i in range(21,25):
a26cad
+        test_user.add('description', 'value {}'.format(str(i)))
a26cad
+
a26cad
+
a26cad
 if __name__ == '__main__':
a26cad
     # Run isolated
a26cad
     # -s for DEBUG mode
a26cad
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
a26cad
index 2af3ee18d..12027ecb8 100644
a26cad
--- a/ldap/servers/slapd/valueset.c
a26cad
+++ b/ldap/servers/slapd/valueset.c
a26cad
@@ -801,6 +801,10 @@ valueset_array_purge(const Slapi_Attr *a, Slapi_ValueSet *vs, const CSN *csn)
a26cad
             }
a26cad
         }
a26cad
     } else {
a26cad
+        /* empty valueset - reset the vs->num so that further
a26cad
+         * checking will not abort
a26cad
+         */
a26cad
+        vs->num = 0;
a26cad
         slapi_valueset_done(vs);
a26cad
     }
a26cad
 
a26cad
-- 
a26cad
2.26.2
a26cad