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

Track local checkpoint on primary immediately #25434

Closed
wants to merge 14 commits into from

Conversation

jasontedor
Copy link
Member

Today after a primary shard is recovered or promoted from a replica, it will not be tracking its own local checkpoint until the first indexing operation on the shard. This leads to situations where a shard is relocated and the knowledge it sends in the primary context about its own local checkpoint violates the global checkpoint. This commit rectifies this situation by tracking the local checkpoint on such shards immediately on recovery/promotion/relocation.

Closes #25415, relates #10708, relates #25355

ywelsch and others added 5 commits June 27, 2017 17:38
Today after a primary shard is recovered or promoted from a replica, it
will not be tracking its own local checkpoint until the first indexing
operation on the shard. This leads to situations where a shard is
relocated and the knowledge it sends in the primary context about its
own local checkpoint violates the global checkpoint. This commit
rectifies this situation by tracking the local checkpoint on such shards
immediately on recovery/promotion/relocation.
@jasontedor
Copy link
Member Author

@ywelsch I'm opening this for discussion.

jasontedor and others added 8 commits June 27, 2017 14:58
* master:
  Do not swallow exception when relocating
  Docs: Fix typo for request cache (elastic#25444)
  Remove implicit 32-bit support
  [DOCS] reworded to prevent code span rendering glitch (elastic#25442)
  Disallow multiple concurrent recovery attempts for same target shard (elastic#25428)
  Update global checkpoint when increasing primary term on replica (elastic#25422)
  Add backwards compatibility indices for 5.4.3
  Add version 5.4.3 after release
  Update MSI installer images (elastic#25414)
  Add missing newline at end of SetsTests.java
  Rename handoff primary context transport handler
  correct expected thrown exception in mappingMetaData to ElasticsearchParseException (elastic#25410)
  test: Make many percolator integration tests real integration tests
  [DOCS] Update docs to use shared attribute file (elastic#25403)
  Add Javadocs and tests for set difference methods
  Tests: Add parsing test for AggregationsTests (elastic#25396)
  test: get upgrade status for all indices
  Mute SignificantTermsAggregatorTests#testSignificance()
…cal-checkpoint

* enhance/single-updateshardstate-method:
  Some cleanup
  Do not swallow exception when relocating
  Docs: Fix typo for request cache (elastic#25444)
  Remove implicit 32-bit support
  [DOCS] reworded to prevent code span rendering glitch (elastic#25442)
  Disallow multiple concurrent recovery attempts for same target shard (elastic#25428)
  Update global checkpoint when increasing primary term on replica (elastic#25422)
  Add backwards compatibility indices for 5.4.3
  Add version 5.4.3 after release
  Update MSI installer images (elastic#25414)
  Add missing newline at end of SetsTests.java
  fix test
  Rename handoff primary context transport handler
  Provide single IndexShard method to update state on incoming cluster state
* master:
  Use a single method to update shard state
@jasontedor
Copy link
Member Author

@ywelsch I think this is ready for you after integrating #25431.

Copy link
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.

I've made a suggestion around the update condition and suggested to use unit tests instead.

@@ -360,6 +365,7 @@ synchronized void updateAllocationIdsFromPrimaryContext(final PrimaryContext pri
.allMatch(e -> e.value == SequenceNumbersService.UNASSIGNED_SEQ_NO) : inSyncLocalCheckpoints;
assert StreamSupport
.stream(trackingLocalCheckpoints.spliterator(), false)
.filter(e -> !e.key.equals(allocationId)) // during primary relocation a shard can already know its local checkpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should not filter out the allocation id, but keep the method as before and instead assert in the IndexShard.updateAllocationIdsFromPrimaryContext method that the local checkpoint that is provided as part of the primary context is equal to the local checkpoint that exists locally.

final SequenceNumbersService seqNoService = engine.seqNoService();
seqNoService.updateAllocationIdsFromMaster(applyingClusterStateVersion, activeAllocationIds, initializingAllocationIds);
if ((currentState == IndexShardState.POST_RECOVERY && state == IndexShardState.STARTED) ||
recoveryState.getRecoverySource().getType().equals(RecoverySource.Type.PEER)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

With the change I suggested above we can leave out the == PEER condition and instead add && currentRouting.isRelocationTarget == false to currentState == IndexShardState.POST_RECOVERY && state == IndexShardState.STARTED

* Tests that a primary shard tracks its own local checkpoint after starting.
*/
@ESIntegTestCase.ClusterScope(scope = Scope.TEST, numDataNodes = 0)
public class LocalCheckpointIT extends ESIntegTestCase {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we need an integration test for this. A test under IndexShardTests would be able to check the same.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, now that we are not doing this via indices cluster state service, this is now possible. I will update.

@jasontedor
Copy link
Member Author

This will be superseded by a forthcoming PR.

@jasontedor jasontedor closed this Jun 28, 2017
@jasontedor jasontedor deleted the primary-local-checkpoint branch June 28, 2017 15:49
@jasontedor jasontedor restored the primary-local-checkpoint branch July 4, 2017 13:54
@jasontedor jasontedor deleted the primary-local-checkpoint branch July 4, 2017 13:54
@jasontedor jasontedor restored the primary-local-checkpoint branch July 4, 2017 13:54
@clintongormley clintongormley added :Distributed Indexing/Engine Anything around managing Lucene and the Translog in an open shard. and removed :Sequence IDs labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker >bug :Distributed Indexing/Engine Anything around managing Lucene and the Translog in an open shard. v6.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants