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

fix for delete/open race #4768

Merged
merged 2 commits into from
Jun 21, 2021
Merged

fix for delete/open race #4768

merged 2 commits into from
Jun 21, 2021

Conversation

finnschiermer
Copy link
Contributor

@finnschiermer finnschiermer commented Jun 17, 2021

Proposed fix for #4762

A call to realm::delete_files concurrently with opening the same realm file had a race, where the management directory could be removed from under the feet of DB::do_open. This could happen both before do_open acquires the exclusive lock and after, right before acquiring a shared lock.

The fix moves creation/deletion of the management directory such that it is protected by the exclusive lock.

It is still possible (but a different problem) for realm::delete_files() to interfere with do_open() such that the lock file is not re-initialized. However, this is highly unlikely to have any impact, since it can only happen when cleaning up after previous use of the realm file, and in that case re-initialization of the lock file should not be needed, assuming that the cleanup occurs as part of an orderly shutdown.

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)

@finnschiermer finnschiermer marked this pull request as ready for review June 17, 2021 15:47
src/realm/db.cpp Outdated Show resolved Hide resolved
src/realm/util/file.cpp Outdated Show resolved Hide resolved
@finnschiermer finnschiermer merged commit b2d96fb into master Jun 21, 2021
@finnschiermer finnschiermer deleted the fsa/fix-delete-open-race branch June 21, 2021 13:09
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants