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 there is no parallel file write by write_to_disk #233

Open
saschanaz opened this issue Jan 26, 2023 · 0 comments
Open

Make sure there is no parallel file write by write_to_disk #233

saschanaz opened this issue Jan 26, 2023 · 0 comments

Comments

@saschanaz
Copy link
Collaborator

More details here: https://bugzilla.mozilla.org/show_bug.cgi?id=1807010#c2

rkv's safe mode protects the in-memory database contents with an RwLock (

pub(crate) fn dbs_mut(&self) -> Result<RwLockWriteGuard<EnvironmentDbs>, ErrorImpl> {
self.dbs.write().map_err(|_| ErrorImpl::EnvPoisonError)
}
), but that lock is released in , before flushing the contents to disk. So, even if (2) weren't a factor, multiple calls to EnvironmentImpl.write_to_disk() from different task queues could still race with each other.

I wonder we can mitigate this issue by adding a separate lock solely for this write_to_disk() and wait for the lock for each write.

@saschanaz saschanaz changed the title Get a dedicated lock for write_to_disk()? Make sure there is no parallel file write by write_to_disk Jan 26, 2023
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

No branches or pull requests

1 participant