Database Challenge: Simultaneous Update of the Same Value

in #data5 years ago

What happens if two separate users update the same database value at the same time? In the video, T-SQL: Simultaneous Updates For Identical Value, we look at this situation. We look at the situation with an example where we have two identical identifiers for values and the values are being set differently for the same identifier. This can be a huge challenge in managing database systems.

Some important questions that are discussed in the video we should consider:

  • What type of database systems are we maintaining? What is the purpose of this system?
  • How does the type of system affect how we architect our design?
  • What example do I use where we'd want to consider a "queue" based approach, even if the information is delayed for the customer?
As the example highlights, we may not want a customer to get the information as quickly as possible because there may be situations (and designs) where we have two customers that are doing something to the same underlying value which may affect the outcome for one of them which isn't known at the time thus giving the incorrect impression to one.

Automating ETL
For mastering data transformation from one form to another form, check out the highest-rated Automating ETL course on Udemy. For a coupon to the course, check out the trailer video on the channel SQL In Six Minutes.

This challenge reminds me of a story where I worked with a team who always wanted the latest information about a particular data flow. I understood their desire to have this information, but cautioned that constant monitoring of this would disrupt it. We worked to create a design that would add a low amount of overhead to monitoring, while still providing them with monitoring information to give them a confidence interval that the design was functioning as expected. Custom designs like this can be challenging, but they are imperative when we must balance both the customer's needs with what is the best design for the overall architecture.

The back-end doesn't matter for this challenge because even with NoSQL engines, we can face situations where we have a unique identifier (for instance, in MongoDB the _id field, if none is directly specified) that contains other fields that we want to update. We may architect a solution where we don't face this issue, but if our users can update a specific field by a unique identifier, this will be a challenge.

Are you looking for tech consultants that can assist with design and development? From building custom applications to working with existing infrastructure that's causing you trouble, we can get you connected to consultants who can assist. You can contact for assistance.

SQL In Six Minutes (YouTube) | SQL In Six Minutes (Odysee) | Automating ETL | T-SQL In 2 Hours | Consumer Guide To Digital Security

Sort:  

Here are a few tips on how to effectively handle concurrent updates:

  • Transactions are not supported by all database types. Although MyISAM is still supported, it is not MySQL's default database engine.
  • Due to circumstances beyond your control, transactions may not proceed. If this happens, you'll need to be ready to re-enter your application's BEGIN WORK code.
  • Otherwise, the first select can read data that other transactions have not yet committed (transactions aren't like mutexes in programming languages).
  • If there are concurrent ongoing SERIALIZABLE transactions, some databases will throw an error, and you will have to restart the transaction.
  • SELECT.. FOR UPDATE locks the rows retrieved by select until the end of the transaction in some databases.
    To deal with concurrent updates easier, you can use these helpful SQL Tools.

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.078
BTC 62081.79
ETH 1631.74
USDT 1.00
SBD 0.40