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 conditions #5

Closed
AndreasBackx opened this issue Jul 5, 2015 · 3 comments
Closed

Race conditions #5

AndreasBackx opened this issue Jul 5, 2015 · 3 comments

Comments

@AndreasBackx
Copy link

Paper looks very interesting, but I have some questions about how the file access works. It says random file access is rapid on flash storage. What happens if 2 async tasks read the file and write to the file making the first write to the file obsolete? The second write was based on the result before the first write when it probably should've been based on that after the first write. Does Paper handle these issues or do we have to make sure ourselves that that doesn't happen?

@pilgr
Copy link
Owner

pilgr commented Jul 5, 2015

Every file operation is synchronized by storage instance
https://github.com/pilgr/Paper/blob/master/paperdb/src/main/java/io/paperdb/DbStoragePlainFile.java#L112
Paper has only one storage instance. So all put/get/etc operations are synchronized.
In your example the thread which get access first will save data first. And second one rewrite old data after first one is done.

Doesn't matter you use Paper or any data storage, it should be your responsibility to write correct data in correct order. Paper just controls that more than one parallel write/read operations never happened.

@pilgr
Copy link
Owner

pilgr commented Jul 7, 2015

Do you think the issue is exist anyway? Or we can close the issue?

@AndreasBackx
Copy link
Author

We can, it was just a question wondering whether Paper handled it this way or not.

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

2 participants