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

RestoreService should update primary terms when restoring shards of existing indices #38177

Merged
merged 1 commit into from
Feb 1, 2019

Conversation

tlrx
Copy link
Member

@tlrx tlrx commented Feb 1, 2019

When restoring shards of existing indices, the RestoreService also restores the values of primary terms stored in the snapshot index metadata. The primary terms are not updated and could potentially conflict with current index primary terms if the restored primary terms are lower than the existing ones.

This situation is likely to happen with replicated closed indices (because primary terms are increased when the index is transitioning from open to closed state, and the snapshotted primary terms are the one at the time the index was opened) (see #38024 (comment)) and maybe also with CCR.

This commit changes the RestoreService so that it updates the primary terms using the maximum value between the snapshotted values and the existing values. It also adds a basic integration test.

Related to #33888

@tlrx tlrx added >enhancement :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v7.0.0 v6.7.0 labels Feb 1, 2019
@tlrx tlrx requested a review from ywelsch February 1, 2019 11:14
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

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.

LGTM

@tlrx
Copy link
Member Author

tlrx commented Feb 1, 2019

@elasticmachine run elasticsearch-ci/default-distro
@elasticmachine run elasticsearch-ci/oss-distro-docs

@tlrx tlrx merged commit da6269b into elastic:master Feb 1, 2019
@tlrx tlrx deleted the restore-service-and-primary-terms branch February 1, 2019 14:59
@tlrx
Copy link
Member Author

tlrx commented Feb 1, 2019

Thanks @ywelsch !

tlrx added a commit to tlrx/elasticsearch that referenced this pull request Feb 1, 2019
…xisting indices (elastic#38177)

When restoring shards of existing indices, the RestoreService also
restores the values of primary terms stored in the snapshot index
metadata. The primary terms are not updated and could potentially
conflict with current index primary terms if the restored primary terms
are lower than the existing ones.

This situation is likely to happen with replicated closed indices
(because primary terms are increased when the index is transitioning
from open to closed state, and the snapshotted primary terms are the
one at the time the index was opened) (see elastic#38024) and maybe also
with CCR.

This commit changes the RestoreService so that it updates the primary
terms using the maximum value between the snapshotted values and
the existing values.

Backport elastic/elasticsearch@da6269b

Related to elastic#33888
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Feb 1, 2019
* master:
  Replace awaitBusy with assertBusy in atLeastDocsIndexed (elastic#38190)
  Adjust SearchRequest version checks (elastic#38181)
  AwaitsFix testClientSucceedsWithVerificationDisabled (elastic#38213)
  Zen2ify RareClusterStateIT (elastic#38184)
  ML: Fix error race condition on stop _all datafeeds and close _all jobs (elastic#38113)
  AwaitsFix PUT mapping with _doc on an index that has types (elastic#38204)
  Allow built-in monitoring_user role to call GET _xpack API (elastic#38060)
  Update geo_shape docs to include unsupported features (elastic#38138)
  [ML] Remove "8" prefixes from file structure finder timestamp formats (elastic#38016)
  Disable bwc tests while backporting elastic#38104 (elastic#38182)
  Enable TLSv1.3 by default for JDKs with support (elastic#38103)
  Fix _host based require filters (elastic#38173)
  RestoreService should update primary terms when restoring shards of existing indices (elastic#38177)
  Throw if two inner_hits have the same name (elastic#37645)
tlrx added a commit that referenced this pull request Feb 1, 2019
…xisting indices (#38177)

When restoring shards of existing indices, the RestoreService also
restores the values of primary terms stored in the snapshot index
metadata. The primary terms are not updated and could potentially
conflict with current index primary terms if the restored primary terms
are lower than the existing ones.

This situation is likely to happen with replicated closed indices
(because primary terms are increased when the index is transitioning
from open to closed state, and the snapshotted primary terms are the
one at the time the index was opened) (see #38024) and maybe also
with CCR.

This commit changes the RestoreService so that it updates the primary
terms using the maximum value between the snapshotted values and
the existing values.

Backport da6269b

Related to #33888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants