There are InnoDB tables with user accounts that are on different shards. The task is to make an analogue of the transaction for transferring from one account to another. How I do: 1. I reduce one account 2. Then I increase the other 3. I compare them after the change. If it doesn't fit, I roll it back.
With such a scheme, a situation of “race” is likely on my site, if between requests to the database another request changes the account of one of the users.
How to avoid it? Keep all accounts on the same server in one database and use the built-in transaction mechanism? But such a scheme is not scalable in contrast to sharding.