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 Nov 1, 2023
1 parent 8673fa9 commit 3f491ad
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ public void rollGeneration() throws IOException {

private boolean prepareAndUpload(Long primaryTerm, Long generation) throws IOException {
long maxSeqNo = -1;
boolean translogOpen = closed.get() == false;
try (Releasable ignored = writeLock.acquire()) {
if (generation == null || generation == current.getGeneration()) {
try {
Expand All @@ -277,7 +278,7 @@ private boolean prepareAndUpload(Long primaryTerm, Long generation) throws IOExc
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 @@ -304,7 +305,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, maxSeqNo);
} else {
return upload(primaryTerm, current.getGeneration(), maxSeqNo);
Expand Down

0 comments on commit 3f491ad

Please sign in to comment.