feat(server): keep an entity on disk while it crosses regions #27
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
scope/assets
scope/client
scope/networking
scope/renderer
scope/scripting
scope/server
scope/shared
scope/workspace
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Synvael/synvael!27
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/entity-region-migration"
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?
What does this PR do?
I changed
EntityStoreincrates/server/src/entity_store.rsso an entity that moves between chunks is never absent from disk, including when the two chunks live in different region files.EntityStore::held_backandEntityStore::droppabledecide this, using a new per-entityHome(chunk, save stamp, whether the write succeeded).EntityStore::next_stamp, which is strictly increasing within a run even if the wall clock stalls or steps back.EntityStore::spawnresolves an id that is already live, or that a newer stored copy elsewhere holds, by save stamp. The greatersaved_unix_mswins, and on a tie the live copy stays. Players count as the newest.I added 10 tests in
crates/server/src/tests/entity_store.rscovering the write order, a source-first write losing the entity, flush counts, failed destination writes and merges, duplicate resolution, and stale entries in unloaded chunks.docs/save_format.mddescribes the write order, the duplicate resolution and the known limits below.Why is this change necessary?
Before this, a record dropped an entity as soon as the entity stood in another chunk. If the source region reached disk and the destination had not, a crash or a failed write in between lost the entity. Across two region files there is no single write that covers both, so the order has to be destination first, flush, then source. A side effect of that order is that a crash between the two flushes can leave the entity in both records, so loading now has to resolve duplicates by id and save stamp.
Scope of Changes
server, workspace
Testing
Automated, run from the branch worktree on Windows. There is no
ninjahere, so workspace-wide cargo commands excluderendererandclient(they fail onshaderc-sys):cargo check -p server: passes.cargo test -p server: 119 passed, 0 failed. Under parallel load,save::level_file::tests::a_block_the_base_game_does_not_register_stays_an_orphanoccasionally fails its log-capture assert (about 1 run in 20 to 30); it predates this branch, which does not touch it, and passes 20 of 20 alone.cargo clippy --workspace --exclude renderer --exclude client --all-targets --all-features -- -D warnings: clean.cargo fmt --all -- --check: clean.No Lua changed, so
seleneandstyluawere not run.Manual: none. I did not run the server and move entities across regions in game.
Additional Context
Stacks on #24 (feat/entity-chunk-lifecycle); review that one first.
This branch is stacked on
feat/entity-chunk-lifecycle, which is not merged yet. The diff against that branch is 10 commits touchingentity_store.rs, its tests anddocs/save_format.md. Until that branch lands, the diff againstdevalso contains its commits. No save format version changes.Known limits. The store resolves duplicates only from what it has seen in the current run, so four cases stay unresolved. They are documented in
docs/save_format.mdand in theEntityStore::spawnrustdoc:Fixing these needs persisted deletions and a stamp floor that survives restarts, or a reconciliation scan at startup. That is left for a later change to crash recovery.
Related Issues
None.
Checklist
dev(or a feature branch offdev) and my PR targetsdev.///doc comments for Rust) where necessary.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.