Part 2 of 5 · 1 min read
Dirty reads
Reading a value another transaction wrote but has not yet committed.
Think of reading a coworker's document over their shoulder while they are still typing, mid-sentence, before they have saved anything at all.
In plain words: a dirty read happens when one transaction reads a value that another transaction has written but not yet committed. If the writing transaction later aborts, the reading transaction has based its result on a value that was never actually committed, that effectively never existed. This is exactly the problem the cascadeless schedule property, covered on the previous page, exists to prevent.
A worked example. Transaction A updates a balance to $500 but has not committed; transaction B reads that $500 value; transaction A then rolls back, reverting to the original balance, leaving transaction B holding a value that was never real.
The key lines. No new SQL; a dirty read is a concurrency scenario, not something written directly, that the lowest isolation levels permit and higher ones prevent.
Dirty read
A dirty read is reading a value another transaction has written but not yet committed, risking that the value is later rolled back and was never actually real.
Example: reading a coworker's unsaved, mid-sentence document over their shoulder is a dirty read.