← Lessons

quiz vs the machine

Gold1470

Databases

Transaction Id Wraparound

Why a finite transaction counter can threaten the whole database.

5 min read · core · beat Gold to climb

A Finite Counter

MVCC visibility compares transaction ids. In many engines these ids are 32 bit and increase forever, but a 32 bit space holds only about four billion values. Once it runs out, ids must wrap around and reuse old numbers.

The Danger of Reuse

Visibility is judged by whether one id is older than another. If ids wrap naively, a very old committed row could suddenly look like it was created in the future and become invisible. That would make committed data appear to vanish.

Freezing Old Rows

The fix is freezing. Background maintenance marks very old, still live row versions as frozen, meaning always visible regardless of the current id. Frozen rows no longer depend on id comparison, so wraparound is safe. If freezing falls behind, the engine forces protective maintenance and may refuse new writes to stay correct.

Key idea

A finite transaction id space can wrap and make old committed rows look future dated, so the engine freezes very old rows to mark them always visible and keep wraparound safe.

Check yourself

Answer to earn rating on the learn ladder.

1. Why is transaction id wraparound dangerous?

2. How does freezing prevent the problem?