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

Atomic Concurrency Checks #1231

Closed
ceturc opened this Issue Mar 3, 2019 · 0 comments

Comments

Projects
None yet
2 participants
@ceturc
Copy link
Contributor

ceturc commented Mar 3, 2019

Expected Behavior

Multiple concurrent patches to the same record, from different processes, should result in at least one patch failing with a 412 error (Precondition Failed)

Minimal example will be submitted via a P/R test case shortly.

Actual Behavior

If multiple patch requests are both processed at the same time in different processes, multiple conflicting patches will succeed with a 200, resulting in data inconsistency.

Environment

  • Python version: 3.6
  • Eve versions prior to commit 54fd697 (November 2016) did not have this issue. This issue was introduced with commit 54fd697 from issue #920

Discussion

Prior to commit 54fd697 from 2016-November, ETags would be verified
twice during a patch. One ETag check would be non-atomic by Eve,
then again atomically by MongoDB during app.data.update(filter).
The atomic ETag check was removed during issue #920 in 54fd697

When running Eve in a scale-out environment (multiple processes),
concurrent simultaneous updates are sometimes allowed, because
the Python-only ETag check is not atomic.

There is a critical section in patch_internal() between get_document()
and app.data.update() where a competing Eve process can change the
document and ETag.

I am working on a pull request that contains a proposed patch and a simple
test case that simulates this situation and will upload it shortly.

Thank you.

Chuck Turco

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.