Since readers do not block writers and writers do not block readers is what MVCC is all about, how does postgresql prevent writers who are in the process of committing their changes to blocks/pages prevent a reader from reading this inconsistent data?
So from what I understand about PostgreSQL's MVCC, each table is represented as a heap file and each heap file contains a collection of pages / blocks which are 8 kb segments of information.
So say two transaction
T2 concurrently running and
T1 decides to make some modification to
block1. So at first,
block1 and makes modifications to it in-memory and when it's finally done, it decides to commit; ie actually write back these in-memory changes to
block1. So I understand that
xmax of the previous entries it modified are set to
id(T1) and a new entry is created with
xmin set to
id(T1). Now what I find difficult is, say while the actual commit process occurs for
T2 reads (while the write by
T1 has started but not ended). How is this case handled?
Any answer would be appreciated