-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Lightning: optimize the estimated size #41943
Conversation
[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. |
/check-issue-triage-complete |
br/pkg/lightning/restore/restore.go
Outdated
@@ -115,7 +115,8 @@ const ( | |||
status VARCHAR(32) NOT NULL, | |||
state TINYINT(1) NOT NULL DEFAULT 0 COMMENT '0: normal, 1: exited before finish', | |||
source_bytes BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, | |||
cluster_avail BIGINT(20) UNSIGNED NOT NULL DEFAULT 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.
For existing clutters,this table has already been created, and the table will only be created if the table doesn't exist. This means the table schema will remain the old one without those two new fields for those existing clusters.
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.
Lightning is once-only used. It is fine?
@@ -561,6 +561,10 @@ func (p *PreRestoreInfoGetterImpl) EstimateSourceDataSize(ctx context.Context, o | |||
} | |||
} | |||
|
|||
if !isTiDBBackend(p.cfg) { | |||
sizeWithIndex = sizeWithIndex / 3 |
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.
Can you add a comment here describing why size should be divided by 3 ?
@@ -153,13 +162,23 @@ func (ci *clusterResourceCheckItem) Check(ctx context.Context) (*CheckResult, er | |||
return nil, errors.Trace(err) | |||
} | |||
estimateSize := clusterSource * replicaCount |
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.
Here, the estimated size is multiplied by the number of replicas. However, you have divided the available size of the entire cluster into TiKV size and TiFlash size. There may be false alarms. For example, suppose there's only one TiFlash node in a cluster, and it is sufficient to store one replica. However, the check indicates that this node is not large enough to store multiple replicas. In this situation, the check should pass IMO.
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.
@@ -54,6 +54,9 @@ import ( | |||
"golang.org/x/exp/maps" | |||
) | |||
|
|||
// compressionRatio is the tikv/tiflash's compression ratio | |||
const compressionRatio = float64(1) / 3 |
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.
After asked tiflash member, the size in tikv is similar with tiflash for one replica
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.
} else { | ||
// if sample data failed due to max-error, fallback to use source size | ||
sizeWithIndex += tbl.TotalSize | ||
tableSize = int64(float64(tbl.TotalSize) * tbl.IndexRatio) |
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.
Can we remove the if tbl.IndexRatio > 0
? It seems tbl.IndexRatio
can not be zero.
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.
It is removed in 931f006
estimateSize := clusterSource * replicaCount | ||
if estimateSize > clusterAvail { | ||
estimateTikvSize := tikvSourceSize * replicaCount | ||
// note: tiflashSourceSize contains replicaCount |
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.
Can we also let tikvSourceSize
contains replicaCount
?
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 can 931f006
@@ -99,6 +99,10 @@ func (s *tableRestoreSuiteBase) setupSuite(t *testing.T) { | |||
core, err := ddl.MockTableInfo(se, node.(*ast.CreateTableStmt), 0xabcdef) | |||
require.NoError(t, err) | |||
core.State = model.StatePublic | |||
core.TiFlashReplica = &model.TiFlashReplicaInfo{ |
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.
Please add a test case for multiple tables with different tiflash replicas.
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.
added in 931f006
7c637cf
to
931f006
Compare
ptal again~ @dsdashun @gozssky |
@yabola: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
; branch 'master' of https://github.com/pingcap/tidb into optimize-estimate-size
@okJiang Did you do any tests on real clusters? |
Yes, but more detailed testing is underway.
|
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 309a05d
|
What problem does this PR solve?
Issue Number: close #41942
Problem Summary:
What is changed and how it works?
The compression ratio for TiKV is typically around 3 to 1.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.