Skip to content
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

Segment Replication - Remove seqNo field from ReplicationCheckpoint and use UserData to transfer state. #6594

Merged
merged 2 commits into from
Mar 9, 2023

Conversation

mch2
Copy link
Member

@mch2 mch2 commented Mar 9, 2023

Description

This change removes the seqNo field from ReplicationCheckpoint. This seqNo is only used on the replica to mark the setLocalCheckpointOfSafeCommit used to mark at which point the xlog can be deleted and advance the processed seqNo. This logic was incorrectly attempting to fetch a max by querying the SegmentInfos directly, which would be incorrectly set after delete operations to a lower value.

Rather than relying on this seqNo, we can safely use the max seqNo of the previous commit point to advance both operations. For xlog purge, we will continue to purge after a commit is received from the primary and only purge up to the max, which is guaranteed to be in the set of fsynced segments. For the processed seqno, this ensures that if the replica is promoted primary it continues to replay ops from the xlog starting from this seqNo.

Issues Resolved

closes #6588

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

This change updates getLatestSegmentInfos to only return the max seqNo from the previous
commit point.  This is the only way to guarantee that up to this seqNo has made it into the commit point.

Signed-off-by: Marc Handalian <[email protected]>
@mch2 mch2 changed the title 6588 Segment Replication - Remove seqNo field from ReplicationCheckpoint and use UserData to transfer state. Mar 9, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2023

Gradle Check (Jenkins) Run Completed with:

@dreamer-89
Copy link
Member

Gradle Check (Jenkins) Run Completed with:

testReplicaRestarts test failure. Looks related to change.

REPRODUCE WITH: ./gradlew ':server:test' --tests "org.opensearch.index.shard.SegmentReplicationIndexShardTests.testReplicaRestarts" -Dtests.seed=2DD7A61971AF88AB -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=nb-NO -Dtests.timezone=Poland -Druntime.java=19

org.opensearch.index.shard.SegmentReplicationIndexShardTests > testReplicaRestarts FAILED
    java.lang.AssertionError: expected:<2> but was:<-1>
        at __randomizedtesting.SeedInfo.seed([2DD7A61971AF88AB:D1A5CBB3F240A6A0]:0)
        at org.junit.Assert.fail(Assert.java:89)
        at org.junit.Assert.failNotEquals(Assert.java:835)
        at org.junit.Assert.assertEquals(Assert.java:647)
        at org.junit.Assert.assertEquals(Assert.java:633)
        at org.opensearch.index.shard.SegmentReplicationIndexShardTests.assertDocCounts(SegmentReplicationIndexShardTests.java:1027)
        at org.opensearch.index.shard.SegmentReplicationIndexShardTests.testReplicaRestarts(SegmentReplicationIndexShardTests.java:613)

@mch2
Copy link
Member Author

mch2 commented Mar 9, 2023

Gradle Check (Jenkins) Run Completed with:

testReplicaRestarts test failure. Looks related to change.

REPRODUCE WITH: ./gradlew ':server:test' --tests "org.opensearch.index.shard.SegmentReplicationIndexShardTests.testReplicaRestarts" -Dtests.seed=2DD7A61971AF88AB -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=nb-NO -Dtests.timezone=Poland -Druntime.java=19

org.opensearch.index.shard.SegmentReplicationIndexShardTests > testReplicaRestarts FAILED
    java.lang.AssertionError: expected:<2> but was:<-1>
        at __randomizedtesting.SeedInfo.seed([2DD7A61971AF88AB:D1A5CBB3F240A6A0]:0)
        at org.junit.Assert.fail(Assert.java:89)
        at org.junit.Assert.failNotEquals(Assert.java:835)
        at org.junit.Assert.assertEquals(Assert.java:647)
        at org.junit.Assert.assertEquals(Assert.java:633)
        at org.opensearch.index.shard.SegmentReplicationIndexShardTests.assertDocCounts(SegmentReplicationIndexShardTests.java:1027)
        at org.opensearch.index.shard.SegmentReplicationIndexShardTests.testReplicaRestarts(SegmentReplicationIndexShardTests.java:613)

Yep, thought I had run these. Removed that assertion that was tripping, it was asserting our processed seqNo was advanced on the replicas with every segment copy, which is now no longer guaranteed. We still assert on searchable docs.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2023

Gradle Check (Jenkins) Run Completed with:

@mch2
Copy link
Member Author

mch2 commented Mar 9, 2023

Gradle Check (Jenkins) Run Completed with:

REPRODUCE WITH: ./gradlew ':server:internalClusterTest' --tests "org.opensearch.indices.replication.SegmentReplicationAllocationIT.testAllocationWithDisruption" -Dtests.seed=C9506E4BC22F9615 -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=es-GT -Dtests.timezone=Pacific/Rarotonga -Druntime.java=19
NOTE: leaving temporary files on disk at: /var/jenkins/workspace/gradle-check/search/server/build/testrun/internalClusterTest/temp/org.opensearch.indices.replication.SegmentReplicationAllocationIT_C9506E4BC22F9615-001
NOTE: test params are: codec=Asserting(Lucene95): {index_uuid=Lucene90, type=PostingsFormat(name=Asserting)}, docValues:{}, maxPointsInLeafNode=1679, maxMBSortInHeap=7.955934483795881, sim=Asserting(RandomSimilarity(queryNorm=false): {}), locale=es-GT, timezone=Pacific/Rarotonga
NOTE: Linux 5.15.0-1028-aws amd64/Eclipse Adoptium 19.0.2 (64-bit)/cpus=96,threads=1,free=368206256,total=656408576
NOTE: All tests run in this JVM: [ForceMergeBlocksIT, RemoveSettingsCommandIT, IndexRequestBuilderIT, SegmentReplicationAllocationIT]

Looks like a flaky unrelated test, that seed was not reproducible.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2023

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

codecov-commenter commented Mar 9, 2023

Codecov Report

Merging #6594 (fe742ec) into main (a25f974) will increase coverage by 0.14%.
The diff coverage is 91.66%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##               main    #6594      +/-   ##
============================================
+ Coverage     70.69%   70.83%   +0.14%     
- Complexity    59076    59132      +56     
============================================
  Files          4804     4804              
  Lines        283081   283074       -7     
  Branches      40809    40807       -2     
============================================
+ Hits         200125   200528     +403     
+ Misses        66526    66084     -442     
- Partials      16430    16462      +32     
Impacted Files Coverage Δ
...c/main/java/org/opensearch/bootstrap/Security.java 32.86% <0.00%> (+0.22%) ⬆️
.../opensearch/index/engine/NRTReplicationEngine.java 78.47% <100.00%> (+5.74%) ⬆️
...in/java/org/opensearch/index/shard/IndexShard.java 70.18% <100.00%> (+0.02%) ⬆️
.../indices/replication/SegmentReplicationTarget.java 93.20% <100.00%> (ø)
.../replication/checkpoint/ReplicationCheckpoint.java 56.41% <100.00%> (-0.41%) ⬇️
.../java/org/opensearch/node/NodeClosedException.java 50.00% <0.00%> (-50.00%) ⬇️
...ava/org/opensearch/action/NoSuchNodeException.java 0.00% <0.00%> (-50.00%) ⬇️
...cluster/coordination/PendingClusterStateStats.java 20.00% <0.00%> (-48.00%) ⬇️
.../admin/cluster/reroute/ClusterRerouteResponse.java 60.00% <0.00%> (-40.00%) ⬇️
...luster/routing/allocation/RoutingExplanations.java 62.06% <0.00%> (-37.94%) ⬇️
... and 468 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@dreamer-89
Copy link
Member

dreamer-89 commented Mar 9, 2023

Gradle Check (Jenkins) Run Completed with:

REPRODUCE WITH: ./gradlew ':server:internalClusterTest' --tests "org.opensearch.indices.replication.SegmentReplicationAllocationIT.testAllocationWithDisruption" -Dtests.seed=C9506E4BC22F9615 -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=es-GT -Dtests.timezone=Pacific/Rarotonga -Druntime.java=19
NOTE: leaving temporary files on disk at: /var/jenkins/workspace/gradle-check/search/server/build/testrun/internalClusterTest/temp/org.opensearch.indices.replication.SegmentReplicationAllocationIT_C9506E4BC22F9615-001
NOTE: test params are: codec=Asserting(Lucene95): {index_uuid=Lucene90, type=PostingsFormat(name=Asserting)}, docValues:{}, maxPointsInLeafNode=1679, maxMBSortInHeap=7.955934483795881, sim=Asserting(RandomSimilarity(queryNorm=false): {}), locale=es-GT, timezone=Pacific/Rarotonga
NOTE: Linux 5.15.0-1028-aws amd64/Eclipse Adoptium 19.0.2 (64-bit)/cpus=96,threads=1,free=368206256,total=656408576
NOTE: All tests run in this JVM: [ForceMergeBlocksIT, RemoveSettingsCommandIT, IndexRequestBuilderIT, SegmentReplicationAllocationIT]

Looks like a flaky unrelated test, that seed was not reproducible.

I see this test fails here while asserting per index primary balance after one-third nodes are stopped. I think this can fail in certain scenarios which restricts primary shard movement to nodes already containing replica copies (due to SameShardAllocationDecider). Will raise a PR to fix this.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2023

Gradle Check (Jenkins) Run Completed with:

Copy link
Member

@dreamer-89 dreamer-89 left a comment

Choose a reason for hiding this comment

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

LGTM!

@dreamer-89 dreamer-89 added the backport 2.x Backport to 2.x branch label Mar 9, 2023
@dreamer-89 dreamer-89 merged commit f4739bb into opensearch-project:main Mar 9, 2023
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-6594-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 f4739bb8757d0153d01e83b3aaf8b76724ba3b04
# Push it to GitHub
git push --set-upstream origin backport/backport-6594-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-6594-to-2.x.

@dreamer-89
Copy link
Member

@mch2 : Backport workflow failing, care to raise a manual backport

mch2 added a commit to mch2/OpenSearch that referenced this pull request Mar 9, 2023
…nd use UserData to transfer state. (opensearch-project#6594)

* Segment Replication - Fix incorrect maxSeqNo computation.

This change updates getLatestSegmentInfos to only return the max seqNo from the previous
commit point.  This is the only way to guarantee that up to this seqNo has made it into the commit point.

Signed-off-by: Marc Handalian <[email protected]>

* Remove unnecessary seqNo field from ReplicationCheckpoint.

Signed-off-by: Marc Handalian <[email protected]>

---------

Signed-off-by: Marc Handalian <[email protected]>
(cherry picked from commit f4739bb)
@mch2 mch2 deleted the 6588 branch March 9, 2023 18:18
mch2 added a commit to mch2/OpenSearch that referenced this pull request Mar 9, 2023
…nd use UserData to transfer state. (opensearch-project#6594)

* Segment Replication - Fix incorrect maxSeqNo computation.

This change updates getLatestSegmentInfos to only return the max seqNo from the previous
commit point.  This is the only way to guarantee that up to this seqNo has made it into the commit point.

Signed-off-by: Marc Handalian <[email protected]>

* Remove unnecessary seqNo field from ReplicationCheckpoint.

Signed-off-by: Marc Handalian <[email protected]>

---------

Signed-off-by: Marc Handalian <[email protected]>
(cherry picked from commit f4739bb)
Signed-off-by: Marc Handalian <[email protected]>
mch2 added a commit to mch2/OpenSearch that referenced this pull request Mar 9, 2023
…nd use UserData to transfer state. (opensearch-project#6594)

* Segment Replication - Fix incorrect maxSeqNo computation.

This change updates getLatestSegmentInfos to only return the max seqNo from the previous
commit point.  This is the only way to guarantee that up to this seqNo has made it into the commit point.

Signed-off-by: Marc Handalian <[email protected]>

* Remove unnecessary seqNo field from ReplicationCheckpoint.

Signed-off-by: Marc Handalian <[email protected]>

---------

Signed-off-by: Marc Handalian <[email protected]>
(cherry picked from commit f4739bb)
Signed-off-by: Marc Handalian <[email protected]>
dreamer-89 pushed a commit that referenced this pull request Mar 9, 2023
…nd use UserData to transfer state. (#6594) (#6601)

* Segment Replication - Fix incorrect maxSeqNo computation.

This change updates getLatestSegmentInfos to only return the max seqNo from the previous
commit point.  This is the only way to guarantee that up to this seqNo has made it into the commit point.



* Remove unnecessary seqNo field from ReplicationCheckpoint.



---------


(cherry picked from commit f4739bb)

Signed-off-by: Marc Handalian <[email protected]>
mingshl pushed a commit to mingshl/OpenSearch-Mingshl that referenced this pull request Mar 24, 2023
…nd use UserData to transfer state. (opensearch-project#6594)

* Segment Replication - Fix incorrect maxSeqNo computation.

This change updates getLatestSegmentInfos to only return the max seqNo from the previous
commit point.  This is the only way to guarantee that up to this seqNo has made it into the commit point.

Signed-off-by: Marc Handalian <[email protected]>

* Remove unnecessary seqNo field from ReplicationCheckpoint.

Signed-off-by: Marc Handalian <[email protected]>

---------

Signed-off-by: Marc Handalian <[email protected]>
Signed-off-by: Mingshi Liu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] [Segment Replication] Error computing max seqNo from SegmentInfos.
3 participants