testConcurrentWriteViewsAndSnapshot shouldn't flush concurrently

Fixes #24933
This commit is contained in:
Boaz Leskes 2017-05-30 14:19:07 +02:00
parent fc35d51c3c
commit efcbfb7c32
1 changed files with 7 additions and 1 deletions

View File

@ -682,6 +682,8 @@ public class TranslogTests extends ESTestCase {
// a signal for all threads to stop
final AtomicBoolean run = new AtomicBoolean(true);
final Object flushMutex = new Object();
// any errors on threads
final List<Exception> errors = new CopyOnWriteArrayList<>();
logger.debug("using [{}] readers. [{}] writers. flushing every ~[{}] ops.", readers.length, writers.length, flushEveryOps);
@ -721,8 +723,12 @@ public class TranslogTests extends ESTestCase {
translog.ensureSynced(location);
}
if (id % flushEveryOps == 0) {
synchronized (flushMutex) {
// we need not do this concurrently as we need to make sure that the generation
// we're committing - translog.currentFileGeneration() - is still present when we're committing
translog.commit(translog.currentFileGeneration());
}
}
if (id % 7 == 0) {
synchronized (signalReaderSomeDataWasIndexed) {
signalReaderSomeDataWasIndexed.notifyAll();