Drain executor of index change requests before closing index

When Gerrit needs to exit because of a SIG-HUP, we need to make
sure to drain all pending threads that have outstanding indexing
operations not yet flushed to disk.

This does not have to be confused with the index close which may
happen during on-line reindexing and needs to preserve the current
indexing executor.

This is a rework of I6ec90eb73 and I7bda13058 with an alternative
approach that keeps both index consistency across restarts and on-line
reindexing.

Bug: Issue 5200
Bug: Issue 4618
Change-Id: Id332ec0215de4777fabef6ca310c510ba90c9760
This commit is contained in:
Luca Milanesio
2016-12-30 15:02:57 +00:00
parent e7fc0eb55f
commit df10d85174
7 changed files with 33 additions and 16 deletions

View File

@@ -34,6 +34,9 @@ public interface Index<K, V> {
/** @return the schema version used by this index. */
Schema<V> getSchema();
/** Stop and await termination of all executor threads */
void stop();
/** Close this index. */
void close();

View File

@@ -98,6 +98,7 @@ public abstract class IndexCollection<K, V, I extends Index<K, V>>
}
for (I write : writeIndexes) {
if (write != read) {
write.stop();
write.close();
}
}

View File

@@ -57,4 +57,8 @@ public class DummyChangeIndex implements ChangeIndex {
public int getMaxLimit() {
return Integer.MAX_VALUE;
}
@Override
public void stop() {
}
}