I would like to propose that we tweak the following error message: ERROR: unexpected data beyond EOF in block 1472 of relation base/5/16387 HINT: This has been seen to occur with buggy kernels; consider updating your system.
to something more generic and less confusing. It is coming from ffae5cc5a602 (2006), and we are probably not running those "buggy" kernels anywhere. I've seen this error multiple times, but it is usually due to some external influence overwriting/replacing the files in PGDATA and some (potentially new) backends open()ing those "new" files and finding unexpected file layout. In the real world this means usually: a. files being potentially accidentally replaced/overwritten, please see attached file for reproducer b. some obscure bugs (e.g. in EPAS - PG fork - we have on-demand automatic partition creation and we had bug/race conditions where multiple backends end up writing to the same relfilenode oid file) so how about: -HINT: This has been seen to occur with buggy kernels; consider updating your system. +HINT: This has been observed with files being overwritten, buggy kernels and potentially other external file system influence. ? -J.
postgres@postgres:1234 : 8182 # create table t as select i, repeat(md5(i::text), 100) as txt from generate_series(1 , 100000) i; SELECT 100000 postgres@postgres:1234 : 8182 # analyze t; ANALYZE postgres@postgres:1234 : 8182 # select relfilenode, oid from pg_class where relname = 't'; relfilenode | oid -------------+------- 16387 | 16387 (1 row) postgres@postgres:1234 : 8182 # select pg_relation_filepath('t'::regclass); pg_relation_filepath ---------------------- base/5/16387 (1 row) postgres@postgres:1234 : 8182 # \! find /tmp/pg18 -ls | grep 16387 1584697 8 -rw------- 1 postgres postgres 8192 Mar 25 15:44 /tmp/pg18/base/5/16387_vm 1590939 11780 -rw------- 1 postgres postgres 12058624 Mar 25 15:43 /tmp/pg18/base/5/16387 1590944 24 -rw------- 1 postgres postgres 24576 Mar 25 15:44 /tmp/pg18/base/5/16387_fsm postgres@postgres:1234 : 8182 # \! cp /tmp/pg18/base/5/16387* /tmp/ postgres@postgres:1234 : 8182 # insert into t select i, repeat(md5(i::text), 100) as txt from generate_series(500000, 600000) i; INSERT 0 100001 postgres@postgres:1234 : 8182 # \! mkdir /tmp/blah postgres@postgres:1234 : 8182 # \! mv /tmp/pg18/base/5/16387* /tmp/blah postgres@postgres:1234 : 8182 # \! cp /tmp/16387* /tmp/pg18/base/5/ postgres@postgres:1234 : 8182 # \! find /tmp/pg18 -ls | grep 16387 1591007 8 -rw------- 1 postgres postgres 8192 Mar 25 15:45 /tmp/pg18/base/5/16387_vm 1590947 11776 -rw------- 1 postgres postgres 12058624 Mar 25 15:45 /tmp/pg18/base/5/16387 1590948 24 -rw------- 1 postgres postgres 24576 Mar 25 15:45 /tmp/pg18/base/5/16387_fsm postgres@postgres:1234 : 8182 # select count(*) from t; count -------- 200001 (1 row) postgres@postgres:1234 : 8182 # \q postgres@hive:~$ psql -p 1234 -h /tmp psql (17.2 (Debian 17.2-1.pgdg110+1), server 18devel) WARNING: psql major version 17, server major version 18. Some psql features might not work. Type "help" for help. postgres@postgres:1234 : 8248 # select count(*) from t; count -------- 103040 (1 row) postgres@postgres:1234 : 8248 # vacuum t; VACUUM postgres@postgres:1234 : 8248 # insert into t select i, repeat(md5(i::text), 100) as txt from generate_series(700000, 800000) i; ERROR: unexpected data beyond EOF in block 1472 of relation base/5/16387 HINT: This has been seen to occur with buggy kernels; consider updating your system.