Skip to content

Commit

Permalink
domain: save action type directly instead of left shift it (#39660)
Browse files Browse the repository at this point in the history
close #39656
  • Loading branch information
Defined2014 committed Dec 7, 2022
1 parent dc6d9a0 commit be09b67
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (do *Domain) tryLoadSchemaDiffs(m *meta.Meta, usedVersion, newVersion int64
}
phyTblIDs = append(phyTblIDs, IDs...)
for i := 0; i < len(IDs); i++ {
actions = append(actions, uint64(1<<diff.Type))
actions = append(actions, uint64(diff.Type))
}
}

Expand Down
8 changes: 4 additions & 4 deletions domain/schema_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,10 @@ func (s *schemaValidator) Update(leaseGrantTS uint64, oldVer, currVer int64, cha
actionTypes = change.ActionTypes
}
for idx, ac := range actionTypes {
// NOTE: ac is not an action type, it is (1 << action type).
if ac == 1<<model.ActionUnlockTable {
if ac == uint64(model.ActionUnlockTable) {
s.do.Store().GetMemCache().Delete(tblIDs[idx])
}
if ac == 1<<model.ActionFlashbackCluster {
if ac == uint64(model.ActionFlashbackCluster) {
s.do.InfoSyncer().GetSessionManager().KillNonFlashbackClusterConn()
}
}
Expand Down Expand Up @@ -187,7 +186,8 @@ func (s *schemaValidator) isRelatedTablesChanged(currVer int64, tableIDs []int64
for i, tblID := range item.relatedIDs {
for _, relatedTblID := range tableIDs {
if tblID == relatedTblID {
changedTblMap[tblID] |= item.relatedActions[i]
// if actionType >= 64, the value of left shift equals 0, and it will not impact amend txn
changedTblMap[tblID] |= 1 << item.relatedActions[i]
affected = true
}
}
Expand Down
2 changes: 1 addition & 1 deletion domain/schema_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func subTestEnqueueActionType(t *testing.T) {
relatedChanges, isTablesChanged := validator.isRelatedTablesChanged(5, []int64{1, 2, 3, 4})
require.True(t, isTablesChanged)
require.Equal(t, []int64{1, 2, 3, 4}, relatedChanges.PhyTblIDS)
require.Equal(t, []uint64{15, 2, 7, 4}, relatedChanges.ActionTypes)
require.Equal(t, []uint64{(1 << 1) | (1 << 15), 1 << 2, (1 << 3) | (1 << 4), 1 << 4}, relatedChanges.ActionTypes)
}

type leaseGrantItem struct {
Expand Down

0 comments on commit be09b67

Please sign in to comment.