I will in no way offer a complete coverage of concurrency handling and all of its aspects. Typically solving the problem is divided into two basic approaches:īelow I will give a brief description of the two and the different options for handling them. Let’s first take a look at what others generally say and do about solving database concurrency issues.
#Sql balance lock update
However, that said, the same concurrency issue can occur between automated processes and it is harder to solve because in the case of an update by a human you can ask what the user wants (do they want to overwrite changes made by another user?) and respond to that while a process needs to have all actions fully automated. A concurrency issue is more likely to occur with human users as the read/update/write cycle is likely to take much longer. This kind of database concurrency issue can occur both with humans or automated processes or a combination of the two. Basically, whoever saves their changes second will win, overwriting the changes made by whoever saves first. Why? Because if user 1 writes his data back into the database he will overwrite the changes made by user 2, causing them to be lost. Now you have a concurrency control conflict because user 1 read the data before user 2 wrote it back to the database. User 1 will update the data and write those changes back to the database before user 2 does the same thing. There will be occasions where two users will both read the same data into memory. Because a typical update cycle consists of: Given that multiple persons/processes are updating data in a database, it is only a matter of time before two separate persons/processes will try to update the same piece of data. This means that, at any given point in time, you can expect multiple persons and/or processes reading from and writing to a database.
Most database applications in this world are multi-user applications. Let’s start with a quick recap of what database concurrency conflicts are and why you need to solve them in the first place.
#Sql balance lock how to
I will show some possible approaches on how to solve these concurrency issues. In this article, I will try to show the difference between focusing on the database implementation and on the real-world data. Unfortunately most of these articles, and accompanying solutions, have one major flaw in that they focus on the technical issues and database implementation instead of real-world data and how people use the data. A lot of articles have been written about database concurrency conflict detection and the various ways of handling them.