-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: Check index number in txn #29453
*: Check index number in txn #29453
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
a83c747
to
6afdac9
Compare
/run-integration-tests |
I'm not quite sure whether DDL or tools may use transactions that don't satisfy the constraint. |
Backfill transactions may lock the row keys and insert needed index keys, the lock operation would put zero value kv pairs into the |
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
…insertions' Signed-off-by: ekexium <[email protected]>
…insertions' Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
In such situation, #(row insertion) = 0, and we don't check the index counts. |
Signed-off-by: ekexium <[email protected]>
Theoretically I cannot find a case doesn't satisfy the rule at present. |
We could limit the usage of this check to user transaction and skip internal ones by now |
Signed-off-by: ekexium <[email protected]>
Good idea. Update: That's nonsense. The check is performed in a commit statement. |
@ekexium |
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
return errors.Trace(err) | ||
} | ||
for tableID, count := range indexInsertionCount { | ||
if rowInsertionCount[tableID] > 0 && count%rowInsertionCount[tableID] != 0 { |
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.
We could add some comments to explain the proof or invariant here.
@MyonKeminta PTAL |
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.
I'm actually still not very sure if this invariant is always true...
Signed-off-by: ekexium <[email protected]>
Me too, so I would like to see it if can pass regression tests. Can the comments somewhat convince you? |
At least I didn't come up with any counterexample.. |
// v no duplicates (index does not exist): PR + 1, PI + N | ||
// v duplicated (0 puts, M dels): PR + 1, DI - M, PI + N | ||
// note: duplicated index mutations can only come from deletions on unique indices | ||
// h is del |
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.
Does h does not exist
and h is del
indicates whether it exists in the current transaction's mem buffer?
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.
Yep. h is del
means it exists in the membuf and is a del.
} | ||
return nil | ||
} | ||
if err := kv.WalkMemBuffer(memBuffer, f); err != nil { |
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.
Does it process entries that's not modified but pessimistic-locked? Can it work with this change?
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.
Yes it will process the locked but not changed keys, as each unique index key used to fetch rowkey will be turned into a PUT
record, seems they are not compatibe, consider this:
create table t1(c1 int key, c2 int, c3 int, unique key uk(c2), key k1(c3));
insert into t1 values(1, 1, 1),(2, 2, 2),(3, 3, 3);
update t1 set c3 = c3 + 1 where c1 in (2, 3); // Use the batch point get executor.
here the to be committed keys are:
PUT uk 1->1 uk 2->2 uk 3->3
PUT sk 3_2 -> 2
PUT sk 4_3 -> 3
DEL sk 3_3 -> 3
DEL sk 2_2 -> 2
PUT rowkey 3-> 3, 3, 4
PUT rowkey 2-> 2, 2, 3
The number of PUT
on row is 2 and the number of PUT
on index is 5?
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
Seems @MyonKeminta has found a key point.
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.
Right.. it's an intentional special case. It seems to me we can't simply tell whether it comes from the optimization. A workaround might be adding a flag to indicate the special usage so they can be ignored in the 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.
The change is actually not expected and it's a temoprary solution to workaround the performance issues with many LOCK
records in the write cf
. Maybe we could put back this check after solving the LOCK
record issue so that these tricky optimization or transformation could be removed.
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.
I'm thinking if there is a method to distinguish the usage and won't block removing it.
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.
If we have to add some new flags to membuffer to handle this, I would suspect whether it worths...
@ekexium: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What problem does this PR solve?
Issue Number: close #xxx
Problem Summary:
It should be able to prevent some cases when index insertion is unexpectedly missing.
What is changed and how it works?
It asserts that the number of index insertions must be a multiple of row insertions.
Check List
Tests
Side effects
Documentation
Release note