Skip to content

Commit

Permalink
Add code to fix the red index on close
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Singh <ssashish@amazon.com>
  • Loading branch information
ashking94 committed Sep 19, 2024
1 parent a1d5a87 commit ac864f0
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,25 @@ public int totalOperations() {

@Override
synchronized Checkpoint getCheckpoint() {
// On a remote store enabled cluster, the global checkpoint is always the max seq no of the shard.
// case 1- Whenever a sync translog happens, we create an empty translog writer (TR) with value as -1
// (SequenceNumbers.NO_OPS_PERFORMED). If we try to sync the translog on account of ensureSynced / flush / roll generation, then
// checkpoint contains value as -1.
// Case 2 - In other cases where at-least operation has been added to TR, then the maxSeqNo is set
// correctly in the checkpoint. Since the in-memory global checkpoint is read from translog checkpoint, we set the same correctly as
// max of seqNo and globalCheckpoint supplied by the supplier.
// In case 1, the max value would be supplied global checkpoint. In case 2, it would be the maxSeqNo.
assert maxSeqNo == SequenceNumbers.NO_OPS_PERFORMED || maxSeqNo >= globalCheckpointSupplier.getAsLong();
long globalCheckpoint = remoteTranslogEnabled
? Math.max(maxSeqNo, globalCheckpointSupplier.getAsLong())
: globalCheckpointSupplier.getAsLong();
return new Checkpoint(
totalOffset,
operationCounter,
generation,
minSeqNo,
maxSeqNo,
globalCheckpointSupplier.getAsLong(),
globalCheckpoint,
minTranslogGenerationSupplier.getAsLong(),
SequenceNumbers.UNASSIGNED_SEQ_NO
);
Expand Down

0 comments on commit ac864f0

Please sign in to comment.