-
Notifications
You must be signed in to change notification settings - Fork 230
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
memdb: prevent iterator invalidation #1563
memdb: prevent iterator invalidation #1563
Conversation
Signed-off-by: ekexium <[email protected]>
8ac9c7a
to
1a6d100
Compare
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
faf4853
to
4c16a14
Compare
Signed-off-by: ekexium <[email protected]>
916238e
to
e1a3b5a
Compare
Signed-off-by: ekexium <[email protected]>
74a0617
to
29fc98e
Compare
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
7faf0e1
to
941d94b
Compare
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
a5e313d
to
b15c57a
Compare
Signed-off-by: ekexium <[email protected]>
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.
rest LGTM
) | ||
} | ||
|
||
it.db.RLock() |
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.
Shall we move the RLock
operation before seqno check?
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.
It's discussed above. SnapshotSeqNo
is not supposed to be accessed concurrently. This is the property that SnapshotSeqNo
must have. Should this case happen we'd better expose this race
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.
Oh I get you, SnapshotSeqNo
is changed in very low frequency.
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.
@ekexium
Better to add some comments to explain the usage of RLock
here, others may not be familiar with the upper MemDB
and underlying ART
implementation and usages.
Signed-off-by: ekexium <[email protected]>
…-iter-invalidation
Signed-off-by: ekexium <[email protected]>
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
Signed-off-by: ekexium <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cfzjywxk, you06 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
ref pingcap/tidb#59153
To prevent potential misuse and iterator invalidation, modify the iterators provided by ART memdb as follows:
Iter
andIterReverse
now comes with an extra check: it is invalidated immediately by any write operation to the memdb after the creation of the iterator. Attempting to use such an invalidated iterator will result in a panic.SnapshotIter
andSnapshotIterReverse
will be replaced byBatchedSnapshotIter
.2.1.
SnapshotIter
is different fromIter
that it can be valid after write operations, but only becomes invalid if a write operation modifies the "snapshot".2.2. We need to introduce
BatchedSnapshotIter
instead of directly modifyingSnapshotIter
becauseSnapshotIter
maintains internal states and pointers. Consider a situation where a write operation causes changes to the internal data structure making the pointers invalid, while the snapshot should remain valid.2.3.
SnapshotIter
andSnapshotIterReverse
are not removed now for compatibility.RBT is unchanged as it is no longer used.
Pipelined MemDB still doesn't support iterators as it was.
Performance
Iterator microbenchmark
TiDB union scan executor
BatchedSnapshotIter
SnapshotIter