Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x8d25-00000001OiE-33im for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Sep 2026 12:22:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x8d24-00000009MwM-3GZr for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Sep 2026 12:22:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x8d24-00000009MwD-0F12 for pgsql-hackers@lists.postgresql.org; Mon, 21 Sep 2026 12:22:04 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x8d21-00000000UfK-1GRA for pgsql-hackers@postgresql.org; Mon, 21 Sep 2026 12:22:03 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-495437bb891so14771345e9.1 for ; Mon, 21 Sep 2026 05:22:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789993320; x=1790598120; darn=postgresql.org; h=to:date:message-id:subject:mime-version:content-type:from:from:to :cc:subject:date:message-id:reply-to:content-type; bh=tC2jFVWNWjAe2ZuzJ5BPPtuWx17kLbjB5+FLUBzute8=; b=pYWs063d2f56lg5eOj1mX0X2SKMkwitwxnwtXaJQ1N1SIl5fxJVFaBcCKPkQSXD6k6 zJZNDxCwE9Xf0kL0RWCza5dFW6GGwNqLxvawP1E2oXeaY+rsedPcQBF6GSrjsAIGIHes ZQm8cfxvKcZ/BOJvqedzyXwVM/UivxqBUOnjmsecAmsbMR/+TCauwyWhrACqeDQVT5G9 FJiuj4ojZMEKUDJhaznA7avVLOKYdKvqzLOHYn5Z0zWP8yKTi9bFJQZYSu08GPsO6Q5i tkNhUuOI8Sk6kqbMgh+Jtz84pMR4MPEdISe5SUcT+CKk3j5LuhjAUgS0Qt4jWRXhYeag 21eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789993320; x=1790598120; h=to:date:message-id:subject:mime-version:content-type:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=tC2jFVWNWjAe2ZuzJ5BPPtuWx17kLbjB5+FLUBzute8=; b=dmjchwYez8CSiSxZ3LUk0fDrbrwDr39bKr0sjQx2PpcsmFCUc7xp2aJOn7Z4mdNKsp BXuUKTW0S9/fTzNztOoKcKMpUw5o3XYTi9N9C0ujkirtr+HS+N51InMelLx/k9yYy/e0 0w8gPxLVYX2ayHySlbhY3DwVRMJsIEjeWVQtdyncUhzYhWJ3Gto49/tgOJZeV1rfgQCG 4fRsEdJQ4VENoMxGebuh/48PYSbrTxTgkKComcrODD907X3IkLRi8HRNND5JUCfFA1m3 1tEicyaZdq+gx8ScVo5uwmnWCy1WcOyTnyi85gPwFID1bn6dN5fpsp+U+wPPhKaECyzU cGmA== X-Gm-Message-State: AFuF++loz5x172pJwAgIWE0W23qJLmigPZQksGScOU/Ae3hIqgchIa/C D44Tz8CacvK9RSdfBdtDDsxY9UZ8SkzZDqvhtCe/P8e5zcQzNH/mu1nPbi8iIUS4 X-Gm-Gg: AYBFou1EDl1bynAHooA/oLc8g48fEE36328Eeu/Xg3O537sUHAk4toZiwubk04fAe+J 5To/vrz98flaiAxQEQe1FOQDksooByJ7m3hnd1ZgS/86gh30zTkKc39D15FRrcY+lNBpAgJJTBP XT6+d+S/iRyBtrzU1lUjfw6xJ/FyvA8Ras7YPvbwmE0dSRV/K5xojPIvCQuqwslVJgvxornxeSN TvgBY11mu168uLPYpsBgA0Eze6sZQOyVty6ijEx4enRlGzeius7TzwurP1ItlsFN754QFHVZQZ9 KDqLpNuURwY35QNvLFfBnHRNaEauROrOQIX26KW2Szn4n7tw2OL0F7EMj+uANbx6r12+Nm7RY9Z wKrP8idy8jp0pcPHJSVmuk4JXdQac0v+94SKL/qFb0Uc1L9vcBSskhRn5Rakz0rwjxK8yRCO3Nl /qsatrekC7qvuI4j6+KJ+sffvFqL/UzBHG2UMxJQYmL0vCXfZboa09aeZTVVVuxcZSXH216Um80 nGCpTvhXNJJ/WyB2KJIj4BYtCryvK6ozNN+Mg== X-Received: by 2002:a05:600c:81c5:b0:49d:28fc:d6a0 with SMTP id 5b1f17b1804b1-49fbd200256mr220765875e9.18.1789993320167; Mon, 21 Sep 2026 05:22:00 -0700 (PDT) Received: from smtpclient.apple ([5.176.154.121]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4872456301dsm22819968f8f.18.2026.09.21.05.21.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2026 05:21:59 -0700 (PDT) From: =?utf-8?Q?R=C4=B1dvan_Korkmaz?= Content-Type: multipart/alternative; boundary="Apple-Mail=_8D353436-674F-4805-8413-5869495C9B60" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.700.51.1.1\)) Subject: pg_resetwal with replication slot (17.11) Message-Id: Date: Mon, 21 Sep 2026 15:21:56 +0300 To: pgsql-hackers@postgresql.org X-Mailer: Apple Mail (2.3864.700.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_8D353436-674F-4805-8413-5869495C9B60 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi Dear Experts, I hit a case seems odd. I wonder if I do something unexpected, or = something is here I can't see. First, these are all on test environment. The version is PostgreSQL = 17.11, uses homebrew installation on MacOS. I have a master - replica setup, both are on the same host. master's PGDATA =3D m port =3D 15432 rs =3D rep slot for streaming replication used by instance "r", = created on master (m instance) max_wal_size =3D 4GB min_wal_size =3D 2GB wal_level =3D replica replica's PGDATA =3D r port =3D 25432 primary_conninfo =3D created by pg_basebackup primary_slot_name =3D rs Case: I have 16MB WAL files on master instance (so on replica). I want = to utilize 1GB WAL files. Here are the steps I take. 1. setup master - replica run on same host in respective directories and = on ports 2. verify streaming replication works 3. verify "rs" (replication slot), master ("m" instance), and replica = ("r" instance) have SAME WAL lsn 4. stop master, keep replica online (simulation for actual case) = (pg_ctl-17 stop -D m) 5. run "pg_resetwal-17 -D m --wal-segsize=3D1024" on master instance. 6. start master instance, started, fine. Replica complains about "ERROR: = requested WAL segment 000000010000000000000000 has already been = removed", no worry. 7. stop master again, cool, done. (last log lines: "checkpoint = complete", "database system is shut down") 8. start master -> bamm, could not start. (pg_ctl-17 start -D m -l = m.log) There is no read, write between after step 3 (after verification of WAL = lsns) Final failure log (step 8): 2026-09-21 14:47:45.525 +03 [22817] LOG: starting PostgreSQL 17.11 = (Homebrew) on aarch64-apple-darwin25.6.0, compiled by Apple clang = version 21.0.0 (clang-2100.1.1.101), 64-bit 2026-09-21 14:47:45.525 +03 [22817] LOG: listening on IPv4 address = "127.0.0.1", port 15432 2026-09-21 14:47:45.525 +03 [22817] LOG: listening on Unix socket = "/tmp/.s.PGSQL.15432" 2026-09-21 14:47:45.528 +03 [22820] LOG: database system was shut down = at 2026-09-21 14:46:42 +03 2026-09-21 14:47:45.528 +03 [22820] LOG: invalid checkpoint record 2026-09-21 14:47:45.528 +03 [22820] PANIC: could not locate a valid = checkpoint record at 0/40000110 2026-09-21 14:47:45.528 +03 [22817] LOG: startup process (PID 22820) = was terminated by signal 6: Abort trap: 6 2026-09-21 14:47:45.528 +03 [22817] LOG: terminating any other active = server processes 2026-09-21 14:47:45.529 +03 [22817] LOG: shutting down due to startup = process failure 2026-09-21 14:47:45.529 +03 [22817] LOG: database system is shut down After pg_resetwal, first start of master successful, but a second start = fails. I guess this causes master to be lost. I'm able to spot the issue:=20 The issue is replication slot. If I would have removed replication slot = before second start (do it between 6 and 7), it succeeds. Questions: 1. Is this behavior is expected? 2. Should replication slot case mentioned in PostgreSQL documents? (I = checked yet could not see) 3. Am I doing something out of order, unexpected? 4. Once I understood the case, I dropped replication slot and able to = start master. Now I want to copy m/global/pg_control to replica and = m/pg_wal to replica as well and complete wal segment size change. I = wonder if this way is documented or supported. I can say "it works" but = does not mean "supported or documented at all". Thank you in advance. Attachments: =EF=BF=BC=EF=BF=BC --Apple-Mail=_8D353436-674F-4805-8413-5869495C9B60 Content-Type: multipart/mixed; boundary="Apple-Mail=_F4041C06-BE4E-4F27-9FB2-10E2DB219FC9" --Apple-Mail=_F4041C06-BE4E-4F27-9FB2-10E2DB219FC9 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
Hi Dear Experts,
I hit a case seems = odd. I wonder if I do something unexpected, or something is here I can't = see.

First, these are all on test environment. The version = is PostgreSQL 17.11, uses homebrew installation on = MacOS.

I have a master - replica setup, both are on the = same host.
master's
PGDATA =3D m
= port =3D 15432
rs =3D rep slot for streaming replication = used by instance "r", created on master (m instance)
= max_wal_size =3D 4GB
min_wal_size =3D 2GB
= wal_level =3D replica


replica's
PGDATA =3D= r
port =3D 25432
primary_conninfo =3D = created by pg_basebackup
primary_slot_name =3D = rs


Case: I have 16MB WAL files on master instance (so = on replica). I want to utilize 1GB WAL files.
Here are the = steps I take.

1. setup master - replica run on same host = in respective directories and on ports
2. verify streaming = replication works
3. verify "rs" (replication slot), master = ("m" instance), and replica ("r" instance) have SAME WAL = lsn
4. stop master, keep replica online (simulation for actual = case) (pg_ctl-17 stop -D m)
5. run "pg_resetwal-17 -D m = --wal-segsize=3D1024" on master instance.
6. start master = instance, started, fine. Replica complains about "ERROR: requested WAL = segment 000000010000000000000000 has already been removed", no = worry.
7. stop master again, cool, done. (last log lines: = "checkpoint complete", "database system is shut down")
8. = start master -> bamm, could not start. (pg_ctl-17 start -D m -l = m.log)

There is no read, write between after = step 3 (after verification of WAL lsns)

Final failure log = (step 8):
2026-09-21 14:47:45.525 +03 [22817] LOG: starting PostgreSQL 17.11 = (Homebrew) on aarch64-apple-darwin25.6.0, compiled by Apple clang = version 21.0.0 (clang-2100.1.1.101), 64-bit
2026-09-21 = 14:47:45.525 +03 [22817] LOG: listening on IPv4 address "127.0.0.1", port = 15432
2026-09-21 14:47:45.525 +03 [22817] LOG: listening on Unix socket = "/tmp/.s.PGSQL.15432"
2026-09-21 14:47:45.528 +03 [22820] LOG: database system = was shut down at 2026-09-21 14:46:42 +03
2026-09-21 = 14:47:45.528 +03 [22820] LOG: invalid checkpoint = record
2026-09-21 14:47:45.528 +03 [22820] PANIC: could not locate a valid = checkpoint record at 0/40000110
2026-09-21 14:47:45.528 +03 = [22817] LOG: startup = process (PID 22820) was terminated by signal 6: Abort trap: = 6
2026-09-21 14:47:45.528 +03 [22817] LOG: terminating any other active server = processes
2026-09-21 14:47:45.529 +03 [22817] LOG: shutting down due to startup = process failure
2026-09-21 14:47:45.529 +03 [22817] LOG: database system = is shut down



After pg_resetwal, first start of = master successful, but a second start fails.
I guess this = causes master to be lost.

I'm able to spot the issue: =
The issue is replication slot. If I would have removed = replication slot before second start (do it between 6 and 7), it = succeeds.

Questions:
1. Is this behavior is = expected?
2. Should replication slot case mentioned in = PostgreSQL documents? (I checked yet could not see)
3. Am I = doing something out of order, unexpected?
4. Once I understood = the case, I dropped replication slot and able to start master. Now I = want to copy m/global/pg_control to replica and m/pg_wal to replica as = well and complete wal segment size change. I wonder if this way is = documented or supported. I can say "it works" but does not mean = "supported or documented at all".

Thank you in = advance.

Attachments:
= --Apple-Mail=_F4041C06-BE4E-4F27-9FB2-10E2DB219FC9 Content-Disposition: attachment; filename=1-master-replica-setup-info.txt Content-Type: text/plain; x-unix-mode=0644; name="1-master-replica-setup-info.txt" Content-Transfer-Encoding: quoted-printable 14:41:17 test$ bash setup_pg17_replication.sh recreate [pg17-lab] Stopping replica waiting for server to shut down.... done server stopped [pg17-lab] Removing replica data directory: = /Users/ridvan.korkmaz/adjust/test/r [pg17-lab] Removing primary data directory: = /Users/ridvan.korkmaz/adjust/test/m [pg17-lab] Cleanup complete [pg17-lab] Initializing primary with 16 MB WAL segments and checksums = disabled The files belonging to this database system will be owned by user = "ridvan.korkmaz". This user must also own the server process. The database cluster will be initialized with locale "en_US.UTF-8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". Data page checksums are disabled. creating directory /Users/ridvan.korkmaz/adjust/test/m ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default "max_connections" ... 100 selecting default "shared_buffers" ... 128MB selecting default time zone ... Europe/Istanbul creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok Success. You can now start the database server using: /opt/homebrew/bin/pg_ctl -D /Users/ridvan.korkmaz/adjust/test/m -l = logfile start [pg17-lab] Starting primary on port 15432 waiting for server to start.... done server started [pg17-lab] Creating physical replication slot 'rs' pg_create_physical_replication_slot=20 ------------------------------------- (rs,) (1 row) [pg17-lab] Creating replica with pg_basebackup 23498/23498 kB (100%), 1/1 tablespace [pg17-lab] Starting replica on port 25432 waiting for server to start.... done server started [pg17-lab] Primary checks port | max_wal_size | min_wal_size | wal_level | in_recovery=20 -------+--------------+--------------+-----------+------------- 15432 | 4GB | 2GB | replica | f (1 row) slot_name | slot_type | active=20 -----------+-----------+-------- rs | physical | t (1 row) application_name | client_addr | state | sync_state=20 ------------------+-------------+-----------+------------ walreceiver | 127.0.0.1 | streaming | async (1 row) [pg17-lab] Replica checks port | max_wal_size | min_wal_size | wal_level | in_recovery=20 -------+--------------+--------------+-----------+------------- 25432 | 4GB | 2GB | replica | t (1 row) status | sender_host | sender_port | slot_name=20 -----------+-------------+-------------+----------- streaming | 127.0.0.1 | 15432 | rs (1 row) [pg17-lab] Ready: primary=3D127.0.0.1:15432 replica=3D127.0.0.1:25432 = slot=3Drs [pg17-lab] WAL segment size verified as 16 MB; data checksums verified = off --Apple-Mail=_F4041C06-BE4E-4F27-9FB2-10E2DB219FC9 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii
--Apple-Mail=_F4041C06-BE4E-4F27-9FB2-10E2DB219FC9 Content-Disposition: attachment; filename=3-all-wal-lsn-same.txt Content-Type: text/plain; x-unix-mode=0644; name="3-all-wal-lsn-same.txt" Content-Transfer-Encoding: quoted-printable 14:43:01 test$ psql -p 15432 -c "checkpoint" CHECKPOINT 14:43:20 test$ psql -p 15432 -c "select slot_name, active, restart_lsn = from pg_replication_slots" slot_name | active | restart_lsn=20 -----------+--------+------------- rs | t | 0/3047328 (1 row) 14:43:24 test$ psql -p 25432 -c "SELECT pg_last_wal_replay_lsn()" pg_last_wal_replay_lsn=20 ------------------------ 0/3047328 (1 row) 14:43:33 test$ psql -p 15432 -c "select pg_current_wal_lsn()" pg_current_wal_lsn=20 -------------------- 0/3047328 (1 row)= --Apple-Mail=_F4041C06-BE4E-4F27-9FB2-10E2DB219FC9 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii


--Apple-Mail=_F4041C06-BE4E-4F27-9FB2-10E2DB219FC9-- --Apple-Mail=_8D353436-674F-4805-8413-5869495C9B60--