Skip to content

Solve race condition in LocalPageStore causing PageCorruptedExceptions - #18752

Open
ELBouslama wants to merge 1 commit into
Alluxio:mainfrom
ELBouslama:fix/local-page-store-atomic-write-race-condition
Open

Solve race condition in LocalPageStore causing PageCorruptedExceptions#18752
ELBouslama wants to merge 1 commit into
Alluxio:mainfrom
ELBouslama:fix/local-page-store-atomic-write-race-condition

Conversation

@ELBouslama

@ELBouslama ELBouslama commented Jun 1, 2026

Copy link
Copy Markdown

What changes are proposed in this pull request?
This PR switches LocalPageStore.put() to an atomic write-then-rename approach. Instead of writing directly to the final cache file path, we now write to a temporary .tmp file, sync it to disk, and then atomically rename it into place.
This way, any concurrent reader will either see the old complete file or the new complete file — never a half-written one that triggers PageCorruptedException.
If anything goes wrong during the write, the temp file is cleaned up so we don't leave stale artifacts behind.

Why are the changes needed?
We've been hitting PageCorruptedException in production under concurrent read/write workloads. The root cause is straightforward: a reader can open a cache file while a writer is still flushing data to it, resulting in a truncated read.
The write-to-temp + atomic rename pattern is a well-established solution for this class of problem. It guarantees readers only ever observe fully-written pages, eliminating the race condition entirely.

Related to this issue on Trino.
trinodb/trino#25899

@alluxio-bot

Copy link
Copy Markdown
Contributor

Thank you for your pull request.
In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement (CLA).
It's all electronic and will take just a few minutes. Please download CLA form here, sign, and e-mail back to cla@alluxio.org

@alluxio-bot

Copy link
Copy Markdown
Contributor

Automated checks report:

  • PR title follows the conventions: FAIL
    • The title of the PR does not pass all the checks. Please fix the following issues:
      • First word must be capitalized
      • First word of title ("fix:") is not an imperative verb. Please use one of the valid words
  • Commits associated with Github account: FAIL
    • It looks like your commits can't be linked to a valid Github account.
      Your commits are made with the email ala.bouslama@adjoe.io, which does not allow your contribution to be tracked by Github.
      See this link for possible reasons this might be happening.
      To change the author email address that your most recent commit was made under, you can run:
      git -c user.name="Name" -c user.email="Email" commit --amend --reset-author
      See this answer for more details about how to change commit email addresses.
      Once the author email address has been updated, update the pull request by running:
      git push --force https://github.com/ELBouslama/alluxio.git fix/local-page-store-atomic-write-race-condition

Some checks failed. Please fix the reported issues and reply
alluxio-bot, check this please
to re-run checks.

@ELBouslama ELBouslama changed the title fix: solve race condition in LocalPageStore causing PageCorruptedExce… Fix: solve race condition in LocalPageStore causing PageCorruptedExce… Jun 1, 2026
@ELBouslama

Copy link
Copy Markdown
Author

alluxio-bot, check this please

@alluxio-bot

Copy link
Copy Markdown
Contributor

Automated checks report:

  • PR title follows the conventions: FAIL
    • The title of the PR does not pass all the checks. Please fix the following issues:
      • First word of title ("Fix:") is not an imperative verb. Please use one of the valid words
  • Commits associated with Github account: PASS

Some checks failed. Please fix the reported issues and reply
alluxio-bot, check this please
to re-run checks.

@ELBouslama ELBouslama changed the title Fix: solve race condition in LocalPageStore causing PageCorruptedExce… Solve race condition in LocalPageStore causing PageCorruptedExceptions Jun 1, 2026
@alluxio-bot

Copy link
Copy Markdown
Contributor

Automated checks report:

  • PR title follows the conventions: PASS
  • Commits associated with Github account: PASS

All checks passed!

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.

2 participants