A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Non-Repeatable Read Anomaly

College Depth 103 in the knowledge graph I know this Set as goal
1topic build on this
410prerequisites beneath it
See this on the map →
Isolation Level: READ COMMITTEDDirty Read Anomaly: Reading Uncommitted ChangesPhantom Read Anomaly: New Rows Appearing
concurrency anomalies isolation-problems

Core Idea

A non-repeatable read occurs when a transaction reads a row, another transaction modifies it, and the first transaction re-reads the same row and sees different data.

Explainer

You already understand that under READ COMMITTED isolation, a transaction only sees data that has been committed — no dirty reads. But READ COMMITTED makes a subtle promise that is weaker than many people assume: it guarantees a consistent snapshot *per statement*, not per transaction. Each SQL statement you execute within a transaction sees the latest committed data at the moment *that statement* begins. If another transaction commits a change between your first and second SELECT, your second SELECT sees the new value. This is the non-repeatable read anomaly.

Here is a concrete scenario. Suppose you are building a banking application, and transaction T1 needs to check an account balance twice during its work — first to verify the account has sufficient funds, and later to compute a transfer amount. T1 reads the balance and sees $1000. Meanwhile, transaction T2 withdraws $800 and commits. When T1 reads the balance again, it now sees $200. T1's logic assumed the balance was $1000 throughout, but the ground shifted beneath it. The read was not "repeatable" — the same query on the same row returned different results within the same transaction.

The anomaly is called "non-repeatable" because the original read cannot be repeated with the same result. This differs from a dirty read (which sees uncommitted data) and from a phantom read (which sees new rows appearing in a range query). A non-repeatable read involves a specific row that you already read, whose *value* changed because another committed transaction modified or deleted it. All three anomalies involve interference between concurrent transactions, but they target different aspects: dirty reads concern uncommitted writes, non-repeatable reads concern committed updates to existing rows, and phantoms concern committed inserts of new rows.

To prevent non-repeatable reads, you need the REPEATABLE READ isolation level or higher. Under REPEATABLE READ, each transaction sees a consistent snapshot taken at the start of the transaction (or at the start of the first statement, depending on the implementation). No matter how many times T1 reads that account balance within its transaction, it will always see the value as of its snapshot — T2's committed change is invisible until T1 commits or rolls back and starts a new transaction. The cost is reduced concurrency: in lock-based systems, shared read locks are held for the duration of the transaction rather than released after each statement, which increases the chance of blocking and deadlocks. In MVCC systems, the cost is more subtle — long-running transactions may force the database to retain old row versions longer, increasing storage overhead. The design decision is always the same tradeoff: stronger consistency guarantees versus higher concurrency and throughput.

Practice Questions 5 questions

Prerequisite Chain

Understanding ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsLogic Gates FundamentalsImplementing Boolean Functions with GatesKarnaugh Map SimplificationCombinational Circuit DesignFlip-Flops and LatchesBinary Counters: Design and AnalysisBinary ArithmeticFixed-Point Number RepresentationTwo's Complement RepresentationOverflow and Underflow DetectionBinary Adders: Half-Adders and Full-AddersFull Adder and Carry PropagationCarry Lookahead Adder DesignHalf Adder Circuit DesignMultiplication Circuit DesignSequential Circuit DesignRegisters and Register FilesInstruction Set Architecture (ISA)Kernel Architecture and OS StructureSystem Calls and User/Kernel ModeProcesses and the Process Control BlockProcess Creation: fork() and exec()Process Termination and Resource CleanupProcess States and State TransitionsThreads and ConcurrencyThe Critical Section Problem and Race ConditionsMutual Exclusion and LocksConcurrency Control in DatabasesIsolation Level: READ UNCOMMITTED (Dirty Reads)Dirty Read Anomaly: Reading Uncommitted ChangesNon-Repeatable Read Anomaly

Longest path: 104 steps · 410 total prerequisite topics

Prerequisites (2)

Leads To (1)