-
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
ddl: use the correct timezone to encode record for adding index (#46055) #46104
ddl: use the correct timezone to encode record for adding index (#46055) #46104
Conversation
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@@ -485,7 +485,7 @@ func getRestoreData(tblInfo *model.TableInfo, targetIdx, pkIdx *model.IndexInfo, | |||
|
|||
func buildDAGPB(sCtx sessionctx.Context, tblInfo *model.TableInfo, colInfos []*model.ColumnInfo) (*tipb.DAGRequest, error) { | |||
dagReq := &tipb.DAGRequest{} | |||
dagReq.TimeZoneName, dagReq.TimeZoneOffset = timeutil.Zone(sCtx.GetSessionVars().Location()) | |||
_, dagReq.TimeZoneOffset = timeutil.Zone(sCtx.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.
Why do we only need to change 'TimeZoneName' and not 'TimeZoneOffset'?
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## release-6.5 #46104 +/- ##
================================================
Coverage ? 74.3184%
================================================
Files ? 1084
Lines ? 353658
Branches ? 0
================================================
Hits ? 262833
Misses ? 74377
Partials ? 16448 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wjhuang2016, zimulala The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
/retest |
1 similar comment
/retest |
/retest-required |
This is an automated cherry-pick of #46055
What problem does this PR solve?
Issue Number: close #46033
Problem Summary:
Normally, TiDB converts
timestamp
values to UTC before writing them to the storage, and converts them back when reading. For adding index, weIn step 1, the datum returned by
extractDatumByOffsets()
is in UTC timezone. It is converted to UTC again in step 2. As a result, index timestamp is converted twice.Unistore DAG request decoding:
tidb/store/mockstore/unistore/cophandler/cop_handler.go
Lines 298 to 308 in 3846e80
TiKV DAG request decoding:
https://github.com/tikv/tikv/blob/14dd8cce96e064a029e58de8cf832c35d44e09a5/components/tidb_query_datatype/src/expr/ctx.rs#L86-L94
For Unistore and TiKV, the time zone name is always considered first, and the time zone offset second.
Thus, the way to
buildDAGPB
is wrong:tidb/ddl/index_cop.go
Line 487 in 3846e80
We assigned both name and offset to
UTC
and-0600
respectively.UTC
is kept but-0600
is discarded during parsing the DAG request.What is changed and how it works?
Assign the time zone offset in
buildDAGPB
, and leave time zone name to be empty.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.