-
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
executor: Add insert/replace ignore/on duplicate key support for local temporary table #26636
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. |
/run-check_dev_2 |
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.
This PR is much more difficult than I first thought.
executor/insert.go
Outdated
if err = prefetchDataCache(ctx, txn, toBeCheckedRows); err != nil { | ||
return err | ||
// Temporary table need not to do prefetch because its all data are stored in the memory. | ||
if e.Table.Meta().TempTableType == model.TempTableNone { |
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.
Instead of change the code here, could we change the prefetchDataCache
to make it a dummy operation when it's on the temporary table?
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.
Both is ok to me. The reason why put the if statement outside is that the function prefetchDataCache
cannot access the table meta.
executor/point_get.go
Outdated
@@ -403,14 +403,9 @@ func (e *PointGetExecutor) get(ctx context.Context, key kv.Key) ([]byte, error) | |||
// fallthrough to snapshot get. | |||
} | |||
|
|||
// Global temporary table is always empty, so no need to send the request. |
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.
Why the global temporary table code is modified?
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 my fault... Line 407 should be modified to e.tblInfo.TempTableType != model.TempTableNone
. It's a draft and waiting for other prs to be merged first... so some tests are not added yet.
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 you find a bug here, it's better to file another PR for the bug.
Otherwise please reset 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.
Actually, there is no bug in previous code. Just because after we make TemporaryTableSnapshotReader
can read both local and global temporary data, it can be more elegant after this modification. But it's still ok to revert it.
/run-check_dev_2 |
/run-check_dev_2 |
return err | ||
// Temporary table need not to do prefetch because its all data are stored in the memory. | ||
if e.Table.Meta().TempTableType == model.TempTableNone { | ||
if _, err = prefetchUniqueIndices(ctx, txn, toBeCheckedRows); 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.
Could it be moved into perfetchUniqueIndices
just like here?
https://github.com/pingcap/tidb/pull/26636/files#diff-6024133129a4038bfa75513ee2ac6a664c9c184fbf026997ec69f6db006aa38cR178
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 question is what is the return of perfetchUniqueIndices
. If it returns an empty data, it seems not fit the semantics of the method. If it returns the data in temporary table, it seems unnecessary and no one depends the return to do anything...
executor/point_get.go
Outdated
@@ -403,14 +403,9 @@ func (e *PointGetExecutor) get(ctx context.Context, key kv.Key) ([]byte, error) | |||
// fallthrough to snapshot get. | |||
} | |||
|
|||
// Global temporary table is always empty, so no need to send the request. |
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 you find a bug here, it's better to file another PR for the bug.
Otherwise please reset this change ...
I'm wondering if we can make the changes simpler. For example:
Why do we need to consider a special case for temporary table?
What if we make The philosophy is that special logic make the code harder to maintain. The normal transaction update process code is critical for general cases, it's not worthy to sacrifice the readability on behalf of non-general code like the temporary table. (I'm not sure we can really achieve that goal ... just some personal thoughts.) |
Yes, wrap it in the txn it self is more elegant but I wonder it need more works to archive it. For example for |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 34a7283
|
@lcwangchao: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. 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 ti-community-infra/tichi repository. |
/run-check_dev_2 |
What problem does this PR solve?
Issue Number: close #26083
What is changed and how it works?
Add support for some clause of local temporary table:
Check List
Tests
Release note