Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ch7: mention a "compare-and-set" alternative to "repeatable read" #331

Open

Description

If I'm not mistaken, there is an alternative way to disallow concurrent updates of the same product that doesn't require going up an isolation level from the default "read committed". That way is to use version number increments in conjunction with the "UPDATE ... WHERE product.version = ..." query. If two transactions try to modify the same product, the second one waits for the first one to commit, executes the update, and returns with zero affected rows, because the product's version has already been incremented by the first transaction, at which point we roll back the second one in the app.

I believe it would benefit the reader to be pointed to this pattern, even if in a footnote. It's described as a "compare and set" way to prevent lost updates in the "Transactions" chapter of Kleppmann's "Designing Data-Intensive Applications". That chapter is a good source on transaction isolation to direct the reader at.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /