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 1xAiCt-00000002nkx-2Jyb for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Sep 2026 06:17:51 +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 1xAiCs-00000005Rwv-30AA for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Sep 2026 06:17:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xAiCs-00000005Rwm-1ayE for pgsql-hackers@lists.postgresql.org; Sun, 27 Sep 2026 06:17:50 +0000 Received: from mail-pz2-x0d.google.com ([2607:f8b0:4864:3b::d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xAiCp-00000001WkX-34xM for pgsql-hackers@postgresql.org; Sun, 27 Sep 2026 06:17:49 +0000 Received: by mail-pz2-x0d.google.com with SMTP id d2e1a72fcca58-8631d0023daso1025781b3a.2 for ; Sat, 26 Sep 2026 23:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790489865; x=1791094665; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=4e1hlQY3T+Oo8vrx14gU9bVpTu9OBG0bejS+vBBy+Ko=; b=AJ7uF8uCZZZwDAX2jZHaUBSeZPxj9n3+SZSgJCAvTlr95YSanYigpsz/z70Atdt+Qf /lQocT+D1aVSq3SyqZpFbNVSdysfUpusvkhd5XFY4gMz/tRPcu+n/tpqN/+/AJSVLq1W YVON1QmM1vQ/bufXxvgUXCMlNKmhnwqNYHg+PHi0rrUzt7hpWqVn9eJh9XGgTGpYaKDb ayqIBZaEzGr9NGQJJbRDA3p882apb3fVHPm7WbGGjYCHEmFYedWsOVN5KpkfbvQc/eOZ FIsBzA2yz8hVrzPSysptto1sqybqcwfPZX9QnGtsFhxrQvcP9qLx1r7tQ4slnKScFhyU 2Vmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790489865; x=1791094665; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4e1hlQY3T+Oo8vrx14gU9bVpTu9OBG0bejS+vBBy+Ko=; b=I7iN3AcBLpT4uzXEMFNu8J23ePQBkN2BmhGO7EwFF0eR4qhHmb/1nk+lzeGAfCHwlv GJol6jr2X9tmhVEn0h+1US1YoJADW06Soi+UTKvJm7n3Mc9Ykrst0mFg1TKKxX3LVkC5 ThOhCpUfGH9feNwzVyN6dzRJUDMSozqCQb/hMewaEhy+ng9MRAd0jF1bDEFO5neIjRWJ oTaMNHL1DUtCDNS5UzWyS7NlEyszRQcUIesO3d66BdgZ4aRqMOdRe3qhTRj1maYPVj2F tH8Rypuepi0SRpf6VkRniWvFHonotyuGfGr27Mj8hqC16V08BOlCouNbfhVNVLdLdWY5 udBw== X-Gm-Message-State: AFuF++lEZm2a+x6lnMLNiBmYfQcOXDURSHOhRs7LeI3WZ8O6WwgcpN2R 1+wfVtrYSRXIwtvyGsx0kbc5ct1aOk5WZc8O5K4hUXP5pDl1BtTgP4EALneuQg== X-Gm-Gg: AYBFou1D5urJdt8fHQ29Ot4norHqSADvoH9gdzItB4AbuVxg0znBMeQ6ZeFOu9TKqkp iEsDDkFV97aqCVM1++hqHfli+gYErCLUjiPZKfodptAqx2ItdGkEDqQa/Y55R4tdRphOtn48+Lo s4yfYqat/T19RpGzbAgyJe40QU83pibtyh0x52Nzf3DJWdW5duePfGFVy9bzFiTcrP0abyEtNxZ 09xspsl7IlyFRB8hYjG/At7ep8xv4CAJ/Grust8ZG+e5ZICKsvyyyfQb7dP90N2Cu7VHiWv5urc +lroS9QDzDnOrrIwGJxNC59cvZdC4pHm3Eitpl4KVN043BQPRcmtkE3DP1WHz4M4m9J1uSdfkND Pcs2pLNSoBfHuzFWwtHmq1pmLdhL2Om0Bfu5D3tJZepb0oA9FAaX1MrxeCqSfarAD5iMuo8URNt acew/U5dGSAi1hMvtWtZNvYk+bkeoL5Hhvj13FsUxv+VZmjQQ4QO16nzLM0C+YqGnWnBE2MGVqz 45xFSU= X-Received: by 2002:a05:6a00:a16:b0:87a:50f9:2930 with SMTP id d2e1a72fcca58-87e9be77f97mr8248245b3a.55.1790489865358; Sat, 26 Sep 2026 23:17:45 -0700 (PDT) Received: from smtpclient.apple ([185.135.79.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-87feb57a5a6sm2725435b3a.47.2026.09.26.23.17.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Sep 2026 23:17:43 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.700.51.1.1\)) Subject: Re: pg_resetwal with replication slot (17.11) From: Chao Li In-Reply-To: <177EFF62-78CE-4918-88E2-8B464248E651@gmail.com> Date: Sun, 27 Sep 2026 14:17:07 +0800 Cc: pgsql-hackers@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <8E9C4DA6-1907-44CB-8946-337C634F9F3E@gmail.com> References: <177EFF62-78CE-4918-88E2-8B464248E651@gmail.com> To: =?utf-8?Q?R=C4=B1dvan_Korkmaz?= 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 > On Sep 26, 2026, at 23:03, R=C4=B1dvan Korkmaz = wrote: >=20 > Dear Experts, > Is this mail list correct list to share my case, > If anybody gets this message and respond (to guide me to correct = list), I really appreciate. >=20 >=20 >> On 21 Sep 2026, at 15:21, R=C4=B1dvan Korkmaz = wrote: >>=20 >> Hi Dear Experts, >> I hit a case seems odd. I wonder if I do something unexpected, or = something is here I can't see. >>=20 >> First, these are all on test environment. The version is PostgreSQL = 17.11, uses homebrew installation on MacOS. >>=20 >> 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 >>=20 >>=20 >> replica's >> PGDATA =3D r >> port =3D 25432 >> primary_conninfo =3D created by pg_basebackup >> primary_slot_name =3D rs >>=20 >>=20 >> 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. >>=20 >> 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) >>=20 >> There is no read, write between after step 3 (after verification of = WAL lsns) >>=20 >> 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 >>=20 >>=20 >>=20 >> After pg_resetwal, first start of master successful, but a second = start fails. >> I guess this causes master to be lost. >>=20 >> 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. >>=20 >> 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". >>=20 >> Thank you in advance. >>=20 >> Attachments: >> <1-master-replica-setup-info.txt><3-all-wal-lsn-same.txt> >>=20 This looks like a bug. I just reproduced the failure on master, I can = debug the problem and try to work out a fix tomorrow. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/