Skip to content
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

feat: speed up rollback command #620

Closed
wants to merge 15 commits into from
Closed

feat: speed up rollback command #620

wants to merge 15 commits into from

Conversation

mmsqe
Copy link
Contributor

@mmsqe mmsqe commented Nov 14, 2022

@mmsqe mmsqe changed the title speed up rollback command feat: speed up rollback command Nov 16, 2022
@mmsqe mmsqe marked this pull request as ready for review November 16, 2022 14:33
@mmsqe mmsqe requested a review from a team as a code owner November 16, 2022 14:33
Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few comments.

if !fastMode {
latestVersion, err = tree.LoadVersion(targetVersion)
} else {
latestVersion, err = tree.LazyLoadVersion(targetVersion)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a param name clash:

  • seams that we want to use fastMode when we don't want to use fastCache
  • so let's rename fastMode parameter to something different, eg lazy bool or noFastCache bool.

Copy link
Contributor Author

@mmsqe mmsqe Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this flag is mainly related with rollback, should we rename to FastRollback or OfflineRollback.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but in the DeleteVersionsFrom it's related to the fast cache

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, then OfflineRollback might better since assumption is based on offline and re-index on restart.

mutable_tree.go Outdated
return tree.LoadVersionForOverwritingWithMode(targetVersion, false)
}

func (tree *MutableTree) LoadVersionForOverwritingWithMode(targetVersion int64, fastMode bool) (int64, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a doc string explaining the new parameter.

nodedb.go Outdated
@@ -420,7 +420,7 @@ func (ndb *nodeDB) DeleteVersion(version int64, checkLatestVersion bool) error {
}

// DeleteVersionsFrom permanently deletes all tree versions from the given version upwards.
func (ndb *nodeDB) DeleteVersionsFrom(version int64) error {
func (ndb *nodeDB) DeleteVersionsFrom(version int64, fastMode bool) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto, also update doc string

nodedb.go Outdated
})

return nil
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inner function is the same in both cases. Let's avoid copy-paste.

nodedb.go Outdated
return nil
})
} else {
err = ndb.traverseOrphansVersion(version-1, func(key, hash []byte) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we change a version here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since toVersion in orphan records is current version-1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, let's add a comment in the code.

Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-approving. let's finalize the naming

if !fastMode {
latestVersion, err = tree.LoadVersion(targetVersion)
} else {
latestVersion, err = tree.LazyLoadVersion(targetVersion)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but in the DeleteVersionsFrom it's related to the fast cache

@yihuang
Copy link
Collaborator

yihuang commented Nov 30, 2022

I did a cleaner version: #636

if err := tree.enableFastStorageAndCommitLocked(); err != nil {
return latestVersion, err
}
} else if err = tree.ndb.Commit(); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yihuang seems we still need commit if skipFastStorageUpgrade?

Copy link
Collaborator

@yihuang yihuang Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, so it don't commit previously?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, I wonder if need fix as a separate bug

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, the current rollback cmd maybe don't work at all if the fast node is disabled 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing this PR, let's limit the options.

@mmsqe mmsqe closed this Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants