问题
I have been going around the crash recovery mechanism in Postgresql and this hit me. In WAL logging, At the transaction START, based on the queries, WAL Buffers are filled with XLOG records. At transaction COMMIT, the WAL buffer gets flushed. Now, Assume that i start a transaction with series of inserts. When the existing WAL segments gets filled, it creates new ones. But what happens, when i do bulk insert or copy heavy data or something (say 4-5GB), and the WAL Buffer(1-2GB) gets filled before the transaction commits? In this case, what happens to the WAL?
回答1:
When the WAL buffers are full, they are flushed to disk. There is nothing that says that WAL buffers can only be flushed when a transaction commits. What is important is that all WAL records pertaining to a transaction are flushed before a transaction is reported as committed (assuming synchronous commit). But the reverse is not true: A WAL record can be flushed before a transaction is committed.
来源:https://stackoverflow.com/questions/39879754/wal-buffers-fills-before-the-transaction-commits