-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
refactor(store): keep batch.Close
error handle logic consistance
#21812
refactor(store): keep batch.Close
error handle logic consistance
#21812
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe changes involve enhancements to error handling in two functions: Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
3f5689c
to
80dda92
Compare
store/v2/commitment/metadata.go
Outdated
@@ -158,8 +158,9 @@ func (m *MetadataStore) deleteRemovedStoreKeys(version uint64, removeStore func( | |||
|
|||
batch := m.kv.NewBatch() | |||
defer func() { | |||
if berr := batch.Close(); berr != nil { | |||
err = berr | |||
cErr := batch.Close() |
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.
these are functionally identical, why the change?
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 batch.Write()
returns error and batch.Close()
returns error too, the error returned by batch.Write
would be covered.
This change just keeps consistant with others: The error returned by batch.Close
should be returned when original err is 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.
We should errors.Join them then to not lose any 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.
@julienrbrt Hi sir, I have changed to use errors.Join
now, thanks for your review
f9ba1b8
to
3ce6972
Compare
23b0c20
to
92f0a4c
Compare
92f0a4c
to
09b74dd
Compare
batch.Close
error handle logic consistancebatch.Close
error handle logic consistance
Description
This PR includes two changes:
batch.Close()
infunc deleteRemovedStoreKeys
is different from others, which maybe lose the original error info. Let's keep them consistance.batch.Close()
is error infunc flushMetadata
Summary by CodeRabbit