-
Notifications
You must be signed in to change notification settings - Fork 66
backend/local: skip split regions if engine total size is smaller than region size #524
Conversation
/run-all-tests |
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.
LGTM
lightning/backend/local.go
Outdated
@@ -1181,10 +1181,14 @@ func (local *local) ImportEngine(ctx context.Context, engineUUID uuid.UUID) erro | |||
log.L().Info("start import engine", zap.Stringer("uuid", engineUUID), | |||
zap.Int("ranges", len(ranges))) | |||
|
|||
// if all the kv can fit in one region, skip split regions. TiDB will split one region for | |||
// the table when table is created. | |||
needSplit := len(ranges) > 0 || lf.TotalSize > local.regionSplitSize || lf.Length > regionMaxKeyCount |
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 needSplit := len(ranges) > 1
enough? seems readAndSplitIntoRange
has checked regionSplitSize
and regionMaxKeyCount
tidb-lightning/lightning/backend/local.go
Lines 811 to 815 in d9254b1
// <= 96MB no need to split into range | |
if engineFile.TotalSize <= local.regionSplitSize && engineFile.Length <= regionMaxKeyCount { | |
ranges := []Range{{start: firstKey, end: endKey, length: int(engineFile.Length)}} | |
return ranges, nil | |
} |
and splitRangeBySizeProps
uses a tighter keysLimit
so it will return more than 1 ranges
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.
splitRangeBySizeProps may still generate ranges that exceed regionSplitSize, so if the split is triggered by remain ranges, it may be a single range but the range size is exceeded.
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.
I see. Now I suggest
needSplit := len(ranges) > 0 || lf.TotalSize > local.regionSplitSize || lf.Length > regionMaxKeyCount | |
needSplit := len(ranges) > 1 || lf.TotalSize > local.regionSplitSize || lf.Length > regionMaxKeyCount |
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
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.
rest LGTM
lightning/backend/local.go
Outdated
@@ -1181,10 +1181,14 @@ func (local *local) ImportEngine(ctx context.Context, engineUUID uuid.UUID) erro | |||
log.L().Info("start import engine", zap.Stringer("uuid", engineUUID), | |||
zap.Int("ranges", len(ranges))) | |||
|
|||
// if all the kv can fit in one region, skip split regions. TiDB will split one region for | |||
// the table when table is created. | |||
needSplit := len(ranges) > 0 || lf.TotalSize > local.regionSplitSize || lf.Length > regionMaxKeyCount |
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.
I see. Now I suggest
needSplit := len(ranges) > 0 || lf.TotalSize > local.regionSplitSize || lf.Length > regionMaxKeyCount | |
needSplit := len(ranges) > 1 || lf.TotalSize > local.regionSplitSize || lf.Length > regionMaxKeyCount |
LGTM |
/merge |
/run-all-tests |
What problem does this PR solve?
Skip split regions there is only one range within the engine.
What is changed and how it works?
Check List
Tests
Side effects
Related changes