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

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

Open
jpedrick opened this issue Mar 17, 2023 · 0 comments

Comments

@jpedrick
Copy link

jpedrick commented Mar 17, 2023

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.

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