mysqldatabaseconcurrencydatabase-concurrency

How to achieve data concurrency on MySQL database's single user but multiple simultaneous login sessions?


I have a MySQL server's database on cloud say empdb. This server has only one user (who has all admin privileges) say empdb_admin with password

I created an application which logs in the database using this login and it can perform CRUD activities with ease.

Since my application is performing well, I install it on 50+ desktops.
As per my understanding, all 50 desktops will log in using only one user admin credentials (empdb_admin).

What will happen if all 50+ PC perform CRUD operations simultaneously? Will there be collision or loss of data?


Solution

  • You're asking about race conditions and these can occur in any system allowing concurrent access, regardless of what user accounts are provided.

    As to what your exposure is, it really depends on what kind of collisions you might have. Two people editing the same record can happen, but depending on how you code your updates that may or may not be a problem.

    You'll want to investigate a locking strategy and using transactions if you need to ensure consistent writes. The approach used depends entirely on the problems you're trying to solve.