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.96) (envelope-from ) id 1x2D0Q-005e4N-2W for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Sep 2026 19:21:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x2D0O-002DlY-1M for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Sep 2026 19:21:48 +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.96) (envelope-from ) id 1x2D0O-002DlP-0G for pgsql-hackers@lists.postgresql.org; Thu, 03 Sep 2026 19:21:48 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x2D0L-00000002mVO-14if for pgsql-hackers@lists.postgresql.org; Thu, 03 Sep 2026 19:21:47 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-c259e5c22ffso24663966b.1 for ; Thu, 03 Sep 2026 12:21:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788463304; x=1789068104; darn=lists.postgresql.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=9EOe3N8So4H/SulSER69Jk/b19fkzBBpdZfalQWHEcA=; b=MJ+0KdfDCqTvlif9/N7beGeIyaG4BsHODCyNcQSJtvtdNOUK6UeCWXWWwbWbbtyaGl zHK7LF4eT7oX3iby2Rzx5MJB0UiSSUQScJhT1YIHIxoZr4hEbPc5yg57jKk0aK7/lz1o wlarzp4NOi7BM7yvhhlVaR0KtdyD5KLN/npDSnh722dA+FvsgPwgM477WvVxWJXw6VJH 8rPyWZEQ05pXpvSHSZXN1b3+tLkS7ze+JT19U1U+g8Ux7im4JqMgaIU7HL2Fi2GvGUb/ rZ1tzoti54fGsa0zDdqKIi4THSW3I/+QNnzRooVK0Xpq68TJZpYUtxDiSh0iuaqGuBnr 4w6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788463304; x=1789068104; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9EOe3N8So4H/SulSER69Jk/b19fkzBBpdZfalQWHEcA=; b=XNCEWvDel+U5nY3AYAgLZwQa1vEJrD5OAIuYzrPHviCG4sLBDGyjykqyQXwRdvSfJZ zLS4/O2A3jlGSDqE/oNa6YZLPd1a7xDaLDdb40tIWbRdkmjwX5+w2rInp44S64bznAKD z0ZgELRLoKR87Q3CTy7jasuom5cyleTUIg967AxPI+FLypjEfjbMg5EJeDBLhXWPgj7/ hK1RKVR5rcHMuLN7D2vqxjNMxhIHS1heVo/AuGAXCS96jDSChY/0LWsSuD+1vW9l5Fbc eJNtC+cBJNoDOYXQHNVBk9AfG6Pk9hXqfYKLKiJtvym+Z2rbz+ajkTfiUc7u0Fvms4PH lSzg== X-Forwarded-Encrypted: i=1; AKwUvByskKxDZdNKUEO+VgPlyghiYbpzOK5azOzv+Ns+0dK7I6hFb0uAJKw3kOa0iCBcs8F1cI+1UE2TLC2qAIAk@lists.postgresql.org X-Gm-Message-State: AFuF++kKyI7TfyQww09Fj60pQMfIbvnEuUFtR4Y072QBmCa8/pjyUgPK 044KqzDG6C0VSLIhtdOCfA/ZlCBHP9a2kXJi7VSIY5Z+o38Tc5P5katu X-Gm-Gg: AYBFou3eHShVtrV3PBKMgadFbNzcqzqJoRGepKnn21bzUnhsK/U9Iwfs1lESQhmkZwq IKnBfpgOqyZY+6bUdjY0adJ2qg9MaomPX4ljtf8ccaOKiHVzQrMqeYmtOk2XgfZK5qLDcBRW4CU 9VCoEp/0yyXhCe3vO8he3truA8Hp6XTBdon16PyK9HvxOVIf1DV5djQ4QswFcEVi1IO842PnymL VI8xmu2SlBozaqG6ST3s6yYJFy2aKxJ1r43h0PlikVcvK8dfOp7+K5K/mQWtJbJWV0A6dprPLm1 rNzBsKENE278J6pCJyJmpaTI1/4j0+AB/WV4wtq54TIF6Z5OLuMpijy8PH0MD4C9D63IGYD/fEr VLN+Eebno69F70QwMlvZFtbMW58+A1tikuHRBox5LZMBrFY0IZl3CzSFumg3AXeZW0v0XbOAJXP TLrpk9tsnJ4T6pEmQZwVyyuUp8n/jq+BP4+edYkWMBZtBOhmhfZUIiFQPL9mqN3uo9lZxKpEJ10 2cLHtGwnD3F9V2lrlCf2wzqJYs4I48= X-Received: by 2002:a17:906:4fc7:b0:c25:5faf:b207 with SMTP id a640c23a62f3a-c260c7ad6a8mr69950466b.3.1788463303424; Thu, 03 Sep 2026 12:21:43 -0700 (PDT) Received: from [192.168.0.161] (c151-177-23-39.bredband.tele2.se. [151.177.23.39]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c260d53c37csm10428166b.32.2026.09.03.12.21.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Sep 2026 12:21:41 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------B0wcQBNOVcF3666HSo8Sb0NZ" Message-ID: <5407e386-3d61-4712-99af-9d0b29fab3b2@gmail.com> Date: Thu, 3 Sep 2026 21:21:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pg_rewind does not rewind diverging timelines To: Andrey Borodin Cc: Japin Li , pgsql-hackers mailing list References: <80D76C66-A953-466C-8295-A1CF8365A4D2@yandex-team.ru> <10351a09-3a93-49fc-a366-d616b67c6ede@gmail.com> <80EEB51E-176C-4E57-B86F-5200F4348D02@yandex-team.ru> Content-Language: en-US From: Mats Kindahl In-Reply-To: <80EEB51E-176C-4E57-B86F-5200F4348D02@yandex-team.ru> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------B0wcQBNOVcF3666HSo8Sb0NZ Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Andrey, and thank you for the comments. On 8/30/26 19:35, Andrey Borodin wrote: > Hi Mats, > > On Tue, Aug 12, 2026, Mats Kindahl wrote: >> Even with a shared archive, it is impossible to ensure such things. It >> is a normal consensus problem. > This race came up again in an open-space discussion here. What do you > think about allowing a promotion request to supply the new TimelineID? > In managed HA setups, the tool that decides which node may promote > normally already has a DCS. It could allocate the TLI through the DCS > while selecting the new primary, then pass it to PostgreSQL. PostgreSQL > would still validate that it is greater than the current TLI and does > not conflict with any history file it can see. This would prevent the > collision when such a coordinator exists, while the UUID could remain a > last-resort check for uncoordinated promotions. If we have some sort of API or callback for assigning a new TLI that would be excellent. Would be useful for a bunch of DCS as a way to ensure that you do not pick a conflicting TLI. Should probably be configurable though, but a normal hook callback would probably be sufficient... and yes, the UUID is good to have as a last-resort check to ensure that you don't break things. > > archive_command and restore_command are file-transfer interfaces. They > cannot express an atomic allocation, so they seem like the wrong place > to solve the distributed problem of choosing an identifier. Yup, agree. > > At least until PostgreSQL gets built-in Paxos. Every joke contains a > grain of joke, though; Kostya Osipov's related built-in consensus thread > is [0]. Would love to see that. Kostja would definitely know how to implement that. :) > > Would this fit the model you have in mind? That would work fine. My main concern about adding UUIDs were to prevent problems when you accidentally allocate same TLI to timelines that are not the same. Integration hooks with a DCS would be icing on the cake. :) Best wishes, Mats Kindahl > > Thank you! > > > Best regards, Andrey Borodin. > > [0]https://www.postgresql.org/message-id/flat/Z_1Cq7JvabsFYjQo%40ark > --------------B0wcQBNOVcF3666HSo8Sb0NZ Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi Andrey, and thank you for the comments.

On 8/30/26 19:35, Andrey Borodin wrote:

Hi Mats,

On Tue, Aug 12, 2026, Mats Kindahl wrote:
Even with a shared archive, it is impossible to ensure such things. It
is a normal consensus problem.
This race came up again in an open-space discussion here. What do you
think about allowing a promotion request to supply the new TimelineID?

In managed HA setups, the tool that decides which node may promote
normally already has a DCS. It could allocate the TLI through the DCS
while selecting the new primary, then pass it to PostgreSQL. PostgreSQL
would still validate that it is greater than the current TLI and does
not conflict with any history file it can see. This would prevent the
collision when such a coordinator exists, while the UUID could remain a
last-resort check for uncoordinated promotions.

If we have some sort of API or callback for assigning a new TLI that would be excellent. Would be useful for a bunch of DCS as a way to ensure that you do not pick a conflicting TLI. Should probably be configurable though, but a normal hook callback would probably be sufficient... and yes, the UUID is good to have as a last-resort check to ensure that you don't break things.


archive_command and restore_command are file-transfer interfaces. They
cannot express an atomic allocation, so they seem like the wrong place
to solve the distributed problem of choosing an identifier.

Yup, agree.


At least until PostgreSQL gets built-in Paxos. Every joke contains a
grain of joke, though; Kostya Osipov's related built-in consensus thread
is [0].

Would love to see that. Kostja would definitely know how to implement that. :)


Would this fit the model you have in mind?

That would work fine. My main concern about adding UUIDs were to prevent problems when you accidentally allocate same TLI to timelines that are not the same. Integration hooks with a DCS would be icing on the cake. :)

Best wishes,
Mats Kindahl


Thank you!


Best regards, Andrey Borodin.

[0] https://www.postgresql.org/message-id/flat/Z_1Cq7JvabsFYjQo%40ark

--------------B0wcQBNOVcF3666HSo8Sb0NZ--