Hi,

I'm trying to understand the relation between 'archive_mode', pg_wal directory, 
'max_wal_size' and failover.

I'm running the kubernetes example from patroni (patroni 4.0.6)
When 'archive_mode: off', and I issue a couple of 'patronictl failover' 
commands I observe the following files pg_wal:
```
postgres@patronidemo-0:~/pgdata/pgroot/data/pg_wal$ ls
000000080000000000000017  00000008.history          00000009.history          
0000000A.history        0000000B.history    0000000C.history
000000080000000000000018  000000090000000000000018  0000000A0000000000000018  
0000000B0000000000000018      0000000C0000000000000018  archive_status
```
Our problem with this is that If I do a lot of failovers, lets say a 100, then 
there will be a 100 files ( from 000000080000000000000018, to 
0000001C0000000000000018)
and during checkpoint it doesn't decrease, and can go way over max_wal_size.

Whereas if I set 'archive_mode: on', and 'archive_command: /bin/true'
```
postgres@patronidemo-0:~/pgdata/pgroot/data/pg_wal$ ls
0000000E000000000000001F        0000000E.history          0000000F.history      
          00000010.history        00000011.history
0000000E0000000000000020        0000000F0000000000000021  
000000100000000000000022        000000110000000000000023      archive_status
0000000E0000000000000021.partial  0000000F0000000000000022  
000000100000000000000023.partial  000000110000000000000024
```
In this latter case after a timeline id is incremented postgres creates a new 
file with an incremented seqno, and in this case the files get rotated out 
normally they don't go over max_wal_size

Can someone explain why the difference in behavior? Does postgres only use the 
seqno only to differentiate the wal files here? Why does postgres not rotate 
out files in the former case?

Many thanks,
 Arpi

Reply via email to