(unnamed)
text/html
Filename: (unnamed)
Type: text/html
Part: 0
<div>On second run I got bug</div><div> </div><div> </div><div>08.08.2024, 14:30, "Heikki Linnakangas" <<a href="mailto:hlinnaka@iki.fi" rel="noopener noreferrer">hlinnaka@iki.fi</a>>:</div><blockquote><p>On 08/08/2024 10:57, Georgy Shelkovy wrote:</p><blockquote> Unfortunately, the playback is not very stable, but sometimes it shoots.<br /> I added some commands to show last WAL rows</blockquote><p><br />Thanks. I still haven't been able to reproduce it, but here's a theory:<br /><br />When determining whether the target needs rewinding, pg_rewind looks at<br />the target's last checkpoint record, or if it's a standby, its<br />minRecoveryPoint. It's possible that standby2's minRecoveryPoint is<br />indeed before the point of divergence. That means it has replayed the<br />340 insert records, but all the changes are still only sitting in the<br />shared buffer cache. When you shut it down, those 340 inserts are gone<br />on standby2. When you restart it, they will be applied again from the WAL.<br /><br />In that case, pg_rewind's conclusion that no rewind is needed is<br />correct. standby2 is strictly behind standby1, and could catch up<br />directly to it. However, when you restart standby2, it will first replay<br />the WAL it had streamed from master.<br /><br />Can you show the full output of pg_controldata on all the servers,<br />please? In your latest snippet, you showed just the checkpoint<br />locations, but if just remove the "grep checkpoint | grep location"<br />filters, it would print the whole thing. I'm particularly interested in<br />the minRecoveryPoint on standby2, in the cases when it works and when it<br />doesn't.<br /><br />I'm not sure what the right behavior would be if that's the issue.<br />Perhaps pg_rewind should truncate the WAL in standby2/pg_wal/ in that<br />case, so that when you start it up again, it would not replay the local<br />WAL but would connect to standby2 directly. Also, perhaps a fast<br />shutdown of a standby server should update minRecoveryPoint before exiting.<br /> </p>--<br />Heikki Linnakangas<br />Neon (<a href="https://neon.tech/" rel="noopener noreferrer">https://neon.tech</a>)<br /> </blockquote>