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

Implement read/write with file offset change #121

Closed
chenhao-ye opened this issue Dec 6, 2021 · 1 comment
Closed

Implement read/write with file offset change #121

chenhao-ye opened this issue Dec 6, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@chenhao-ye
Copy link
Collaborator

The tricky piece of read/write (in contrast to pread and pwrite) is, changing file offset would imply a serialization point while OCC will pick another serialization point. Such divergence could result in anomalies.

The easiest way to resolve it is to use a lock for file offset. A multithreaded program that has concurrent read/write on a file usually uses pread and pwrite instead.

A better solution is to fully exploit OCC: in BlkTable.update, a thread A acquires the current offset and the last offset-changing thread's tx tail. Then it performs its IO, commits, and leaves the tx tail it has seen (this is the serialization point). Another thread B that does IO concurrently should see A's offset changing and A does not finish (probably implemented as a ticket lock etc); B could proceed and when it is about to commit, it must ensure A has already committed and it must ensure its' commit is after A.

@chenhao-ye chenhao-ye added the bug Something isn't working label Dec 6, 2021
@chenhao-ye chenhao-ye self-assigned this Dec 28, 2021
@chenhao-ye
Copy link
Collaborator Author

Fixed in #143.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant