Skip to content

Fix: First Commit Win guarantee may be broken under high concurrency#378

Open
xuerongNanopay wants to merge 2 commits intosurrealdb:mainfrom
xuerongNanopay:fix_issues_376
Open

Fix: First Commit Win guarantee may be broken under high concurrency#378
xuerongNanopay wants to merge 2 commits intosurrealdb:mainfrom
xuerongNanopay:fix_issues_376

Conversation

@xuerongNanopay
Copy link
Copy Markdown

Thank you for submitting this pull request. We really appreciate you spending the time to work on SurrealDB. 🚀 🎉

What is the motivation?

The first-committer-wins guarantee may be broken under high concurrency.
The root cause is that the write-write conflict check doesn't not operate under serialization manner.

What does this change do?

  1. move validate_write_conflicts method into CommitEnv trait.
  2. use batch.starting_seq_num to store visible_seq_num for validate_write_conflicts initially, and will be updated to log sequence number before write to WAL
  3. Operate validating write-write conflict, WAL writing, and memtable insertion under write_mutex lock

What is your testing strategy?

Run tests in my local. All passed.

Is this related to any issues?

#376

Does this change need documentation?

  • No documentation needed

Does this change make any alterations to environment variables or CLI commands?

  • No changes made to env vars

Have you read the Contributing Guidelines?

@arriqaaq
Copy link
Copy Markdown
Contributor

Sorry for the delay in merging this. LGTM. I'll run some benchmarks and confirm

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

Successfully merging this pull request may close these issues.

2 participants