Skip to content

Commit

Permalink
infoschema: Remove the unimplemented ALL_SQL_DIGESTS column from the …
Browse files Browse the repository at this point in the history
…DEADLOCKS table (pingcap#24939)
  • Loading branch information
MyonKeminta authored May 27, 2021
1 parent f3557bb commit b64f900
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
10 changes: 5 additions & 5 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8232,11 +8232,11 @@ func (s *testSerialSuite) TestDeadlockTable(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustQuery("select * from information_schema.deadlocks").Check(
testutil.RowsWithSep("/",
id1+"/2021-05-10 01:02:03.456789/0/101/aabbccdd/6B31/<nil>/102",
id1+"/2021-05-10 01:02:03.456789/0/102/ddccbbaa/6B32/[sql1]/101",
id2+"/2022-06-11 02:03:04.987654/1/201/<nil>/<nil>/[]/202",
id2+"/2022-06-11 02:03:04.987654/1/202/<nil>/<nil>/[sql1, sql2, sql3]/203",
id2+"/2022-06-11 02:03:04.987654/1/203/<nil>/<nil>/<nil>/201",
id1+"/2021-05-10 01:02:03.456789/0/101/aabbccdd/6B31/102",
id1+"/2021-05-10 01:02:03.456789/0/102/ddccbbaa/6B32/101",
id2+"/2022-06-11 02:03:04.987654/1/201/<nil>/<nil>/202",
id2+"/2022-06-11 02:03:04.987654/1/202/<nil>/<nil>/203",
id2+"/2022-06-11 02:03:04.987654/1/203/<nil>/<nil>/201",
))
}

Expand Down
3 changes: 2 additions & 1 deletion infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -1368,8 +1368,9 @@ var tableDeadlocksCols = []columnInfo{
{name: "TRY_LOCK_TRX_ID", tp: mysql.TypeLonglong, size: 21, flag: mysql.NotNullFlag | mysql.UnsignedFlag, comment: "The transaction ID (start ts) of the transaction that's trying to acquire the lock"},
{name: "CURRENT_SQL_DIGEST", tp: mysql.TypeVarchar, size: 64, comment: "The digest of the SQL that's being blocked"},
{name: "KEY", tp: mysql.TypeBlob, size: types.UnspecifiedLength, comment: "The key on which a transaction is waiting for another"},
{name: "ALL_SQL_DIGESTS", tp: mysql.TypeBlob, size: types.UnspecifiedLength, comment: "A list of the digests of SQL statements that the transaction has executed"},
{name: "TRX_HOLDING_LOCK", tp: mysql.TypeLonglong, size: 21, flag: mysql.NotNullFlag | mysql.UnsignedFlag, comment: "The transaction ID (start ts) of the transaction that's currently holding the lock"},
// TODO: Implement the ALL_SQL_DIGESTS column
// {name: "ALL_SQL_DIGESTS", tp: mysql.TypeBlob, size: types.UnspecifiedLength, comment: "A list of the digests of SQL statements that the transaction has executed"},
}

var tableDataLockWaitsCols = []columnInfo{
Expand Down
9 changes: 3 additions & 6 deletions util/deadlockhistory/deadlock_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (d *DeadlockHistory) GetAllDatum() [][]types.Datum {

rows := make([][]types.Datum, 0, rowsCount)

row := make([]interface{}, 8)
row := make([]interface{}, 7)
for _, rec := range records {
row[0] = rec.ID
row[1] = types.NewTime(types.FromGoTime(rec.OccurTime), mysql.TypeTimestamp, types.MaxFsp)
Expand All @@ -148,12 +148,9 @@ func (d *DeadlockHistory) GetAllDatum() [][]types.Datum {
row[5] = strings.ToUpper(hex.EncodeToString(item.Key))
}

row[6] = nil
if item.AllSQLDigests != nil {
row[6] = "[" + strings.Join(item.AllSQLDigests, ", ") + "]"
}
row[6] = item.TxnHoldingLock

row[7] = item.TxnHoldingLock
// TODO: Implement the ALL_SQL_DIGESTS column for the deadlock table.

rows = append(rows, types.MakeDatums(row...))
}
Expand Down
26 changes: 11 additions & 15 deletions util/deadlockhistory/deadlock_history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (s *testDeadlockHistorySuite) TestGetDatum(c *C) {
res := h.GetAllDatum()
c.Assert(len(res), Equals, 4)
for _, row := range res {
c.Assert(len(row), Equals, 8)
c.Assert(len(row), Equals, 7)
}

toGoTime := func(d types.Datum) time.Time {
Expand All @@ -195,37 +195,33 @@ func (s *testDeadlockHistorySuite) TestGetDatum(c *C) {
return t
}

c.Assert(res[0][0].GetValue(), Equals, uint64(1)) // ID
c.Assert(toGoTime(res[0][1]), Equals, time1) // OCCUR_TIME
c.Assert(res[0][2].GetValue(), Equals, int64(0)) // RETRYABLE
c.Assert(res[0][3].GetValue(), Equals, uint64(101)) // TRY_LOCK_TRX_ID
c.Assert(res[0][4].GetValue(), Equals, "sql1") // SQL_DIGEST
c.Assert(res[0][5].GetValue(), Equals, "6B31") // KEY
c.Assert(res[0][6].GetValue(), Equals, "[sql1, sql2]") // ALL_SQL_DIGESTS
c.Assert(res[0][7].GetValue(), Equals, uint64(102)) // TRX_HOLDING_LOCK
c.Assert(res[0][0].GetValue(), Equals, uint64(1)) // ID
c.Assert(toGoTime(res[0][1]), Equals, time1) // OCCUR_TIME
c.Assert(res[0][2].GetValue(), Equals, int64(0)) // RETRYABLE
c.Assert(res[0][3].GetValue(), Equals, uint64(101)) // TRY_LOCK_TRX_ID
c.Assert(res[0][4].GetValue(), Equals, "sql1") // SQL_DIGEST
c.Assert(res[0][5].GetValue(), Equals, "6B31") // KEY
c.Assert(res[0][6].GetValue(), Equals, uint64(102)) // TRX_HOLDING_LOCK

c.Assert(res[1][0].GetValue(), Equals, uint64(1)) // ID
c.Assert(toGoTime(res[1][1]), Equals, time1) // OCCUR_TIME
c.Assert(res[1][2].GetValue(), Equals, int64(0)) // RETRYABLE
c.Assert(res[1][3].GetValue(), Equals, uint64(102)) // TRY_LOCK_TRX_ID
c.Assert(res[1][4].GetValue(), Equals, nil) // SQL_DIGEST
c.Assert(res[1][5].GetValue(), Equals, nil) // KEY
c.Assert(res[1][6].GetValue(), Equals, nil) // ALL_SQL_DIGESTS
c.Assert(res[1][7].GetValue(), Equals, uint64(101)) // TRX_HOLDING_LOCK
c.Assert(res[1][6].GetValue(), Equals, uint64(101)) // TRX_HOLDING_LOCK

c.Assert(res[2][0].GetValue(), Equals, uint64(2)) // ID
c.Assert(toGoTime(res[2][1]), Equals, time2) // OCCUR_TIME
c.Assert(res[2][2].GetValue(), Equals, int64(1)) // RETRYABLE
c.Assert(res[2][3].GetValue(), Equals, uint64(201)) // TRY_LOCK_TRX_ID
c.Assert(res[2][6].GetValue(), Equals, "[]") // ALL_SQL_DIGESTS
c.Assert(res[2][7].GetValue(), Equals, uint64(202)) // TRX_HOLDING_LOCK
c.Assert(res[2][6].GetValue(), Equals, uint64(202)) // TRX_HOLDING_LOCK

c.Assert(res[3][0].GetValue(), Equals, uint64(2)) // ID
c.Assert(toGoTime(res[3][1]), Equals, time2) // OCCUR_TIME
c.Assert(res[3][2].GetValue(), Equals, int64(1)) // RETRYABLE
c.Assert(res[3][3].GetValue(), Equals, uint64(202)) // TRY_LOCK_TRX_ID
c.Assert(res[3][6].GetValue(), Equals, "[sql1]") // ALL_SQL_DIGESTS
c.Assert(res[3][7].GetValue(), Equals, uint64(201)) // TRX_HOLDING_LOCK
c.Assert(res[3][6].GetValue(), Equals, uint64(201)) // TRX_HOLDING_LOCK
}

func (s *testDeadlockHistorySuite) TestErrDeadlockToDeadlockRecord(c *C) {
Expand Down

0 comments on commit b64f900

Please sign in to comment.