Skip to content

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

@saschanaz

Description

@saschanaz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions