-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: add retriver for tidb_hot_regions_history #27375
Conversation
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
…e key Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
…heck Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
143c248
to
78a9484
Compare
…x results order overlap Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
2201462
to
42a5c61
Compare
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
3a87459
to
f5b478b
Compare
Signed-off-by: IcePigZDB <icepigzdb@gmail.com> Co-authored-by: ShuNing <nolouch@gmail.com>
f5b478b
to
c8d8c11
Compare
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
PTAL @rleungx |
/uncc JmPotato |
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
sctx.GetSessionVars().StmtCtx.AppendWarning(result.err) | ||
} | ||
if result.err != nil || len(result.messages.HistoryHotRegion) == 0 { | ||
continue |
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.
move continue
to line 886 and check len(result.messages.HistoryHotRegion) > 0
?
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.
done.
) ([]types.Datum, error) { | ||
_, startKey, _ := codec.DecodeBytes(hisHotRegion.StartKey, []byte{}) | ||
_, endKey, _ := codec.DecodeBytes(hisHotRegion.EndKey, []byte{}) | ||
region := &tikv.KeyLocation{StartKey: startKey, EndKey: endKey} |
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.
Is there possible the old table is dropped?
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 have discussed this case, dropped tables' hot region will be ignore in current implement.
_, startKey, _ := codec.DecodeBytes(hisHotRegion.StartKey, []byte{})
_, endKey, _ := codec.DecodeBytes(hisHotRegion.EndKey, []byte{})
region := &tikv.KeyLocation{StartKey: startKey, EndKey: endKey}
hotRange, err := helper.NewRegionFrameRange(region)
if err != nil {
return nil, err
}
f := tikvHelper.FindTableIndexOfRegion(allSchemas, hotRange)
// Ignore row without corresponding schema f.
if f == nil {
return nil, nil
}
This case has been tested in memtable_reader_test.go/TestTiDBHotRegionsHistory
line 1097-1099, code run as expected.
// table_id = 131, index_id = 1, index_value = 1, deleted schema
{"2019-10-10 10:10:23", "UNKONW", "UNKONW", "131", "UNKONW", "1", "5", "5", "55555", "0", "1", "READ", "99", "99", "99", "99"},
{"2019-10-10 10:10:24", "UNKONW", "UNKONW", "131", "UNKONW", "1", "6", "6", "66666", "0", "0", "WRITE", "99", "99", "99", "99"},
@@ -541,6 +541,24 @@ func (helper extractHelper) convertToTime(t int64) time.Time { | |||
return time.Unix(0, t) | |||
} | |||
|
|||
func (helper extractHelper) extractRoleBoolSliceFromUint64Slice(uint64Slice []uint64) []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.
The function name is too long.
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.
change to convertToBoolSlice
according to previous func convertToTime
.
for _, k := range slice { | ||
l = append(l, fmt.Sprintf(`%t`, k)) | ||
} | ||
sort.Strings(l) |
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.
What is the purpose of sort?
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.
In unnormal case, user may query is_leader in(0,1)
, sort can keep the order of result string.
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
/merge |
This pull request has been accepted and is ready to merge. Commit hash: e4d113f
|
Signed-off-by: IcePigZDB icepigzdb@gmail.com
Problem Summary: Create a new table
TIDB_HOT_REGIONS_HISTORY
in theINFORMATION_SCHEMAT
database to retrieve history hotspot information stored by PD periodically.What problem does this PR solve?
Proposal: pingcap/tidb#27487
Associated Issue: #25281
Associated PRs in TiDB:
PRs splited from oversize PR #27224 in merge order :
Associated PR in PD:
PRs splited from old oversize one: tikv/pd/pull/3989
Check List
Tests
Side effects
Documentation
Release note