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

Change error handling logic in db.close() #400

Merged
merged 1 commit into from
Feb 10, 2023

Conversation

CaojiamingAlan
Copy link
Contributor

#382 (comment)
Complete all cleanup operations in db.close() even if there is an error in the middle. Otherwise fd remains open and flock is not released.

Add a test mocking the munmap syscall fails. This test fails before this commit.

db.go Outdated
@@ -649,9 +650,10 @@ func (db *DB) close() error {
// Clear ops.
db.ops.writeAt = nil

var errs []string
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var errs []string
var errs []error

I suggest to only return the first error if present. It is consistent with the existing behavior. We will add log in separate PR to record all errors.

Copy link
Member

Choose a reason for hiding this comment

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

Please resolve this comment: change the type to []error. It doesn't make sense to convert the errors to strings, and finally convert them back to errors.

@ahrtr
Copy link
Member

ahrtr commented Feb 5, 2023

Please signoff the commit:

$ git rebase HEAD~1 --signoff
$ git push origin release-lock-on-unmap-error -f

@ahrtr ahrtr modified the milestones: v1.4.0, v1.3.8 Feb 5, 2023
@CaojiamingAlan CaojiamingAlan force-pushed the release-lock-on-unmap-error branch 2 times, most recently from fa761d2 to dddc5fd Compare February 9, 2023 22:44
Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

LGTM

Thank you @CaojiamingAlan

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

Please resolve the workflow error.

…or in the middle

Signed-off-by: caojiamingalan <alan.c.19971111@gmail.com>
@CaojiamingAlan CaojiamingAlan force-pushed the release-lock-on-unmap-error branch from dddc5fd to ef81032 Compare February 10, 2023 15:22
Copy link
Contributor

@ptabor ptabor left a comment

Choose a reason for hiding this comment

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

Thank you. Looks good to me. Let's see whether the test passes.

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

Thanks again.

Could you backport this PR to release-1.3?

@ahrtr ahrtr merged commit 505fc0f into etcd-io:master Feb 10, 2023
@ahrtr ahrtr removed this from the v1.4.0 milestone Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants