Re: Incorrect checksum in control file with pg_rewind test

Maksim.Melnikov <m.melnikov@postgrespro.ru>

From: "Maksim.Melnikov" <m.melnikov@postgrespro.ru>
To: pgsql-hackers@lists.postgresql.org
Date: 2025-11-07T15:19:39Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Try to handle torn reads of pg_control in frontend.

Hi,
just to clarify, it isn't pg_rewind related issue and can fire 
spontaneously.
I don't have any strong scenario how to reproduce it, tests sometimes 
fired on our local CI, but as you can see on thread [1],
where the same issue for frontends was discussed, it is very hard to 
reproduce and there wasn't scenario how to do it too.

Some dirty hacks to reproduce it was described here [2], and I've tried 
it on master branch:
First of all I applied patch 
0001-XXX-Dirty-hack-to-clobber-control-file-for-testing.patch from [2], 
then compile app with
-DEXEC_BACKEND and exec command in psql
do $$ begin loop perform pg_update_control_file(); end loop; end; $$;
Also I've run pgbench command
for run in {1..5000}; do pgbench -c50 -t100 -j6 -S postgres ; done
And eventually got error

2025-11-07 17:58:33.139 MSK [2472504] FATAL:  incorrect checksum in 
control file
2025-11-07 17:58:33.141 MSK [2472501] LOG:  could not receive data from 
client: Connection reset by peer
2025-11-07 17:58:33.143 MSK [2472505] LOG:  could not send data to 
client: Broken pipe
2025-11-07 17:58:33.143 MSK [2472505] FATAL:  connection to client lost

Best regards,
Maksim Melnikov

[1] 
https://www.postgresql.org/message-id/flat/20221123014224.xisi44byq3cf5psi%40awork3.anarazel.de
[2] 
https://www.postgresql.org/message-id/CA%2BhUKGK-BEe38aKNqHJDQ86LUW-CMwF5F9bo1JtJVg71FoDv_w%40mail.gmail.com
[3] 
https://www.postgresql.org/message-id/f59335a4-83ff-438a-a30e-7cf2200276b6%40postgrespro.ru