-
Notifications
You must be signed in to change notification settings - Fork 473
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
refactor: Improve consistency and isolation semantics by adding Context parameter to DB API #2332
Conversation
I'll be moving forward with this PR these days, and since it's been a long time, I'll start by resolving the current conflicts and synchronizing the code with the latest unstable. |
NOTE: Therefore, to better advance this work, I believe we need to conduct the review gradually and multiple times. At the start of each review, I will post a Although there are still some If you think this approach is feasible, I will soon start the first review, change the PR from |
REVIEW 1:
Currently, we haven't assigned reviewers for this PR. If it's convenient, I would like to kindly request @mapleFU , @git-hulk , and @PragmaTwice to assist with the review. I understand this may take some time, so please feel free to do it at your convenience. Your feedback and suggestions will be greatly appreciated. Thank you very much for your help. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your contribution!
This PR is quite large, so we may need a longer time to gradually familiarize ourselves with the changes and provide our suggestions : )
It can be removed if the Context class handles them well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I'll take a carefully pass tonight!
Currently, the main focus is on syncing with the unstable branch. If it's convenient, I suggest starting the review and discussion as soon as possible, because the PR will become more complex as we progress. For less critical improvements and optimizations, we can temporarily mark them as TODOs to be addressed in future iterations. I believe we should prioritize completing a basic functional version first. Thank you again for taking the time to provide guidance and suggestions. 😽 |
Thanks for the efforts:
Actually I didn't fully get what does this part means, can you explain it with some examples? |
This was a previous judgment, but there was a misunderstanding. Now I think these issues are also caused by #2473 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % some nits! Thanks!
@PragmaTwice @git-hulk This pr is ready % some nits and comments, and it's ready for review, would you mind take a look? |
Sure, will retake another pass tomorrow. |
@PokIsemaine Sorry for the late review, a few comments inline. |
Unrelated to this pr: I think we can also add a server side conf to allow disable |
I agree, this PR has a wider impact and we should provide the option to turn it on and off. In subsequent observations, in addition to performance and errors, memory usage also needs attention, because we have an additional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, but I think we need fast collect all of us' approve since it's really huge
@PragmaTwice @git-hulk
I'll draft to merge this patch if no negative comment this week |
Will merge this after ci pass |
I'm good with this. |
Quality Gate passedIssues Measures |
issue: #2310
This is just a draft PR to demonstrate ideas, so there are a lot of imperfections.
A. How:
Add a Context parameter to each DB API. The Context contains the fixed snapshot during the entire call process and the resulting operations (stored using rocksdb::WriteBatchWithIndex).
Start of call: Construct
Context
, use snapshot for fixed call, and pass it to DB API as a parameterDuring the call:
Read operation:
GetFromBatchAndDB
to read data. Only two parts of data can be seen in one call: the write operation data in this call stored inrocksdb::WriteBatchWithIndex
; the snapshot isContext.snapshot
DB data at the time. (NewIterator
andMultiGet
use the same method)Write operations:
GetBatchBase
gets aWriteBatch
, then adds operations toWriteBatch
, and then writes the operations inWriteBatch
to DB.writeToDB
part of Write and implement aWriteBatch::Handler
(tentatively namedWriteBatchIndexer
) for iterating the operations inWriteBatch
and appending them toWriteBatchWithIndex
ofContext
.B. Possible codes to pay attention to:
storage:
redis_db: As an example, other APIs are derived from the redis_db API
cmd_xx: Construct a new Context when executing
C. Description: This section is used to explain the modifications that you may feel strange.
CI part: I temporarily added the
-v
parameter to observe the running of golang integration tests in GitHub Action in more detailTest part:
engine::Context
toTestBase
to simplify test initialization. During the test process, I usedSetLatestSnapshot
ofContext
to get the latestsnapshot
and clear thebatch
inContext
. This is because some tests A large number of loops are used. If the same ctx is used all the time, the data of all loops will be accumulated on it, and lead to extremely long time consuming. This is unnecessary because for the test case we do not require multiple APIs to be guaranteed to read the samesnapshot
.TODO: TODO: ctx in the implementation code means that I am not sure whether the ctx setting here is correct. Should it come from the upper parameters or create a Context myself? Where is the boundary of the Context. I'm not familiar with the search, slot, etc. parts yet.
D. Improvement: The following are the points that I currently consider need to be improved.
Context
should be able to replace the originalLatestSnapshot
,GetOptions
, and merge part of the API'sReadOptions
Performance testing, especially testing of DeleteRange related operations (if not ideal, try disabling it)
E. suggestion: