Skip to content

Commit

Permalink
[Remote Translog] Fix translog inconsistent generation assertion fail…
Browse files Browse the repository at this point in the history
…ure in ITs

Signed-off-by: Ashish Singh <[email protected]>
  • Loading branch information
ashking94 committed Oct 30, 2023
1 parent 73bbeb5 commit 502e3f2
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,14 @@ public void rollGeneration() throws IOException {
}

private boolean prepareAndUpload(Long primaryTerm, Long generation) throws IOException {
boolean translogOpen = closed.get() == false;
try (Releasable ignored = writeLock.acquire()) {
if (generation == null || generation == current.getGeneration()) {
try {
final TranslogReader reader = current.closeIntoReader();
readers.add(reader);
copyCheckpointTo(location.resolve(getCommitCheckpointFileName(current.getGeneration())));
if (closed.get() == false) {
if (translogOpen) {
logger.trace("Creating new writer for gen: [{}]", current.getGeneration() + 1);
current = createWriter(current.getGeneration() + 1);
}
Expand All @@ -299,7 +300,7 @@ private boolean prepareAndUpload(Long primaryTerm, Long generation) throws IOExc
// Writing remote in sync fashion doesn't hurt as global ckp update
// is not updated in remote translog except in primary to primary recovery.
if (generation == null) {
if (closed.get() == false) {
if (translogOpen) {
return upload(primaryTerm, current.getGeneration() - 1);
} else {
return upload(primaryTerm, current.getGeneration());
Expand Down

0 comments on commit 502e3f2

Please sign in to comment.