-
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
gc_worker: Remove timezone name from the times that are saved in mysql.tidb #8745
Conversation
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
/run-all-tests |
@MyonKeminta Please fix ci |
LGTM |
/run-common-test |
Sorry.. I didn't make it to figure out what was wrong with CI... |
/run-common-test |
/run-common-test |
/run-all-tests |
/run-unit-test |
1 similar comment
/run-unit-test |
@zhexuany PTAL again thanks! |
@disksing PTAL |
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
if err != nil { | ||
// Remove the last field that separated by space | ||
parts := strings.Split(value, " ") | ||
prefix := strings.Join(parts[:len(parts)-1], " ") |
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.
Will it out of range?
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.
No, it should returns at least one parts. You split ""
by " "
then you should got [""]
. You can also see that the test has passed.
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
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
/run-all-tests |
/run-unit-test |
/run-all-tests |
/run-all-tests |
…l.tidb (pingcap#8745) Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
…l.tidb (pingcap#8745) Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
What problem does this PR solve?
gc_worker saves some times in mysql.tidb. These times are:
tikv_gc_safe_point
,tikv_gc_last_run_time
,tikv_gc_leader_lease
.Now our format is
20060102-15:04:05 -0700 MST
. The time zone is specified twice by"-0700"
and"MST"
. This seems to be ok, but unfortunately it caused a problem: in some environments, it can't get a timezone name properly, only to produce something like"20181218-19:53:37 +0800 +08"
. Then if we try to load it from the table, we will get an error when parsing the string, which sayscannot parse "+08" as "MST"
.This PR tries to solve this problem by deprecating the last field
"MST"
, but still be able to load the time with the old format.What is changed and how it works?
A function named
ParseTimeFromPrefix
was added. It tries to parse a time with specified format from a prefix of a given string, and the string should contain a space that separate the prefix and the rest of the string. So when we use this function to parse the string"20181218-19:53:37 +0800 +08"
or"20181218-19:53:37 +0800 CST"
with the format"20060102-15:04:05 -0700"
, we actually ignored the last"+08"
or"CST"
. So it's compatible with old format.Check List
Tests
Code changes
ParseTimeFromPrefix
20060102-15:04:05 -0700 MST
to20060102-15:04:05 -0700
Side effects
Related changes
This change is