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

make sure temp file(s) are closed during defrag #18841

Closed
4 tasks done
ghouscht opened this issue Nov 6, 2024 · 3 comments
Closed
4 tasks done

make sure temp file(s) are closed during defrag #18841

ghouscht opened this issue Nov 6, 2024 · 3 comments
Assignees
Labels

Comments

@ghouscht
Copy link
Contributor

ghouscht commented Nov 6, 2024

Bug report criteria

What happened?

Some temp file(s) (

temp, err := os.CreateTemp(dir, "db.tmp.*")
) might not be closed during defrag. See discussion #18822 (comment) for more details.

@ghouscht
Copy link
Contributor Author

ghouscht commented Nov 6, 2024

/assign

Will take care of this.

@ghouscht
Copy link
Contributor Author

ghouscht commented Nov 6, 2024

Apparently if everything works as expected the temp file is closed:

  • tmpdb.Close (*bbolt.DB) is called here:
    err = tmpdb.Close()
    (which also closes the file descriptor of the db file)
  • because of
    options.OpenFile = func(_ string, _ int, _ os.FileMode) (file *os.File, err error) {
    return temp, nil
    }
    the temporary file isn't opened again, so calling tmpdb.Close also closes the temp file descriptor

Probably in one of the error cases this doesn't happen. Need to check.

@ghouscht
Copy link
Contributor Author

This is done. All PRs, including the ones for the backports to 3.4 and 3.5 have been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant