Database Kernel (5): Transactions, Timestamps and GC
Multiple versions make concurrent reads and writes possible, but versions aren’t free: who creates them, who can see them, and when they can be dropped all need explicit answers. Part five of the plan series. 1. TxnMgr holds very little TxnMgr{ currentStartTs uint64 // starts at 2, +1 per txn, < 2^62 currentTxnId uint64 // starts at 2^62, +1 per txn lowestActiveId uint64 lowestActiveStart uint64 activeTxns []Txn // created, not committed/rolled back committedTxns []Txn // committed, not GC'd oldTxns []Txn // GC-able, not GC'd } The two counters start in different ranges so timestamps and transaction ids never collide: ...