Skip to content

Commit

Permalink
Fix tests by changing read-write concurrency
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <[email protected]>
  • Loading branch information
Sachin Kale committed Dec 12, 2022
1 parent f3b1ae9 commit 33104a1
Showing 1 changed file with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.function.LongConsumer;
import java.util.function.LongSupplier;
Expand Down Expand Up @@ -174,24 +173,17 @@ protected ArrayList<TranslogReader> recoverFromFiles(Checkpoint checkpoint) thro

@Override
public boolean ensureSynced(Location location) throws IOException {
Callable<Boolean> execute = () -> false;
try (ReleasableLock lock = readLock.acquire()) {
try (ReleasableLock ignored = writeLock.acquire()) {
assert location.generation <= current.getGeneration();
if (location.generation == current.getGeneration()) {
ensureOpen();
execute = () -> prepareAndUpload(primaryTermSupplier.getAsLong(), location.generation);
return prepareAndUpload(primaryTermSupplier.getAsLong(), location.generation);
}
} catch (final Exception ex) {
closeOnTragicEvent(ex);
throw ex;
}
try {
return execute.call();
} catch (Exception ex) {
closeOnTragicEvent(ex);
assert ex instanceof IOException;
throw (IOException) ex;
}
return false;
}

@Override
Expand Down

0 comments on commit 33104a1

Please sign in to comment.