Skip to content

Race condition on concurrent reads when first reader has not completed caching source file #73

@jpedrick

Description

@jpedrick

I identified a race condition when N multiple processes attempt to read the same file at the same time, for the first time.

P_1 -> catfs notices file is missing from cache, begins caching
P_2 ... P_N -> notices cached file is present
P_2 ... P_N -> while reading cached file, file is truncated because loading process from P1 is incomplete.

My solution was to wrap the fd's in a Arc<RwLock> and all of the downstream consequences.

Currently has the downside, that P_2 - P_N block for the entirety of the time it takes to cache the entire file. It should be possible to allow readers up to what has successfully cached.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions