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

fix(Txn): serializable behavior is broken #2057 #2058

Closed
wants to merge 1 commit into from

Conversation

al8n
Copy link

@al8n al8n commented Apr 26, 2024

Hi! This PR is a try to fix #2057.

For the details, please see #2057 (comment)

This PR changes conflictKeys field from conflictKeys map[uint64]struct{} to conflictKeys map[uint64]int. The int is the length of the reads []uint64; store it so that when checking indirect conflict, we know the new write for each key happens after how many reads. And finally, when check conflicts, introduce a new loop to check logical conflicts (indirect conflicts).

After the changes, badger's transaction model can handle this kind of write skew https://wiki.postgresql.org/wiki/SSI#Intersecting_Data.

@al8n al8n requested a review from a team as a code owner April 26, 2024 05:26
@CLAassistant
Copy link

CLAassistant commented Apr 26, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

netlify bot commented Apr 26, 2024

Deploy Preview for badger-docs canceled.

Name Link
🔨 Latest commit 38a8dbb
🔍 Latest deploy log https://app.netlify.com/sites/badger-docs/deploys/662b3b175ff0600009273651

@al8n
Copy link
Author

al8n commented Apr 27, 2024

Closed as this solution cannot handle

db: [a1, a2, b1, b2]
txn1: read [a1, a2] -> sum range "a".."b" -> insert b3
txn2: read [b1, b2] -> sum range "b".."c" -> insert a3
txn2: commit
txn1: commit (fail) logical dependent

@al8n al8n closed this Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: serializable behavior is broken
2 participants