Skip to content

fix(datastore): Don't reopen a player's datastore after they leave - #869

Open
oiisin wants to merge 3 commits into
Quenty:mainfrom
oiisin:users/oiisin/datastore-no-reopen-after-leave
Open

oiisin wants to merge 3 commits into
Quenty:mainfrom
oiisin:users/oiisin/datastore-no-reopen-after-leave

Conversation

@oiisin

@oiisin oiisin commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

When something calls PromiseDataStore(player) while that player's data is being removed (they left, were kicked, or the server is closing), PlayerDataStoreManager warned Called GetDataStore while player is removing, waited for the save, and then created a new DataStore for a player who was gone. That's an extra load per leave, and the new store takes the session lock, which this server holds until another server asks for it (and at shutdown it outlives the server, so the player's next join waits on the lock retries).

  • Players are marked (per manager, weakly) when they leave, are kicked by a session-lock failure, stolen session or close request, or the server closes. After the removal, a request made with a marked Player, or one no longer under Players, is cancelled with an empty rejection, which isn't reported as uncaught.
  • GetDataStore isn't called while a removal runs, so the warning no longer fires for requests that wait.
  • Unchanged: a rejoin (a new Player), requests by userId (handles, tools), and RemovePlayerDataStore on a player who stays, which all still wait and reopen.

Tests cover the reset case, a player who left during the removal, and a userId request after a leave. The same change runs in a live game, checked with a two-player local server and a live log.

PromiseDataStore for a player being removed waited for the removal and
then created a new DataStore for them. A call made during a leave, kick
or shutdown therefore loaded and session locked a departed player's
data on this server, warned "Called GetDataStore while player is
removing", and kept the lock until another server asked for it.

Players are now marked when they leave, are kicked or the server
closes, and requests made with that Player are cancelled once the
removal finishes. A rejoin (a new Player), requests by userId and
RemovePlayerDataStore on a player who stays still reopen as before.
@oiisin
oiisin deployed to integration November 24, 2026 08:41 — with GitHub Actions Active
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Test Results

Package Status Error Try it
@quenty/datastore ❌ FAILED (396/397) (19.9s) [NevermoreTestRunner] 1 test(s) failed, 1 test suite(s) failed; 1 test suite(... Open | Play
@quenty/chatproviderservice ✅ Passed (9/9) (2.0s) Open | Play
@quenty/saveslot ❌ FAILED (143/249) (4.5s) [NevermoreTestRunner] 106 test(s) failed, 7 test suite(s) failed; 7 test suit... Open | Play
@quenty/secrets ✅ Passed (2/2) (1.7s) Open | Play
@quenty/settings ✅ Passed (14/14) (1.9s) Open | Play
@quenty/settings-inputkeymap ✅ Passed (1/1) (1.9s) Open | Play

6 packages tested, 4 passed, 2 failed in 38.8s · View logs

Deploy Results

ℹ️ No changed packages with deploy targets were discovered for this PR. · View logs

…emoval finished

A request that arrived just after the leave's save finished skipped the
wait and opened a new datastore for the player anyway.
@oiisin
oiisin deployed to integration November 25, 2026 16:52 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
integration — 2c15b251 Deployed Nov 25, 2026 by oiisin via integration-build #849
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.

1 participant