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.94.2) (envelope-from ) id 1uCfF8-000ZTZ-54 for pgsql-general@arkaria.postgresql.org; Wed, 07 May 2025 13:55:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uCfF7-00EQid-61 for pgsql-general@arkaria.postgresql.org; Wed, 07 May 2025 13:55:25 +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.94.2) (envelope-from ) id 1uCfF6-00EQiU-Pw for pgsql-general@lists.postgresql.org; Wed, 07 May 2025 13:55:24 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uCfF4-000dhr-0L for pgsql-general@lists.postgresql.org; Wed, 07 May 2025 13:55:24 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3a07a7b517dso4620230f8f.3 for ; Wed, 07 May 2025 06:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1746626121; x=1747230921; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=FplOGlK1K92zn8b3wLsZr2CtNge7flbudutuDroWBuw=; b=ovQ+7R9mSXLqqt82/WwF2vUjixOYEF0AIVWMoBhIHXx9gooXzBvSOv414SjflIA9Mb B9jMIg5KkaSLA5EfPCDwbg8EZvLEo7O+Hxw6HZQRLlAKkGlHQIIzm3chWWlA6Y/66L5a xLiDwFxpnZ7XwcpnM3hJOlHtK2dlOz58j9gt10iiipzELdNKW8ehuCA4WN6OMg17k09u HGKus1/6YcqteV7XQDXmhdViTGAC+mjpzv86bmK8cFtew10A0mMXcglT3Y3mDfBx1hha Pap/zrKuNJx83D3nIa9TgU27wvj+9OctjF1nurso8l5pN/d/DqkpYL/fLs/7E/aqO149 iV3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746626121; x=1747230921; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=FplOGlK1K92zn8b3wLsZr2CtNge7flbudutuDroWBuw=; b=q6UB16BKla6XpmAnFfguJfB8c0x/QWZ5GYKItKnpyiPvasfTzhqs7tCmxA/QqwOx1z ckjHqejsCKTy1O7lYA6IJO9usDvxT43SfNcSnPKSjGLfM/OwT1UQArWWRKtNpEX1UCwF GppMa+KADYFd2aA4Ccm9sq7bM/u9urFPUKgR8dTW4pv47/uUASLm/ag8hBSbY86kLLWh H07AinqEHVT7F0ohXQaMNL2xvH7R2VrOY/co9oa78evqbmq9BWcsO/d3g0jHAqed2VOo p6xnTADtfFSqka14Rja+vrLp4rpJHcENrRz8UpCCHQRUTbyp9+j+jmaXjO7BjA/uNEQ2 mQRA== X-Forwarded-Encrypted: i=1; AJvYcCXuM0B/Yco6SpRCe00zCELY0KC9V63TqEBfT1a6wioTt1y/AKkdltZQLuZunW4s2SmcM1W1p0GDzuRG6J2t@lists.postgresql.org X-Gm-Message-State: AOJu0YzoCHD4FtEzXWZ3fUaXZ1EfTDPJJIVBhy6YzyKcHrHgk2PfpiRa a+rI5UqfPhgCB74C+W4SebjeoTJz9u9v0qwyLimhaXn/NsWH/2elzeVn6Wt70UY= X-Gm-Gg: ASbGncsKe486TwrsLEicWLY+hLpxyT4Uwqcsa12tnnHt+rve/IpeVDsZjMs+GDrjFAE iAg46t38uHfk1EsLnsehrND15mxf2IV9+NvD0/O08rXglAPvyuAauZAb5r/5Tiy7Q/eL/KbMgVf qclAOqGR/7HGVaIWHA/bkzR232ZdfZ46+hlf+DRnP15mPpxP4uh7pMbh+rZ8MXFMN2S3EVm0qmf dYtQbhVzX0FLimdJGkFE0YtgQOLUZ8tiQB0+/Zw3FsnMsCdZvFqKRA5DNLSJ0SAbmxO1TaA4gUE A/L7AGfVlRWnbmgoTgelVcDIPc+NHdrD8/5y7LFrsurPcSQKJg57s3+FAUmBgtniED0q7MiNph0 UR9jCme8W2+qgLZCVXLzU15YoYhj2Zg== X-Google-Smtp-Source: AGHT+IGBVe7++uU+P5rAbcb4+Qrx+b919Q3arGrjZa8CQESv53sbIFki6DMGocFKOQg+PNmpRfZmrg== X-Received: by 2002:a5d:5988:0:b0:38f:4d20:4a17 with SMTP id ffacd0b85a97d-3a0b49bb394mr2774640f8f.13.1746626121299; Wed, 07 May 2025 06:55:21 -0700 (PDT) Received: from localhost.localdomain (ip-185-104-138-51.ptr.icomera.net. [185.104.138.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a099b0f16fsm16954524f8f.77.2025.05.07.06.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 06:55:20 -0700 (PDT) Message-ID: Subject: Re: pg_rewind problem: cannot find WAL From: Laurenz Albe To: Luca Ferrari , pgsql-general Date: Wed, 07 May 2025 15:55:08 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2025-05-07 at 12:51 +0200, Luca Ferrari wrote: > running 17.4 on ubuntu 24.04 machines. I've three hosts, pg-1 > (primary) and two physical replicas. > I then promote host pg-3 as a master (pg_promote()) and want to rewind > the pg-1 to follow the new master, so: >=20 > ssh pg-3 'sudo -u postgres /usr/lib/postgresql/17/bin/pg_rewind -D > /var/lib/postgresql/17/main --source-server=3D"user=3Dreplica_fluca > host=3Dpg-3 dbname=3Dreplica_fluca"' > pg_rewind: servers diverged at WAL location 0/B8550F8 on timeline 1 > pg_rewind: error: could not open file > "/var/lib/postgresql/17/main/pg_wal/00000001000000000000000A": No such > file or directory > pg_rewind: error: could not find previous WAL record at 0/AFFF4E8 >=20 > But the file 0x010000A is not there: >=20 >=20 > % ssh pg-3 'sudo ls /var/lib/postgresql/17/main/pg_wal' > 00000001000000000000000B.partial > 00000002.history > 00000002000000000000000B > 00000002000000000000000C > 00000002000000000000000D > 00000002000000000000000E > archive_status > summaries >=20 > % ssh pg-1 'sudo ls /var/lib/postgresql/17/main/pg_wal' > 000000010000000000000005.00000028.backup > 00000001000000000000000B > 00000001000000000000000C > 00000001000000000000000D > 00000001000000000000000E > archive_status > summaries >=20 > Do i have to ensure the old primary pg-1 does a wal switch before > promoting the other one and try to rewind? I don't think it is connected to a WAL switch. I'd say that you should set "wal_keep_size" high enough that all the WAL needed for pg_rewind is still present. If you have a WAL archive, you could define a restore_command on the server you want to rewind. Yours, Laurenz Albe