Skip to content

Account trimAboveSeqNo in committed translog generation#50205

Merged
dnhatn merged 3 commits intoelastic:masterfrom
dnhatn:fix-trim-above-translog
Dec 16, 2019
Merged

Account trimAboveSeqNo in committed translog generation#50205
dnhatn merged 3 commits intoelastic:masterfrom
dnhatn:fix-trim-above-translog

Conversation

@dnhatn
Copy link
Copy Markdown
Member

@dnhatn dnhatn commented Dec 15, 2019

While working on the fix for #49970, I found that we do not consider trimAboveSeqNo when calculating the translog generation of an index commit. If there is no new indexing after the primary promotion, then we won't be able to clean up the translog.

@dnhatn dnhatn added >bug :Distributed/Engine Anything around managing Lucene and the Translog in an open shard. v8.0.0 v7.6.0 v7.5.2 labels Dec 15, 2019
@dnhatn dnhatn requested a review from ywelsch December 15, 2019 00:04
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed (:Distributed/Engine)

final long maxSeqNo = reader.getCheckpoint().maxSeqNo;
return maxSeqNo == SequenceNumbers.UNASSIGNED_SEQ_NO || maxSeqNo >= minSeqNo;
});
.filter(reader -> minSeqNo <= SequenceNumbers.min(reader.getCheckpoint().trimmedAboveSeqNo, reader.getCheckpoint().maxSeqNo));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to account for the case where trimmedAboveSeqNo is equal to SequenceNumbers.UNASSIGNED_SEQ_NO. Perhaps we can add a method to checkpoint called getMaxEffectiveSeqNo which is:

if (trimmedAboveSeqNo == SequenceNumbers.UNASSIGNED_SEQ_NO)
  return maxSeqNo;
else
  return Math.min(maxSeqNo, trimmedAboveSeqNo);

Copy link
Copy Markdown
Member Author

@dnhatn dnhatn Dec 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SequenceNumbers.min should handle this case:

} else if (minSeqNo == UNASSIGNED_SEQ_NO) {
return seqNo;

But having an explicit method is better. I pushed 563545c.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah lol, I did not see that a special min method was used (I read it as Math.min).

@dnhatn dnhatn requested a review from ywelsch December 16, 2019 14:40
Copy link
Copy Markdown
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dnhatn
Copy link
Copy Markdown
Member Author

dnhatn commented Dec 16, 2019

Thanks Yannick.

@dnhatn dnhatn merged commit 972b81f into elastic:master Dec 16, 2019
@dnhatn dnhatn deleted the fix-trim-above-translog branch December 16, 2019 16:08
dnhatn added a commit that referenced this pull request Dec 16, 2019
Today we do not consider trimAboveSeqNo when calculating the translog 
generation of an index commit. If there is no new indexing after the
primary promotion, then we won't be able to clean up the translog.
dnhatn added a commit that referenced this pull request Dec 16, 2019
Today we do not consider trimAboveSeqNo when calculating the translog 
generation of an index commit. If there is no new indexing after the
primary promotion, then we won't be able to clean up the translog.
@jasontedor jasontedor added v7.5.1 and removed v7.5.2 labels Dec 16, 2019
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
Today we do not consider trimAboveSeqNo when calculating the translog 
generation of an index commit. If there is no new indexing after the
primary promotion, then we won't be able to clean up the translog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Distributed/Engine Anything around managing Lucene and the Translog in an open shard. v7.5.1 v7.6.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants