Skip to content

LATX, fix: Publish lock-free AOT updates safely - #341

Draft
LaurenIsACoder wants to merge 8 commits into
lat-opensource:masterfrom
LaurenIsACoder:lauren/aot-atomic-publish
Draft

LATX, fix: Publish lock-free AOT updates safely#341
LaurenIsACoder wants to merge 8 commits into
lat-opensource:masterfrom
LaurenIsACoder:lauren/aot-atomic-publish

Conversation

@LaurenIsACoder

Copy link
Copy Markdown
Contributor

Summary

  • Publish generated and merged AOT caches through an exclusive .tmp file, file sync, atomic rename, and parent-directory sync.
  • Keep lock-free readers from deleting a concurrently replaced cache by comparing the opened inode under the writer lock.
  • Preserve the current cache on temporary-file, read, validation, or merge failures; replace only deterministically invalid base files.
  • Remove deprecated A/B fragments under the writer lock and include stale .tmp files in cache-capacity reclamation.
  • Build the focused publication regression test only when tests are explicitly enabled.

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 l1 at bdb6a3044dba8883c9cf5129817c9c6f7a0caf65:

  • Deterministic RED before the recovery helpers were present, followed by GREEN for test-latx-aot-file-publish.
  • Failure injection covers file-sync and rename failures, post-rename directory-sync failure, legacy A/B cleanup, stale .tmp reclamation, and inode-safe invalidation.
  • AOT-enabled non-TU configuration: file_ctx.c, aot.c, and aot_merge.c objects compile successfully.
  • Explicit test configuration: complete latx-x86_64 build succeeds; 5/5 tests pass.
  • Default product configuration: complete latx-x86_64 build succeeds; Meson reports 0 test targets.
  • git diff --check passes. Per-commit checkpatch has no errors; the only warning is the generic MAINTAINERS prompt for the new test file, already covered by the existing target/i386/ maintenance scope.

ganjue66da and others added 8 commits July 24, 2026 12:13
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>
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