-
Notifications
You must be signed in to change notification settings - Fork 35
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
fix: commit info data race #155
Conversation
@@ -1022,36 +1043,17 @@ func getLatestVersion(db dbm.DB) int64 { | |||
return latestVersion | |||
} | |||
|
|||
// Gets commitInfo from disk. | |||
func getCommitInfo(db dbm.DB, ver int64) (*types.CommitInfo, error) { |
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.
Made a method and moved up
948de1b
to
0b829c8
Compare
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!
|
||
if err := batch.Write(); err != nil { | ||
if err := batch.WriteSync(); err != nil { |
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 := batch.WriteSync(); err != nil { | |
// We use WriteSync to ensure this get written to disk ASAP. | |
if err := batch.WriteSync(); err != nil { |
rs.flushLastCommitInfo(newCommitInfo) | ||
} | ||
|
||
func (rs *Store) flushLastCommitInfo(cInfo *types.CommitInfo) { |
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.
// should be called with rs.mx.Lock() taken
func (rs *Store) flushLastCommitInfo(cInfo *types.CommitInfo) {
Context
Commit(...)
and read inQuery(...)
andLastCommitID()
rs.lastCommitInfo
WriteSync
when flushing metadata since we want it to be immediately written to disk to avoid losing itRisks