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

(feat) Set segment file to be read-only after write and sync #409

Merged
merged 2 commits into from
Mar 30, 2020

Conversation

killme2008
Copy link
Contributor

Motivation:

Segment file may be swapped out(unmap) when writing, then the JVM may crash.The segment file is swapped out only when it's readonly. So we must make sure the segment file to be set readonly after all writing/fsync requests are finished.

So this PR adds finish hooks to WriteContext, all these hooks will be invoked after writing and fsync. It move currLastFile.setReadOnly(true) from write-executor to a finish hook, so we make sure that the segment file is set readonly only after all writing/fsync requests are finished.

@killme2008 killme2008 merged commit e565e16 into master Mar 30, 2020
@killme2008 killme2008 deleted the feature/fix-write-swapout-segments branch March 30, 2020 12:41
zongtanghu pushed a commit that referenced this pull request Apr 28, 2020
* (feat) Set segment file to be read-only after write and sync

* (feat) use CopyOnWriteArrayList for hooks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants