MB-22256: Fix intermittent failures in test_duplicate_items_disk 58/73758/3
authorDaniel Owen <owend@couchbase.com>
Thu, 16 Feb 2017 17:39:47 +0000 (17:39 +0000)
committerJim Walker <jim@couchbase.com>
Wed, 22 Feb 2017 10:32:00 +0000 (10:32 +0000)
The ep_testsuite: test_duplicate_items_disk test occassionally fails
because waiting for the ep_vbucket_del stat to update (from 0 to 1)
times-out.

The reason the stat occasionally does not increase is because the
the vbucket that is undergoing deletion is set back to active before
the deletion is complete.

A side-effect of setting a vbucket to active, is that if the vbucket
does not exist then it is recreated.

This patch moves the setting of the vbucket back to active to after we
have confirmed the deletion has completed (by ensuring the
ep_vbucket_del stat increases).  Thereby removing the race condition.

Change-Id: Ied680c64536862829974fd061a25d317f766bb46
Reviewed-on: http://review.couchbase.org/73758
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>
Reviewed-by: Manu Dhundi <manu@couchbase.com>
tests/ep_testsuite.cc

index 69b965f..221062e 100644 (file)
@@ -3605,13 +3605,17 @@ static enum test_result test_duplicate_items_disk(ENGINE_HANDLE *h, ENGINE_HANDL
     }
     wait_for_flusher_to_settle(h, h1);
 
-    check(set_vbucket_state(h, h1, 1, vbucket_state_dead), "Failed set set vbucket 1 state.");
+    // don't need to explicitly set the vbucket state to dead as this is
+    // done as part of the vbucketDelete. See KVBucket::deleteVBucket
     int vb_del_num = get_int_stat(h, h1, "ep_vbucket_del");
     vbucketDelete(h, h1, 1);
     checkeq(PROTOCOL_BINARY_RESPONSE_SUCCESS, last_status.load(),
             "Failure deleting dead bucket.");
     check(verify_vbucket_missing(h, h1, 1),
           "vbucket 1 was not missing after deleting it.");
+    // wait for the deletion to successfully complete before setting the
+    // vbucket state active (which creates the vbucket)
+    wait_for_stat_change(h, h1, "ep_vbucket_del", vb_del_num);
 
     check(set_vbucket_state(h, h1, 1, vbucket_state_active), "Failed to set vbucket state.");
 
@@ -3623,7 +3627,6 @@ static enum test_result test_duplicate_items_disk(ENGINE_HANDLE *h, ENGINE_HANDL
         h1->release(h, NULL, i);
     }
     wait_for_flusher_to_settle(h, h1);
-    wait_for_stat_change(h, h1, "ep_vbucket_del", vb_del_num);
 
     testHarness.reload_engine(&h, &h1,
                               testHarness.engine_path,