A discussion of the inherent issues in managing concurrent accesses to a transactional database and the type of mechanisms which a RDBMS might use in defence of data integrity and to resolve potential deadlocks.
General Info
Concurrent access is something that all databases and dbas need to deal with daily. This is the case for internal databases but also the case for bases that deal with external users like the booking system mentioned in the question. Maintain data integrity is the primary goal of a database is slightly out of date, data is better than inaccurate data.
Concurrent access is when two transactions are trying to accrue at the same time on a database. For example, two people booking the same year or downloading the same file at the same time.
Mechanism 1
The first mechanism an RDBMS (relational database management system) is the locking of the database. This can mean both users are locked out of the system but often it is the second user trying to access that gets locked out. This is most likely to happen when someone is trying to buy a unique product.
The most common examples of this are the buying of a ticket for public transport, for a live musical/sporting event. Because there is a limited number of seats, priority needs to be given to users already taking part in the system. If someone is buying a ticket to sit in seat 27b at Old Trafford, for a select set of time, that seat will be locked for that user so that they can complete their purchase. During this set time the seat will appear already taken to any other users on the site. If the original user/customer decides not to make the purchase or their time elapses, the seat will become available again for selection.
The second user is effective locked out of buying that particular seat. Concurrency always gives the priority to the first user which is determined by online timestamps. It follows the principle that consistent data is more important than the most up to date info as mentioned above. So in the off chance that two users select a seat at the exact same moment, they will both be locked out of the system and both purchases will be cancelled. In this case, the seat might become available again for someone else to buy.
Mechanism 2
Another mechanism that could be done by a company like Ticketmaster is to limit the number of people who can access a database once. For example, only 1000 people can buy tickets of any seat at once, but once a user goes off the system another one can get on. Similar to how supermarkets are currently only allowing a certain amount f people in-the store at once. A reason why this might be done to keep the website up and running. This was especially a problem in the past when servers had their limits and it was very expensive to scale anymore. This is not so much of an issue in recent times due to the rise of cloud computing and services such as AWS and Google Cloud meaning databases are easily scalable.
Summary
In summary, this answered looked at 2 mechanisms that RDBMS have to solve deadlocks and maintain data integrity while usually practical examples when possible.
Comments
Post a Comment