By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
World of SoftwareWorld of SoftwareWorld of Software
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Search
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
Reading: Database Transactions: Everything That Can Go Wrong When Using Them | HackerNoon
Share
Sign In
Notification Show More
Font ResizerAa
World of SoftwareWorld of Software
Font ResizerAa
  • Software
  • Mobile
  • Computing
  • Gadget
  • Gaming
  • Videos
Search
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Have an existing account? Sign In
Follow US
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
World of Software > Computing > Database Transactions: Everything That Can Go Wrong When Using Them | HackerNoon
Computing

Database Transactions: Everything That Can Go Wrong When Using Them | HackerNoon

News Room
Last updated: 2025/10/06 at 6:20 PM
News Room Published 6 October 2025
Share
SHARE

Note: This is an excerpt from an unedited version of my book MariaDB for Developers.


To this point, we have understood the concept of atomicity—either all operations succeed or none do. What can go wrong? It seems like we are covered. And we are. Until we introduce concurrency in our system. MariaDB is one of the most highly performant database systems and tries to parallelize processing to increase throughput.

Parallelizing means that MariaDB can execute transactions from different sessions at the same time by interleaving operations from different transactions instead of waiting for one to finish before starting the next. Each transaction has its own sequence of operations, but MariaDB executes them in overlapping order. Figure 8-2 shows two transactions (A and B) and multiple database operations interleaved through time.

This interleaving allows MariaDB to use CPU and I/O resources more efficiently than without parallelism. This, however, opens the door to subtle problems when the parallel transactions read and write overlapping data. Let’s study some of these problems known as concurrency phenomena.

Dirty Reads

Friday afternoon, and we’ve got a winner! Our to-do application—which by chapter 6 became more of a project management tool than a to-do app—is so central to the business that prizes are given to users who excelled at reporting bugs or helping its development. Our to-do application allows the HR team to grant prizes to users, and this use case involves reducing the quantity of the awarded prize in the prizes table.

Janet and Moe, both from HR, are using our to-do app at the same time. Janet is about to grant today’s prize (named “Bagelers” in our database), while Moe is viewing a dashboard that shows an overview of the prize inventory. Jane selects the winner and the prize, and clicks on “Grant prize.” Our to-do app starts a new transaction that decreases the quantity for Bagelers from 8 to 7.

At that moment, Moe refreshes the dashboard and sees that there are 7 Bagelers. However, the system crashes, and since the transaction was never committed, the new quantity is not written to disk. Jane gets an error, but Moe doesn’t. To him, there are 7 Bagelers. He is seeing incorrect data. This is called a dirty read. Figure 8-3 shows an example of the sequence of operations that lead to a dirty read at time t3.

Figure 8-3: Example of dirty read phenomena.

Non-Repeatable Reads

A similar situation can occur when a transaction reads a value twice, but such value is modified between the reads by another transaction. In this case, the second read would obtain a different value. This phenomenon is called a non-repeatable read and can lead to incorrect results if the values are used for other calculations in the same transaction. Figure 8-4 shows a non-repeatable read at time t5.

Figure 8-4: Example of non-repeatable read phenomena.

Phantom Reads

If the write operation in the previous example implies inserting rows, we get what’s called a phantom read phenomenon. Figure 8-5 shows a phantom read at time t5.

Figure 8-5: Example of phantom read phenomena.

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Twitter Email Print
Share
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article Supreme Court rejects Google’s request to block Play Store injunction
Next Article The judge tasked with deciding Google’s fate would rather not
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

248.1k Like
69.1k Follow
134k Pin
54.3k Follow

Latest News

Photos of October’s supermoon: A stunning start to a trio of celestial events
News
A Unified Model for Hot Jupiter Orbits? Evidence for Gas Disk Truncation Across Stellar Masses | HackerNoon
Computing
5 Windows 11 apps I uninstall for a cleaner, smoother experience
News
Firefly targets the defense industry after buying SciTec for $855M – News
News

You Might also Like

Computing

A Unified Model for Hot Jupiter Orbits? Evidence for Gas Disk Truncation Across Stellar Masses | HackerNoon

8 Min Read
Computing

Linux 6.18 NFSD To Help With Scalability From Low-Cost Clouds To High-End Servers

2 Min Read
Computing

Li Auto unveils futuristic Mega van starting at $77,756 · TechNode

1 Min Read
Computing

Are We on the Verge of a Breakthrough in Understanding Planet Formation? | HackerNoon

13 Min Read
//

World of Software is your one-stop website for the latest tech news and updates, follow us now to get the news that matters to you.

Quick Link

  • Privacy Policy
  • Terms of use
  • Advertise
  • Contact

Topics

  • Computing
  • Software
  • Press Release
  • Trending

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

World of SoftwareWorld of Software
Follow US
Copyright © All Rights Reserved. World of Software.
Welcome Back!

Sign in to your account

Lost your password?