Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Bafna <gbbafna@amazon.com>
  • Loading branch information
gbbafna committed Jan 9, 2023
1 parent 0037a24 commit 463c931
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void trimUnreferencedTranslogFiles() throws TranslogException {
}

@Override
public void minSeqNoRequired(long seqNo) {}
public void setMinSeqNoToKeep(long seqNo) {}
};
} catch (IOException ex) {
throw new RuntimeException(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void afterRefresh(boolean didRefresh) {
.forEach(localSegmentChecksumMap::remove);
final long lastRefreshedCheckpoint = ((InternalEngine) indexShard.getEngine())
.lastRefreshedCheckpoint();
indexShard.getEngine().translogManager().minSeqNoRequired(lastRefreshedCheckpoint + 1);
indexShard.getEngine().translogManager().setMinSeqNoToKeep(lastRefreshedCheckpoint + 1);
}
}
} catch (EngineException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ public void ensureCanFlush() {
}

@Override
public void minSeqNoRequired(long seqNo) {
translog.setMinSeqNoRequired(seqNo);
public void setMinSeqNoToKeep(long seqNo) {
translog.setMinSeqNoToKeep(seqNo);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void trimOperationsFromTranslog(long belowTerm, long aboveSeqNo) throws T
public void ensureCanFlush() {}

@Override
public void minSeqNoRequired(long seqNo) {}
public void setMinSeqNoToKeep(long seqNo) {}

@Override
public int restoreLocalHistoryFromTranslog(long processedCheckpoint, TranslogRecoveryRunner translogRecoveryRunner) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class RemoteFsTranslog extends Translog {
private final FileTransferTracker fileTransferTracker;
private volatile long maxRemoteTranslogGenerationUploaded;

private volatile long minSeqNoRequired;
private volatile long minSeqNoToKeep;

public RemoteFsTranslog(
TranslogConfig config,
Expand Down Expand Up @@ -290,7 +290,7 @@ protected long getMinReferencedGen() throws IOException {
assert readLock.isHeldByCurrentThread() || writeLock.isHeldByCurrentThread();
long minReferencedGen = Math.min(
deletionPolicy.minTranslogGenRequired(readers, current),
minGenerationForSeqNo(Math.min(deletionPolicy.getLocalCheckpointOfSafeCommit() + 1, minSeqNoRequired), current, readers)
minGenerationForSeqNo(Math.min(deletionPolicy.getLocalCheckpointOfSafeCommit() + 1, minSeqNoToKeep), current, readers)
);
assert minReferencedGen >= getMinFileGeneration() : "deletion policy requires a minReferenceGen of ["
+ minReferencedGen
Expand All @@ -305,13 +305,13 @@ protected long getMinReferencedGen() throws IOException {
return minReferencedGen;
}

protected void setMinSeqNoRequired(long seqNo) {
if (seqNo < this.minSeqNoRequired) {
protected void setMinSeqNoToKeep(long seqNo) {
if (seqNo < this.minSeqNoToKeep) {
throw new IllegalArgumentException(
"min seq number required can't go backwards: " + "current [" + this.minSeqNoRequired + "] new [" + seqNo + "]"
"min seq number required can't go backwards: " + "current [" + this.minSeqNoToKeep + "] new [" + seqNo + "]"
);
}
this.minSeqNoRequired = seqNo;
this.minSeqNoToKeep = seqNo;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,7 @@ protected long getMinReferencedGen() throws IOException {
Min Seq number required in translog to restore the complete data .
This might be required when segments are persisted via other mechanism than flush.
*/
protected void setMinSeqNoRequired(long seqNo) {}
protected void setMinSeqNoToKeep(long seqNo) {}

/**
* deletes all files associated with a reader. package-private to be able to simulate node failures at this point
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,5 @@ public interface TranslogManager {
* @param seqNo : operations greater or equal to seqNo should be persisted
* This might be required when segments are persisted via other mechanism than flush.
*/
void minSeqNoRequired(long seqNo);
void setMinSeqNoToKeep(long seqNo);
}
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public void testSimpleOperationsUpload() throws IOException {
// expose the new checkpoint (simulating a commit), before we trim the translog
translog.deletionPolicy.setLocalCheckpointOfSafeCommit(0);
// simulating the remote segment upload .
translog.setMinSeqNoRequired(0);
translog.setMinSeqNoToKeep(0);
// This should not trim anything
translog.trimUnreferencedReaders();
assertEquals(translog.allUploaded().size(), 4);
Expand All @@ -514,7 +514,7 @@ public void testSimpleOperationsUpload() throws IOException {
);

// This should trim tlog-2.* files as it contains seq no 0
translog.setMinSeqNoRequired(1);
translog.setMinSeqNoToKeep(1);
translog.trimUnreferencedReaders();
assertEquals(translog.allUploaded().size(), 2);
assertEquals(
Expand Down Expand Up @@ -716,7 +716,7 @@ public void doRun() throws BrokenBarrierException, InterruptedException, IOExcep
// expose the new checkpoint (simulating a commit), before we trim the translog
lastCommittedLocalCheckpoint.set(localCheckpoint);
deletionPolicy.setLocalCheckpointOfSafeCommit(localCheckpoint);
translog.setMinSeqNoRequired(localCheckpoint + 1);
translog.setMinSeqNoToKeep(localCheckpoint + 1);
translog.trimUnreferencedReaders();
}
}
Expand Down

0 comments on commit 463c931

Please sign in to comment.