-
Notifications
You must be signed in to change notification settings - Fork 472
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
Improve consistency and isolation semantics by adding Context parameter to DB API #2310
Comments
Need some help:
This is the general idea: pass in the Most operations nowadays use WriteBatch. Is there any way to copy the operation sequence from |
Should we switch to |
Correction: Because there may be multiple Writes, they should be appended to ctx.WriteBatchWithIndex instead of simply copied |
@PokIsemaine I've checked that most output uses |
I think there are currently two ways:
For the DeleteRange operation, maybe we need to switch to for + Delete, but I don't know if this will have a big performance impact. If it is the first type, we just add Batch but do not perform Write operation, what will happen? 我认为目前两种方式:
对于 DeleteRange 操作,或许我们需要转为 for + Delete 的方式,但我不清楚这样是否会有很大的性能影响。如果是第一种,我们只是加入 Batch 但不进行 Write 操作,这样又会怎么样。 |
Some other questions:
另外的一些疑问:
|
(2) LockGuard protect the "keys" for operation. During writing, it first collects the key it tents to write, and Lock the all keys we would like to write (1) Is a interesting problem, I think we're looking forward to a SI ( snapshot isolation ). This cannot avoid concurrency read-modify-write sequence to same key. And it would making single write or multiple write operations seeing the same snapshot |
This should be unacceptable for the performance consideration. For example, it might cause the Kvrocks stop to service if it runs the FLUSH[DB|ALL] command with a large number of keys in the DB. To mitigate this, it'd be better to disallow using the DeleteRange operation in the transaction if necessary. |
I also think maybe we should checkout how we use |
Does this impact occur when |
https://github.com/facebook/rocksdb/wiki/DeleteRange-Implementation To be short DeleteRange write a explicit "range" tombstone, and this would affect scan, read, compaction... |
Currently it mainly affects kvrocks2redis, rdb and some test cases. |
Progress synchronization:
I'm trying the first option but currently in a specific version of GitHub Action, the golang test times out and I'm currently troubleshooting why. |
@PokIsemaine I'm sorry for didn't quite understand why we need to care about the WriteBatch. From the issue description, what we want to solve is that may use the undetermined snapshot while reading with nested read operations? If yes, passing the snapshot via the context is a good solution. For the write operation and transaction mode, the lock of the key should be able to protect the corresponding key won't be changed, so it should be good to leave it as it is. Help to correct me if I missed anything. |
The main-issue is framework-level read-after-write. I like a command issues a write and read after it. It's hard to ensure read "own-workspace" after this command may writing some data |
I see, thank you. But I can't remember if any commands will write-then-read except the Lua and transaction. |
@git-hulk @PokIsemaine I think currently we can first reject "DeleteRange" and check out other command works? IMO DeleteRange is mostly used in background. Maybe I can recheck the logic use "DeleteRange" in commands |
Yeah the current conversation goes beyond the issue title. I think it's related to this project: https://summer-ospp.ac.cn/org/prodetail/249430512?lang=en&list=pro |
Yes, we are discussing this project. I tried changing the title of this issue and grouping it into a new OSPP Tracking issues. |
Well done! |
1 similar comment
Well done! |
Search before asking
Motivation
The current DB API may use multiple read operations or have nested calls. These read operations do not use fixed snapshots, which may cause different snapshot data to be read during a single operation, causing inconsistency.
Solution
Referring to the current LatestSnapshot and GetOptions, we can add a Context parameter to each DB API, through which the API can pass a definite snapshot.
After a few simple attempts, I found that changes often have a ripple effect, requiring multiple modules to change their APIs at the same time, which can result in a huge PR that is difficult to break down into multiple smaller PRs. I'm going to try to give a draft PR in the near future to get a rough idea of what to do, and then gradually refine the changes to each module.
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: