#[sql] read directly after write but from different server reliably

1 messages · Page 1 of 1 (latest)

fresh otter
#

For switching between lobby servers im saving player location on quit to a mariadb server. On join, i then read the saved data. that way the location is the same even after switching.
However when the player switches servers, the data has not yet been written to the database when the player is too fast. im using hikaricp for database access

i thought about using a lock mechanism that stalls the server join until the server made sure to read the latest changes of the database, but then id need to lock the session faster than the player can switch.
Or i could lock by default and only let new players(players that didnt switch lobby, but just joined) join until I received some "sync data written" message in rabbitmq. But then what if the player quits and joins rlly fast?

brisk light
#

You should look into distributed locks

#

With redisson in specific there are really nice implementations

fresh otter
#

chatgpt said i could also lock the database row using sql

brisk light
#

you'd still have latency against you

#

And it's always a problem

fresh otter
#

oh right