Shouldn't we write xlog record before we do a physical operation?
An test case:
1. set full_page_writes off;
2. startup database; create a table; insert 100000 rows in it; shutdown
database;
3. startup database again; delete all rows from this table;
4. vacuum this table, and it will come into smgrtruncate; kill postmaster
before smgrtruncate do xlog stuff(set a breakpoint before xlog stuff);
5. startup database the 3rd time, during the recovery, the database will
crash with:
PANIC: WAL contains references to invalid pages