-
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
stats: fix dump stats #6285
stats: fix dump stats #6285
Conversation
statistics/histogram.go
Outdated
var sql string | ||
sql = fmt.Sprintf("replace into mysql.stats_meta (version, table_id, count, modify_count) values (%d, %d, %d, %d)", version, tableID, count, modifyCount) | ||
if _, err = exec.Execute(ctx, sql); err != nil { | ||
return errors.Trace(err) |
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.
Maybe we should execute rollback
here.
executor/load_stats.go
Outdated
return nil | ||
Err: nil, | ||
} | ||
err = statistics.SaveMetaToStorage(e.Ctx, tbl.TableID, tbl.Count, tbl.ModifyCount, tbl.Version) |
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 think if err is nil, we should not trace it.
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.
If err is nil, the errors.Trace will return nil.
LGTM |
/run-all-tests |
@coocood @lamxTyler PTAL |
executor/load_stats.go
Outdated
@@ -143,6 +145,10 @@ func (e *LoadStatsInfo) Update(data []byte) error { | |||
return errors.Trace(err) | |||
} | |||
} | |||
err = statistics.SaveMetaToStorage(e.Ctx, tbl.TableID, tbl.Count, tbl.ModifyCount, tbl.Version) |
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.
Why save it twice?
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 don't save it twice. They are two situations, and it will return immediately after the previous call.
statistics/histogram.go
Outdated
return errors.Trace(err) | ||
} | ||
var sql string | ||
sql = fmt.Sprintf("replace into mysql.stats_meta (version, table_id, count, modify_count) values (%d, %d, %d, %d)", version, tableID, count, modifyCount) |
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.
We cannot use the original version, it may not be loaded into stats cache.
/run-all-tests |
/run-all-tests |
@@ -54,6 +54,8 @@ type Handle struct { | |||
feedback []*QueryFeedback | |||
|
|||
Lease time.Duration | |||
// loadMetaCh is a channel to notify a load stats operation has done. | |||
loadMetaCh chan *LoadMeta |
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 think that it is not initialized.
LGTM |
There are two problems in the current implementation of dumping/loading stats info:
This PR fixed these issues.
PTAL @lamxTyler @coocood