LATX, fix: Publish lock-free AOT updates safely - #341
Draft
LaurenIsACoder wants to merge 8 commits into
Draft
Conversation
Replace file overwrites with atomic rename operations. Eliminate locks during AOT file reading. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Fix LATX AOT cache generation when temporary-file writes or publication fail. Write to an exclusive .tmp file, sync its contents, rename it over the final path, and sync the parent directory. Failure-injection coverage verifies that write and rename errors preserve the current final file. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Fix LATX lock-free readers invalidating a cache that a writer replaced concurrently. Take the writer lock and compare the opened and current inode before unlinking an invalid cache. The regression test covers both replaced and unchanged files. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Fix non-TU LATX AOT merges overwriting the final cache in place. Write the merged image to the same exclusive temporary path and let the outer publication step replace the final file atomically. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Fix LATX AOT builds where configuration headers expose bool with a different underlying type across translation units. Use int for the cross-file generation status while preserving boolean success semantics. The AOT-enabled non-TU affected objects compile with this declaration. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Add regression coverage for post-rename durability failures, legacy cache fragments, and stale temporary-file reclamation. The test runs only through the explicit LATX test configuration. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Publish a generated temporary file only when there is no prior cache or when the merge completed successfully. Preserve the current cache on load, validation, or merge failures. Remove deprecated A/B fragments under the writer lock, account stale .tmp files in cache reclamation, and report post-rename directory-sync failures without hiding the successful namespace update. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Allow LATX AOT caches with a deterministically invalid length or version trailer to recover under the writer lock. Keep the current file unchanged for transient open, seek, read, temporary-file, or merge failures. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.tmpfile, file sync, atomic rename, and parent-directory sync..tmpfiles in cache-capacity reclamation.Root cause
The lock-free reader change in #300 did not propagate write and merge failures through the publication path. Fixed-name temporary files also overlapped the legacy A/B cache-group convention, reader invalidation acted on a pathname that could already name a new inode, and the non-TU merge path still truncated the final file in place.
This draft supersedes #300 with the original change plus the publication, recovery, and concurrency fixes.
Validation
Validated on LoongArch host
l1atbdb6a3044dba8883c9cf5129817c9c6f7a0caf65:test-latx-aot-file-publish..tmpreclamation, and inode-safe invalidation.file_ctx.c,aot.c, andaot_merge.cobjects compile successfully.latx-x86_64build succeeds; 5/5 tests pass.latx-x86_64build succeeds; Meson reports 0 test targets.git diff --checkpasses. Per-commit checkpatch has no errors; the only warning is the generic MAINTAINERS prompt for the new test file, already covered by the existingtarget/i386/maintenance scope.