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

Review current conflicts resolution logic #1159

Open
masipcat opened this issue Nov 17, 2021 · 0 comments
Open

Review current conflicts resolution logic #1159

masipcat opened this issue Nov 17, 2021 · 0 comments
Assignees

Comments

@masipcat
Copy link
Contributor

I was reviewing this part and I don't understand why the strategy resolve_readcommitted (the default one) needs the tpc_vote logic from resolve strategy.

If I'm not wrong, these are the cases we are trying to mitigate:

  1. Cache invalidation race condition: an object is modified but the next request that wants to modify the object reads the stale object. During the write to the storage, we want to detect that the old txn id is not the latest in postgres. This is already implemented in the UPDATE sql, using the WHERE tid = $7::bigint. If the WHERE clause doesn't match it would not update the object and we'll raise the ConflictError.

  2. Two concurrent requests modify the same object "at the same time". At the same time could mean two things:
    a. Both requests read the same object, the first starts the pg transaction and writes the changes and finished. When the second transaction starts will try to update the object and I'd would happen the error in point 1. The Old TID doesn't match and the ConflictError is raised.
    b. Both requets read the same object, the first request starts the transaction and writes the changes. At the same time, before committing the pg transaction the second request starts a transaction and tries to write the same object. In that case two things could happen:

    1. same thing as previous points: TID mismatch -> Conflict.
    2. deadlock and both requests fail

My conclusion is that in all these situations postgres/SQL queries already handle the conflicts, and there is no need for the extra logic. The only case I could think this is useful is for Cockroach DB.

./cc @bloodbare @vangheem

Originally posted by @masipcat in #1154 (comment)

@masipcat masipcat self-assigned this Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant