I'm writing a Web app with Play Framework and MariaDB. The user has a balance on his account that can be consumed with a request to the app. Today, when the user sends 2 requests to the app, there is no way to be sure that the second request will take the balance state from the first one. It makes de data inconsistent.
What's the "by default" way to deal with this? Using a lock column to update and read after/before each update of the balance? Having a lock mechanism built-in MariaDB? Rethinking the async requests?
Thanks for your advice.