Skip to content

Ensure atomic session persistence in FileStore using write-then-rename pattern#1016

Closed
sahvx655-wq wants to merge 1 commit into
apache:mainfrom
sahvx655-wq:filestore-atomic-save
Closed

Ensure atomic session persistence in FileStore using write-then-rename pattern#1016
sahvx655-wq wants to merge 1 commit into
apache:mainfrom
sahvx655-wq:filestore-atomic-save

Conversation

@sahvx655-wq

Copy link
Copy Markdown
Contributor

Updated FileStore.save(Session) to use an atomic write-then-rename pattern. Previously, session data was written directly to the final file, which could leave partially written or inconsistent session state if the process was interrupted during persistence. The new logic writes to a temporary .tmp file first and renames it only after a successful write, improving persistence reliability and reducing the risk of corruption.

@sahvx655-wq
sahvx655-wq force-pushed the filestore-atomic-save branch from 17af440 to 3a6104d Compare May 29, 2026 07:09

@markt-asf markt-asf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed changes no longer handle the (very likely) case that the destination file exists reliably.

@sahvx655-wq
sahvx655-wq force-pushed the filestore-atomic-save branch from 3a6104d to ecbe5b0 Compare June 11, 2026 05:53
@sahvx655-wq

Copy link
Copy Markdown
Contributor Author

I have updated the implementation to handle existing destination files more reliably and pushed the changes for review.

markt-asf added a commit that referenced this pull request Jun 17, 2026
@markt-asf

Copy link
Copy Markdown
Contributor

Thanks for the updated PR. I have applied it manually with a slightly modified try/finally structure as there were code paths (e.g. IOException during session write) where the temporary file would not have been deleted.

@markt-asf markt-asf closed this Jun 17, 2026
markt-asf added a commit that referenced this pull request Jun 17, 2026
markt-asf added a commit that referenced this pull request Jun 17, 2026
markt-asf added a commit that referenced this pull request Jun 17, 2026
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

Successfully merging this pull request may close these issues.

2 participants