-
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, store: fixed daylight saving time issue #6823
executor, store: fixed daylight saving time issue #6823
Conversation
@@ -1098,7 +1099,7 @@ func (b *executorBuilder) buildAnalyzeIndexPushdown(task plan.AnalyzeIndexTask) | |||
Tp: tipb.AnalyzeType_TypeIndex, | |||
StartTs: math.MaxUint64, | |||
Flags: statementContextToFlags(b.ctx.GetSessionVars().StmtCtx), | |||
TimeZoneOffset: timeZoneOffset(b.ctx), |
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.
@lamxTyler For analyse executor, do we need timezone name too?
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.
Do not need.
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.
@lamxTyler Is offset needed in analyzer?
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.
ping @lamxTyler
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.
Seems not needned.
2fcc3a2
to
4a59ac4
Compare
|
@shenli I usually created PR via command-line. That is being said, I will fill info later via website. For second question, I can certainly do this. |
Please fix the CI and resolve the conflicts. |
654c0d9
to
61e72f8
Compare
Please fix the CI. |
e3d702f
to
249bd55
Compare
/run-all-tests |
@shenli I was on a vacation break. Sorry for the delay. Now, CI has been fixed. PTAL |
@zhexuany |
Already checked with engineer from tikv. TiKV does not need handle this. |
|
var LocCache *locCache | ||
|
||
func (lm *locCache) getLoc(name string) (*time.Location, error) { | ||
if v, ok := lm.locMap[name]; ok { |
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.
Need read lock
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. This was already fixed.
c8e3626
to
eb92e87
Compare
expression/builtin_time.go
Outdated
@@ -1889,7 +1889,7 @@ func (b *builtinSysDateWithFspSig) evalTime(row types.Row) (d types.Time, isNull | |||
return types.Time{}, isNull, errors.Trace(err) | |||
} | |||
|
|||
tz := b.ctx.GetSessionVars().GetTimeZone() | |||
tz := b.ctx.GetSessionVars().Location() |
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.
s/tz/loc/?
// GetTimeZone returns the value of time_zone session variable. | ||
func (s *SessionVars) GetTimeZone() *time.Location { | ||
// Location returns the value of time_zone session variable. If it is nil, then return time.Local. | ||
func (s *SessionVars) Location() *time.Location { | ||
loc := s.TimeZone |
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 may need to rename s.TimeZone
to s.Location
or any other proper names.
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.
Location is better and also time package uses the same name.
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, we can do it in another PR, keep this PR focused on the daylight saving time issue.
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.
Already did - -.
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 changed to Loc
eventually.
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.
OK
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 saw a conflict and to avoid further change I undo my changes and I will file another PR for changing this once this PR gets merged into master.
store/tikv/gcworker/gc_worker.go
Outdated
if err != nil { | ||
_, err1 := se.Execute(ctx, "ROLLBACK") | ||
terror.Log(errors.Trace(err1)) | ||
return false, errors.Trace(err) | ||
} | ||
err = w.saveTime(gcLeaderLeaseKey, time.Now().Add(gcWorkerLease), se) | ||
fmt.Println("fuck" + time.Now().String()) |
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.
remove debug log.
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.
Hahahahaha! @zhexuany
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 totally understand your mind!
6573b27
to
690c644
Compare
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
@@ -1272,7 +1275,7 @@ func (b *executorBuilder) buildAnalyzeColumnsPushdown(task plan.AnalyzeColumnsTa | |||
Tp: tipb.AnalyzeType_TypeColumn, | |||
StartTs: math.MaxUint64, | |||
Flags: statementContextToFlags(b.ctx.GetSessionVars().StmtCtx), | |||
TimeZoneOffset: timeZoneOffset(b.ctx), | |||
TimeZoneOffset: offset, |
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.
Should we add TimeZoneName in Analyze request? @lamxTyler
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.
Already confirmed with him. No need to consider dst in statistics.
@@ -1938,6 +1938,7 @@ func (s *testSuite) TestTimestampTimeZone(c *C) { | |||
r.Check(testkit.Rows("123381351 1734 2014-03-31 08:57:10 127.0.0.1")) // Cover IndexLookupExec | |||
|
|||
// For issue https://github.com/pingcap/tidb/issues/3485 | |||
tk.MustExec("set time_zone = 'Asia/Shanghai'") |
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 should we add this line? Is there any dst issue in the test case?
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.
Please refer to line 1907. It sets timezone with offset -6. If we want to compare datetime correctly, we have to set timezone as Asia/Shanghai
.
// Talked with Golang team about whether they can have some forms of cache policy available for programmer, | ||
// they suggests that only programmers knows which one is best for their use case. | ||
// For detail, please refer to: https://github.com/golang/go/issues/26106 | ||
type locCache struct { |
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.
How about locationCache? locCache looks like lockCache.
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.
loc is generally used everywhere in our codebase. Additionally, it is generally used in time
package.
if sc.TimeZone, err = LocCache.getLoc(dagReq.TimeZoneName); err != nil { | ||
return nil, nil, nil, errors.Trace(err) | ||
} | ||
dagReq.TimeZoneName = sc.TimeZone.String() |
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 set dagReq.TimeZoneName
?
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 set dagReq.TimeZoneOffset
here, so do dagReq.TimeZoneName
.
@@ -240,7 +240,7 @@ func (w *GCWorker) leaderTick(ctx context.Context) error { | |||
return nil | |||
} | |||
|
|||
// prepare checks required conditions for starting a GC job. It returns a bool | |||
// prepare checks preconditions for starting a GC job. It returns a bool |
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 change this file? Is it related to the dst issue?
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 has nothing to do with dst issue. I change it mainly becuase GCoworker
already has session
as its variable so we do not need access such info with passing it as parameter around.
I found this on the way fixing dst, it should be done via another PR. I will be carefully next time.
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.
OK
LGTM |
/run-all-tests |
@zhexuany Please resolve the conflict. |
@coocood conflict was already resolved. |
Thank you for working on TiDB! Please read TiDB's CONTRIBUTING document BEFORE filing this PR.
What have you changed? (mandatory)
During coprocessor dag task, it first uses timezone
name
, if non-empty, to get legitimate timezone variable. To achieve this, we need push down such data into tikv which leads to change the logic of building pushdown request. The logic I mentioned mainly resides inexecutor
package.I change
timeZoneOffset
tozone
and add second return parametername string
. The intentioned of doing this to adopt the convention oftime
package.For the same purpose, I change
GetTimeZone
toLocation
. As you can see, intime
package, timezone was bind toLocation
.What are the type of the changes (mandatory)?
How has this PR been tested (mandatory)?