Skip to content

feat: scheduled reload of account definitions from storage#1024

Open
HarleyGilpin wants to merge 1 commit into
GregHib:mainfrom
HarleyGilpin:feat/Scheduled-Account-Definitions-Reload
Open

feat: scheduled reload of account definitions from storage#1024
HarleyGilpin wants to merge 1 commit into
GregHib:mainfrom
HarleyGilpin:feat/Scheduled-Account-Definitions-Reload

Conversation

@HarleyGilpin

Copy link
Copy Markdown
Contributor

Summary

Website password resets and imported accounts previously required a server restart because AccountDefinitions caches all account metadata (including password hashes) at startup and never refreshes.

  • Add AccountDefinitions.merge(): add/update only, mutates existing definitions and clans in place (preserves live Clan.members), skips online players and accounts with pending saves whose in-memory state may be newer than storage.
  • Add AccountDefinitionsReloader: loads names/clans on Dispatchers.IO, applies merge on the game thread; SupervisorJob so a failed reload does not cancel future ones.
  • Add AccountReload script: world timer driven by new setting storage.accounts.reloadMinutes (-1 default, disabled), reacts to ::reload settings.
  • Add ::reload accounts admin command for on-demand refresh.
  • FileStorage.names()/clans(): warn and skip corrupt save files instead of crashing, so a partially-written save cannot abort a reload.
  • Swap AccountDefinitions maps to ConcurrentHashMap as login threads read while the game thread merges.

Known limitation: a password reset for a currently online player is overwritten at logout; it converges on the next reload after they log out.

Tests successful

  • engine/src/test/kotlin/world/gregs/voidps/engine/data/definition/AccountDefinitionsTest.kt
  • engine/src/test/kotlin/world/gregs/voidps/engine/data/AccountDefinitionsReloaderTest.kt

Manual test

  • Successfully reloaded password for a test account via in-game 'reload accounts' command.

Website password resets and imported accounts previously required a
server restart because AccountDefinitions caches all account metadata
(including password hashes) at startup and never refreshes.

- Add AccountDefinitions.merge(): add/update only, mutates existing
  definitions and clans in place (preserves live Clan.members), skips
  online players and accounts with pending saves whose in-memory state
  may be newer than storage.
- Add AccountDefinitionsReloader: loads names/clans on Dispatchers.IO,
  applies merge on the game thread; SupervisorJob so a failed reload
  does not cancel future ones.
- Add AccountReload script: world timer driven by new setting
  storage.accounts.reloadMinutes (-1 default, disabled), reacts to
  ::reload settings.
- Add ::reload accounts admin command for on-demand refresh.
- FileStorage.names()/clans(): warn and skip corrupt save files instead
  of crashing, so a partially-written save cannot abort a reload.
- Swap AccountDefinitions maps to ConcurrentHashMap as login threads
  read while the game thread merges.

Known limitation: a password reset for a currently online player is
overwritten at logout; it converges on the next reload after they
log out.
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