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

Core: create operation on replica should not throw DocumentAlreadyExistsException #7142

Closed
mikemccand opened this Issue Aug 4, 2014 · 0 comments

Comments

Projects
None yet
1 participant
@mikemccand
Contributor

mikemccand commented Aug 4, 2014

For a create operation, today we (by design) throw DAEE if the given _uid is already present in the index, even if its version is "old".

But when there are concurrent operations in flight against the same _uid this can be wrong, and was causing [rare] failures in SimpleVersioningTests.testRandomIDsAndVersions... the specific case was a given _uid was already in the index, and then a delete op (with higher version), and a create op (with higher version still) were issued concurrently.

On primary, the delete came first, succeeded, and then the create came second, and it succeeded. But on the replica, the create came first, and it threw DAEE (which we intentionally suppress & don't throw back to user), then the delete came, and it succeeded, leaving primary & replica silently out-of-sync.

To fix this, for a create op, if we are a replica, we should not throw DAEE: it means the primary has already decided the document should be indexed. Instead, we should fallback to the same logic index operation does, making sure the version is newer, and we must use IW.updateDocument/s in this case since the doc is in the index with an older version. We can still use the auto-gen'd ID optimization...

@mikemccand mikemccand added bug labels Aug 4, 2014

@mikemccand mikemccand self-assigned this Aug 4, 2014

mikemccand added a commit that referenced this issue Aug 4, 2014

Core: simultaneous create/delete against same id can cause silently i…
…nconsistent replica

If simultaneous create & delete operations arrive against the same id,
it's possible that primary and replica see those operations in
different orders, which may result in replica throwing
DocumentAlreadyExistsException when the primary didn't which would
lead to replica being inconsistent (missing a document that primary
had indexed).

This push fixes the issue, by never throwing DAEE from the replica on
create.

Closes #7146 #7142

mikemccand added a commit that referenced this issue Aug 4, 2014

Core: simultaneous create/delete against same id can cause silently i…
…nconsistent replica

If simultaneous create & delete operations arrive against the same id,
it's possible that primary and replica see those operations in
different orders, which may result in replica throwing
DocumentAlreadyExistsException when the primary didn't which would
lead to replica being inconsistent (missing a document that primary
had indexed).

This push fixes the issue, by never throwing DAEE from the replica on
create.

Closes #7146 #7142

@mikemccand mikemccand closed this Aug 4, 2014

@mikemccand mikemccand added the v1.3.0 label Aug 6, 2014

@mikemccand mikemccand changed the title from Create operation on replica should not throw DocumentAlreadyExistsException to Core: create operation on replica should not throw DocumentAlreadyExistsException Aug 6, 2014

mikemccand added a commit that referenced this issue Aug 6, 2014

Core: simultaneous create/delete against same id can cause silently i…
…nconsistent replica

If simultaneous create & delete operations arrive against the same id,
it's possible that primary and replica see those operations in
different orders, which may result in replica throwing
DocumentAlreadyExistsException when the primary didn't which would
lead to replica being inconsistent (missing a document that primary
had indexed).

This push fixes the issue, by never throwing DAEE from the replica on
create.

Closes #7146 #7142

@mikemccand mikemccand added v1.3.2 and removed v1.3.0 labels Aug 13, 2014

mikemccand added a commit that referenced this issue Sep 8, 2014

Core: simultaneous create/delete against same id can cause silently i…
…nconsistent replica

If simultaneous create & delete operations arrive against the same id,
it's possible that primary and replica see those operations in
different orders, which may result in replica throwing
DocumentAlreadyExistsException when the primary didn't which would
lead to replica being inconsistent (missing a document that primary
had indexed).

This push fixes the issue, by never throwing DAEE from the replica on
create.

Closes #7146 #7142

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015

Core: simultaneous create/delete against same id can cause silently i…
…nconsistent replica

If simultaneous create & delete operations arrive against the same id,
it's possible that primary and replica see those operations in
different orders, which may result in replica throwing
DocumentAlreadyExistsException when the primary didn't which would
lead to replica being inconsistent (missing a document that primary
had indexed).

This push fixes the issue, by never throwing DAEE from the replica on
create.

Closes #7146 #7142
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment