Repository navigation
Conversation
On quit, modules save and then forget player data asynchronously. A quick rejoin could load before the save had written (stale data), and the delayed forget could then drop the freshly loaded data. Logins now wait for that player's pending save.
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.
Fixes a race in
ModulePlayerDataLoaderbetween a player's quit and a quick rejoin.Problem
On quit,
saveAndForgetAllruns asynchronously: each module saves, then forgets the player's data. If the player rejoins before that finishes:loadAllonAsyncPlayerPreLoginEventcan read storage before the save has written, so the player gets stale data.forgetPlayerDatathen runs after the new load and removes the freshly loaded data, leaving an online player with none (e.g.basics-homeserrors withHomeList for <uuid> doesn't exist).This affects every module that uses the player data lifecycle (
basics-homes, and the newbasics-back/basics-godfrom #168 and #173).Fix
onPlayerQuitkeeps thesaveAndForgetAllfuture inpendingSavesuntil it completes. That future completes only after every module has both saved and forgotten.handle), so the login still loads.pendingSaves.remove(uuid, future)only removes that exact future, so an older save finishing can't drop a newer one.Joins without a recent quit are unchanged. The wait counts towards the existing
storage.ymljoin timeout, so a slow save can't hang a login.Testing
./gradlew :core:build(compile + ktlint + tests) passes on Java 17. Not exercised on a live server.