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
store/gc_worker: Fix that gc_delete_range table is queried with wrong form of TS #7610
store/gc_worker: Fix that gc_delete_range table is queried with wrong form of TS #7610
Conversation
@zhangjinpeng1987 PTAL |
ddl/util/util.go
Outdated
sql := fmt.Sprintf(loadDeleteRangeSQL, safePoint) | ||
// DeleteRange records in `gc_delete_range` table is saved with a timestamp in seconds, and the physical part of | ||
// safePoint's form is in milliseconds. Divide it by 1000 to get seconds. | ||
sql := fmt.Sprintf(loadDeleteRangeSQL, oracle.ExtractPhysical(safePoint)/1000) |
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 think you should add test to cover generating SQL.
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
I think we better rename |
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
404e59f
to
8799d92
Compare
@zhangjinpeng1987 @coocood PTAL again. Manual test is in progress. |
LGTM |
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
Tested on a TiDB cluster, with gc_run_interval and gc_lifetime both set to 10min. Producing the problemDrop a table:
Check log of GC:
It shows that Delete Range happens even that its life time (10min) haven't been expired. (In this log, the "re-delete range" is an additional operation in my another PR. It doesn't affect other behavior before it. It can be just ignored.) This PRDrop a table:
Check log of GC:
We can see that the range is not immediately deleted at the next time GC runs, but deleted in the second GC after it. |
@coocood I don't have write access to this repo. Please help me merge it. Thanks. |
/run-integration-tests |
/run-all-tests |
Signed-off-by: MyonKeminta MyonKeminta@users.noreply.github.com
What problem does this PR solve?
The GC worker checks table
mysql.gc_delete_range
with ts < safePoint and the ranges indicated by them. But unfortunately (and dramatically) the table was queried with incorrect form of TS previously. GCWorker calculated a safePoint in the formphysical << 18 | logical
, where thephysical
is a timestamp in milliseconds and logical is 0. However the ts field ingc_delete_range
is in seconds. So these timestamps in the table is always much less than safePoint, and as a result the ranges will be immediately deleted at the next time GC runs.This PR fixes it.
What is changed and how it works?
Check List
Tests
Related changes