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 1tZBjT-0036Ai-8r for pgsql-hackers@arkaria.postgresql.org; Sat, 18 Jan 2025 16:31:36 +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 1tZBjP-001F2a-V6 for pgsql-hackers@arkaria.postgresql.org; Sat, 18 Jan 2025 16:31:32 +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.94.2) (envelope-from ) id 1tZBjP-001F2R-LA for pgsql-hackers@lists.postgresql.org; Sat, 18 Jan 2025 16:31:32 +0000 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tZBjL-000E0f-2u for pgsql-hackers@lists.postgresql.org; Sat, 18 Jan 2025 16:31:30 +0000 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3b05:0:640:71ba:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 1471960AFE; Sat, 18 Jan 2025 19:31:24 +0300 (MSK) Received: from smtpclient.apple (unknown [2a02:6b8:b081:1254::1:6b]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id MVWumo1IW8c0-5Z0bNgth; Sat, 18 Jan 2025 19:31:23 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1737217883; bh=NdkdcFvwJVlUFi/ZeXt6KjdqjTpDt47DFihzv+Tu4Yg=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=vI3MngIQNw05tL5b9KsbjWjMFpweotGbvBAyym5O/w4XQS5iVHta2vqnEpP6eREk9 PkVeLOnI6xFGDxVzcGxOq201mbLgUML/2XKIHjUllUnFDsVwzAKWUpDBoHFaarCPYA HqGa8aEsGXUm6QV4nEip0MxZty27hdgLELVEqOcU= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51.11.1\)) Subject: Re: Timeline issue if StartupXLOG() is interrupted right before end-of-recovery record is done From: "Andrey M. Borodin" In-Reply-To: Date: Sat, 18 Jan 2025 21:31:12 +0500 Cc: pgsql-hackers@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <171297CF-48B3-49D1-B5B2-BAFEFCA63712@yandex-team.ru> References: To: Roman Eskin X-Mailer: Apple Mail (2.3776.700.51.11.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Roman! Thanks for raising the issue. I think the root cause is that many = systems imply that higher number of timeline id means more recent = timeline write. This invariant is not uphold. It's not even more recent = timeline start. "latest timeline" effectively means "random timeline". > On 17 Jan 2025, at 06:05, Roman Eskin wrote: >=20 > 5. Switch back instance_1 and instance_2 to the original > configuration. And here, when we try to start instance_2 as Replica, > we'll get a FATAL: > "FATAL: requested timeline 2 is not a child of this server's history > DETAIL: Latest checkpoint is at 0/303FF90 on timeline 1, but in the > history of the requested timeline, the server forked off from that > timeline at 0/3023538." I think here you can just specify target timeline for the standby = instance_1 and it will continue recovery from instance_2. Having say that, I must admit that we observe something similar = approximately 2 times a week, tried several fixes, but still have to = live with it. In our case we have a "resetup" cron job, which will automatically = rebuild replica from backup if Postgres cannot start recovery for some = hours. So in our case this looks like extra 3 hours of standby downtime. I'm not sure if this is a result of pgconsul not setting up target = timeline or some other error... Persisting recovery signal file for some _timeout_ seems super dangerous = to me. In distributed systems every extra _timeout_ is a source of = complexity, uncertainty and despair. Thanks! Best regards, Andrey Borodin.=