Whether any individual tuple in the data files is visible or not depends
not only on the data itself, but also on the commit status of the
transactions that created it (and deleted it, if any). Replaying WAL
also updates the commit status of transactions, so if you're in the
middle of replaying WAL, you may be adding tuples to the data files, but
those tuples will not become visible until their commit records are also
updated.
You can stop replaying WAL at any point, and data will always be in a
consistent state. Some data tuples might be "from the future" and those
will not be visible, which is what makes it all consistent.
Hi,
so let's suppose that the WAL is:
LSN 10: start transaction 123
LSN 11: update tuple 100
checkpoint position here (not a record but just for understanding)
LSN 12: update tuple 100
LSN 13: update tuple 100
LSN 14: checkpoint record ( postion=11)
LSN 15: update tuple 100
and that the system crashes now, before ending to write all the transaction's recs to the WAL (other updates and commit record missing).
At the replay, starting from LSN 12, the entire page we had at LSN 11 is written to the disk, though carrying inconsistent data.
Then we can even replay up to the end of WAL but always getting inconsistent data.
BUT, you say, as the tuple is not commited in the WAL, only the old version of the tuple will be visible? Right?
Regards
Pupillo