I was wondering how to handle money in a SQL database to maintain consistency. I presume the tables would look something like below.
Consider the following scenario: if two players are playing then the money they wagered has been deducted from both of their balance_usd
and added to pot_usd
. But suppose the server goes down in the middle of the hand. Consistency of the database here presumably would mean that the money in pot_usd
should be returned to the two players balance_usd
effectively canceling the hand. It doesn't seem that transactions alone can solve this problem. How should the backend of a poker server be architected to handle this?
table user
user_id
balance_usd
table game
game_id
pot_usd
...