Hi Kyotaro,

> I took a bit too long detour but the patch gets to pass make-world for me.

Good news, v10 passes all the tests for me (including TAP recover ones). 
There's major problem I think:

drop table t6;
create unlogged table t6 (id bigint, t text);
create sequence s1;
insert into t6 select nextval('s1'), repeat('A', 1000) from generate_series(1, 
100);
alter table t6 set logged;
select pg_sleep(1);
<--optional checkpoint, more on this later.
/usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data -l logfile -m immediate stop
/usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data -l logfile start
select count(*) from t6; -- shows 0 rows

But If I perform checkpoint before crash, data is there..  apparently the 
missing steps done by checkpointer 
seem to help. If checkpoint is not done, then some peeking reveals that upon 
startup there is truncation (?!):

$ /usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data -l logfile -m immediate 
stop
$ find /var/lib/pgsql/15/data/ -name '73741*' -ls
112723206  120 -rw-------   1 postgres postgres   122880 Dec 21 12:42 
/var/lib/pgsql/15/data/base/73740/73741
112723202   24 -rw-------   1 postgres postgres    24576 Dec 21 12:42 
/var/lib/pgsql/15/data/base/73740/73741_fsm
$ /usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data -l logfile start
waiting for server to start.... done
server started
$ find /var/lib/pgsql/15/data/ -name '73741*' -ls
112723206    0 -rw-------   1 postgres postgres        0 Dec 21 12:42 
/var/lib/pgsql/15/data/base/73740/73741
112723202   16 -rw-------   1 postgres postgres    16384 Dec 21 12:42 
/var/lib/pgsql/15/data/base/73740/73741_fsm

So what's suspicious is that 122880 -> 0 file size truncation. I've 
investigated WAL and it seems to contain TRUNCATE records
after logged FPI images, so when the crash recovery would kick in it probably 
clears this table (while it shouldn't).

However if I perform CHECKPOINT just before crash the WAL stream contains just 
RUNNING_XACTS and CHECKPOINT_ONLINE 
redo records, this probably prevents truncating. I'm newbie here so please take 
this theory with grain of salt, it can be 
something completely different.

-J.



Reply via email to