-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Optimize remote store refresh performance by avoiding unnecessary metadata uploads when index state is unchanged #20192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
sjs004
wants to merge
15
commits into
opensearch-project:main
Choose a base branch
from
sjs004:pr-19198
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
24fc597
Skip metadata upload when no new segments during refresh
HyunsangHan f9743eb
Refactor metadata upload optimization
HyunsangHan 1e058da
Add changelog
HyunsangHan 18a41fa
Add test cases: testSkipsMetadataUploadWhenNoNewSegments, testUploads…
HyunsangHan 4dbcf30
Fix affected test cases
HyunsangHan 8a2c65f
retrigger CI
sjs004 ab9354c
Move the optimisation to upload Metadata method
sjs004 9f5abc5
Move the optimisation to upload Metadata method
sjs004 d285df8
Move the optimisation to upload Metadata method
sjs004 02dee94
Move the optimisation to upload Metadata method
sjs004 3715f48
Move the optimisation to upload Metadata method
sjs004 98319a3
Move the optimisation to upload Metadata method
sjs004 44dab6a
Move the optimisation to upload Metadata method
sjs004 e2fec2b
Move the optimisation to upload Metadata method
sjs004 ba4c4bf
Move the optimisation to upload Metadata method
sjs004 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Deduplication check must include translog generation.
The deduplication logic (lines 448-450) checks
primaryTerm,luceneGeneration, andcheckpointVersion, but omitstranslogFileGeneration. When the translog advances without creating new segments (e.g., documents indexed but not yet flushed), the three checked values remain unchanged, causing the method to return early (line 454) and skip the metadata upload. This leaves the remote store with stale translog generation information.This likely explains the test failure in the PR description: the snapshot expects up-to-date metadata reflecting the current translog state but instead finds stale information, resulting in a PARTIAL snapshot state instead of SUCCESS.
To fix this, add
lastUploadedTranslogGenerationtracking and include it in the deduplication check:private volatile long lastUploadedPrimaryTerm = -1L; private volatile long lastUploadedLuceneGeneration = -1L; private volatile long lastUploadedCheckpointVersion = -1L; + private volatile long lastUploadedTranslogGeneration = -1L;Then update the deduplication check:
final long currentPrimaryTerm = replicationCheckpoint.getPrimaryTerm(); final long currentLuceneGeneration = segmentInfos.getGeneration(); final long currentCheckpointVersion = replicationCheckpoint.getSegmentInfosVersion(); if (this.lastUploadedPrimaryTerm == currentPrimaryTerm && this.lastUploadedLuceneGeneration == currentLuceneGeneration - && this.lastUploadedCheckpointVersion == currentCheckpointVersion) { + && this.lastUploadedCheckpointVersion == currentCheckpointVersion + && this.lastUploadedTranslogGeneration == translogFileGeneration) { // LOGIC: The index state (segment files, primary authority, and replication progress) // is identical to the last state successfully uploaded. Skip the costly remote I/O. return; }And update the cache after successful upload:
this.lastUploadedPrimaryTerm = currentPrimaryTerm; this.lastUploadedLuceneGeneration = currentLuceneGeneration; this.lastUploadedCheckpointVersion = currentCheckpointVersion; + this.lastUploadedTranslogGeneration = translogFileGeneration;🤖 Prompt for AI Agents