mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2399] [MERGED] Replace atomic-update deep-equality conflict check with cheap file-stamp guard #5583
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#5583
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2399
Author: @Romuromylus
Created: 6/6/2026
Status: ✅ Merged
Merged: 6/6/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/storage-cheap-conflict-guard📝 Commits (2)
49d9107Replace atomic-update deep-equality conflict check with cheap file-stamp guard33363e1Capture conflict-guard stamp under the load lock to close a TOCTOU window📊 Changes
1 file changed (+13 additions, -10 deletions)
View changed files
📝
src-tauri/crates/storage/src/lib.rs(+13 -10)📄 Description
Linked issue
Closes #2301
Why this change
update_collections_atomicallyran on every message create/edit/swipe. Its concurrent-modification guard cloned the entire globalmessages+message-swipescollections and deep-compared them by structuralserde_json::Valueequality (O(n) over the whole corpus) under the storage write lock — pure overhead that scales with chat history size.What changed
src-tauri/crates/storage/src/lib.rs: the guard now captures a cheapCollectionFileStamp(file length + mtime + content hash) per target collection at load and re-checks it at commit, instead of cloning and deep-comparing all rows. TheCollectionFileStamp/collection_file_stampprimitive already exists in the file and is used by the projected-list cache.flush_dirty_collections_locked()plus the atomic-update mutex mean targets are clean on disk and only an external/concurrent write changes a stamp, so thestorage_conflictcontract is preserved. Public method signature unchanged — callers (message_swipes.rs / chats.rs / entities.rs) untouched.Refactor impact
Primary owner: Rust storage
Impact areas reviewed:
src-tauri/crates/storage/src/lib.rs(update_collections_atomically)Boundary notes:
marinara-storagecrate; no mode-specific logic (shared infra). Per-chat sharding (issue's larger alternative) intentionally out of scope.Pressure points touched:
Validation
pnpm checkpasses before PR push/handoffManual verification notes
cargo test --manifest-path src-tauri/Cargo.toml -p marinara-storage— 45 passed, including all existing conflict/recovery tests (rejects_duplicate,rejects_reentrant_writes,reads_targets_without_recovery,reentrant_reads_do_not_recover,reads_and_replaces_multiple_collections). Local inline tests confirmed the cheap guard still rejects a genuine out-of-band modification (storage_conflict) and does not false-positive on a normal sequential write (kept local per repo convention).cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings— clean.Feature Discoverability
src/features/shell/discovery/Reason:
Docs and release impact
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.