MVCC Under the Hood — Row Versions, Visibility, the Version Chain left: the classes · right: a live object graph for “account 2” across transactions 12 and 13 RowVersion inserted_by : TxID deleted_by : TxID? payload : row data next_older : RowVersion? next_newer : RowVersion? Transaction txid : int (always increasing) state : active | committed | aborted snapshot: set of active txids IndexEntry key : indexed value points_to : one RowVersion 1 0..* writes / marks finds the visible version by walking the chain next_older / next_newer Object diagram — versions of “account 2” v3 : RowVersion balance = 400 inserted_by = 13 invisible to tx 12 v2 : RowVersion balance = 500 inserted_by = 11 deleted_by = 13 visible to tx 12 “deleted” only means marked by tx 13 v1 : RowVersion balance = 500 inserted_by = 11 deleted_by = 13 older history — kept until no snapshot needs it next_older next_older Visibility rules (why tx 12 sees v2) 1. ignore writes of transactions still active at snapshot start 2. ignore writes of any later txid · 3. ignore aborted writes 4. everything else is visible — update is never an overwrite