Skip to content

Commit

Permalink
infoschema: Use system local time for tables of lock view
Browse files Browse the repository at this point in the history
  • Loading branch information
MyonKeminta committed May 28, 2021
1 parent 348abf0 commit 88c9f5b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8178,7 +8178,7 @@ func (s *testSerialSuite) TestIssue24210(c *C) {
func (s *testSerialSuite) TestDeadlockTable(c *C) {
deadlockhistory.GlobalDeadlockHistory.Clear()

occurTime := time.Date(2021, 5, 10, 1, 2, 3, 456789000, time.UTC)
occurTime := time.Date(2021, 5, 10, 1, 2, 3, 456789000, time.Local)
rec := &deadlockhistory.DeadlockRecord{
OccurTime: occurTime,
IsRetryable: false,
Expand All @@ -8201,7 +8201,7 @@ func (s *testSerialSuite) TestDeadlockTable(c *C) {
}
deadlockhistory.GlobalDeadlockHistory.Push(rec)

occurTime2 := time.Date(2022, 6, 11, 2, 3, 4, 987654000, time.UTC)
occurTime2 := time.Date(2022, 6, 11, 2, 3, 4, 987654000, time.Local)
rec2 := &deadlockhistory.DeadlockRecord{
OccurTime: occurTime2,
IsRetryable: true,
Expand Down
6 changes: 3 additions & 3 deletions infoschema/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ func (s *testTableSuite) TestTrx(c *C) {
Username: "root",
CurrentDB: "test",
}
blockTime2 := time.Date(2021, 05, 20, 13, 18, 30, 123456000, time.UTC)
blockTime2 := time.Date(2021, 05, 20, 13, 18, 30, 123456000, time.Local)
sm.txnInfo[1] = &txninfo.TxnInfo{
StartTS: 425070846483628033,
CurrentSQLDigest: "",
Expand All @@ -1550,8 +1550,8 @@ func (s *testTableSuite) TestTrx(c *C) {
}
tk.Se.SetSessionManager(sm)
tk.MustQuery("select * from information_schema.TIDB_TRX;").Check(testkit.Rows(
"424768545227014155 2021-05-07 04:56:48.001000 "+digest.String()+" Normal <nil> 1 19 2 root test []",
"425070846483628033 2021-05-20 13:16:35.778000 <nil> LockWaiting 2021-05-20 13:18:30.123456 0 0 10 user1 db1 [sql1, sql2]"))
"424768545227014155 2021-05-07 12:56:48.001000 "+digest.String()+" Normal <nil> 1 19 2 root test []",
"425070846483628033 2021-05-20 21:16:35.778000 <nil> LockWaiting 2021-05-20 13:18:30.123456 0 0 10 user1 db1 [sql1, sql2]"))
}

func (s *testTableSuite) TestInfoschemaDeadlockPrivilege(c *C) {
Expand Down
3 changes: 1 addition & 2 deletions session/txninfo/txn_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ func (info *TxnInfo) ShallowClone() *TxnInfo {

// ToDatum Converts the `TxnInfo` to `Datum` to show in the `TIDB_TRX` table.
func (info *TxnInfo) ToDatum() []types.Datum {
// TODO: The timezone represented to the user is not correct and it will be always UTC time.
humanReadableStartTime := time.Unix(0, oracle.ExtractPhysical(info.StartTS)*1e6).UTC()
humanReadableStartTime := time.Unix(0, oracle.ExtractPhysical(info.StartTS)*1e6)

var currentDigest interface{}
if len(info.CurrentSQLDigest) != 0 {
Expand Down

0 comments on commit 88c9f5b

Please sign in to comment.