Disable ReindexAfterRefUpdate in tests This functionality causes a race during tests that may cause flaky failures. Specifically, in the case of ChangeIT#abandonAndRestoreAllowedWithPermission: 1. ACL grant on the main thread (A) modifies refs/meta/config, which triggers ReindexAfterRefUpdate, which kicks off a background task (thread B) to search for and reindex affected changes. 2. B reads change from primary storage, observes that it is open, and constructs a document. 3. A abandons the change, saves the result in primary storage. 4. A indexes the change, deleting it from the open index and adding it to the closed index. 5. B indexes the document it constructed in (2), adding it to the open index. 6. A attempts to look up the change, finds it in both the open and closed indexes, and explodes. Turning off auto-reindexing causes tests to pass. The race still exists in running servers, although in practice the inconsistent cases are fleeting and the index should usually end up in a consistent state. More details and reflections are in the bug. Bug: Issue 5944 Change-Id: Ifca5a1065852db38a562755b652fad3de3672816
diff --git a/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/GerritServer.java b/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/GerritServer.java index b7b6f6a..1e741a8 100644 --- a/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/GerritServer.java +++ b/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/GerritServer.java
@@ -228,6 +228,7 @@ cfg.setInt("sshd", null, "commandStartThreads", 1); cfg.setInt("receive", null, "threadPoolSize", 1); cfg.setInt("index", null, "threads", 1); + cfg.setBoolean("index", null, "reindexAfterRefUpdate", false); } private static Injector createTestInjector(Daemon daemon) throws Exception {