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 1wUEdd-0011lI-1j for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jun 2026 02:13:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wUEdc-00CBoy-0u for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jun 2026 02:13:52 +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 1wUEdb-00CBoq-2y for pgsql-hackers@lists.postgresql.org; Tue, 02 Jun 2026 02:13:51 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wUEdZ-00000000lvF-2LZu for pgsql-hackers@lists.postgresql.org; Tue, 02 Jun 2026 02:13:51 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-396775c26f9so19100851fa.3 for ; Mon, 01 Jun 2026 19:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780366427; x=1780971227; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=QdGBFbuThgrji3vieQ1xo+d8JQPQ3+yb/mJ1Ah7LSt8=; b=NRGyTdDc300EC8sMp0BAX40XuCqkzvswXIeQxlEDMjeyWylC1YtlEZb7n2RuYx9Iai tXUDu3sgcetpCjyKvqNW12vIad63c+1S7zZcxQyRAW6coMtYKagvGpBXm87RN6HaDP1O oyMhoOauICpL96HhRg7/FP4jPQoMXK9wNuMebObALWQDkBEvs5VDkjVAvgpN9uI9wSv8 e8Q6WOAQYJZHpKzTHrFR2EFcA6DBR/ZgRQeqXlRcpWegjLJzbw4rg+NB0rfrVZGQZ8md NaCI7gPx4Ah5BcX1Ifj54BhPmbUWLkhxvXBjI6PnN6cfhfea5UUyYP0r22NosAMvKuum rbeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780366427; x=1780971227; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QdGBFbuThgrji3vieQ1xo+d8JQPQ3+yb/mJ1Ah7LSt8=; b=AtpjaM5jnVZ5L7AjRIAPfl/Dm9U0YJQPOY0MHpu1tjni6iubxgWniD8cw3hdv9KCWh DuCj/MBrU5V5G5eBolEhaaz3yvNioUCrEZ9AL9eB80dkpEKjLI/gVSUbm9S9SsTxu39f ccm7HOSH0Xn8JgVkZELsgiDF/bFMaNVDwwIS1pjoUIjYFGwHb/WSCv0ibsVz7DxYEYUm hlj+AU4Ar65ucFdzGAyh18F2eU+a+2lyMk8KGSkNWS7zNzeftMCA2UdGQk16XI+N66Ls tEKjJpyMw6SD/SuNoccGEC3dnZaLvG24PzLAwdrJtU72XeLp8yyz5flFgI3Ny5H5Y+lL dKIA== X-Forwarded-Encrypted: i=1; AFNElJ+yZ9dql48zzdfpz99S0FCIs1W/bu2djqU7u/Pm+KuQXi/Kf/MR3B8annXbjCVzSMUr0sa8jv1EXRMBSXbV@lists.postgresql.org X-Gm-Message-State: AOJu0Yym2hrArdaTFVkF0gs/bi+dNW6wma+lHe8ned3WD4xsUDujmqoL WVsJCuR5jheUMW6w8h8kV6vl6zJIlw9siBikiO34z5XqiAFrIuwS2hy/ X-Gm-Gg: Acq92OFHAhFkH3oF3965FpvNitWMloDgsNkKN3BTY8aUkMkpH8cb0U5IZ3HkJzl/+zP +rA5gsZQrsfOkccqN2fVOUZb9Zfi6YV+DR5X4WIXRzdHVrN+mHa1rnF2MBh3c0OvdoAlqHqeIGw XUrCRlAB3e5X3iGBK3ZvngvSh69WP0+BZYClUL7p+4bMIeCfwm/LgCS236l/xVhu9xsO6/5sGcU S4K8CwPosVwZhKltMUJ9d+qfvoobHU4gVc19Oc1aoX5DT1VwOC7pALo6mFk4VPX1SoBNdGfTdh+ 5Hn+a1nDCQVhgzFZxB2IL/TYXCtfQRIxqJ6wbSH1zFRhJzyY2ZLSdQP5BOX6IMBs5M7OLodRIQf 7b8Q+pifeDYeF1R1wkCY8RhV0BuviHDZblo8FM8kcZUrS1r9ozYZchMQxhPwHKrnP4dUQOyEadH xHRl2NdptuVXrXqVPTkJViqguBqBwXOVNsvUg14eWI8Ln6NTSpFxS3wRg5Mpmq5j7jH6QTODBdN 3E= X-Received: by 2002:a05:6512:1326:b0:5aa:6f8e:ffdf with SMTP id 2adb3069b0e04-5aa73e6ea29mr757083e87.22.1780366427132; Mon, 01 Jun 2026 19:13:47 -0700 (PDT) Received: from [192.168.0.11] (c151-177-23-39.bredband.tele2.se. [151.177.23.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5aa5b07d389sm2433354e87.36.2026.06.01.19.13.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2026 19:13:46 -0700 (PDT) Message-ID: Date: Tue, 2 Jun 2026 04:13:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pg_rewind does not rewind diverging timelines To: Kyotaro Horiguchi , japinli@hotmail.com Cc: suryapoondla4@gmail.com, pgsql-hackers@lists.postgresql.org References: <9ce0d2b9-7a41-4a8a-b299-da295bb4514f@gmail.com> <20260601.153058.2271004477925758292.horikyota.ntt@gmail.com> Content-Language: en-US From: Mats Kindahl In-Reply-To: <20260601.153058.2271004477925758292.horikyota.ntt@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/1/26 08:30, Kyotaro Horiguchi wrote: > Sorry, I only just noticed this thread. > > I may be missing something, but UUID feels somewhat heavyweight to me > for this problem. > > I wonder whether strengthening the history-based matching would be > sufficient instead. If timelines with the same TLI but different > histories can be treated as distinct and pg_rewind continues walking > the history chain until it finds a common ancestor, that seems like a > fairly natural fit with the existing timeline model. > UUIDs would certainly make identification straightforward, although > they would also introduce longer identifiers that are a bit less > convenient for humans to work with. My initial thought is that it may > be worth exploring how far we can get with the existing history > information before introducing a new identifier. It is a good idea, but unfortunately there are positions in the timeline that have same TLI, same LSN, but are still different timelines because they originate from different promotions. Just to summarize the situation: the timeline history file contains a TLI (which is a number), and a switchpoint (which is an LSN). Each time pg_promote is called, a new timeline is created based on the previous TLI (it is increased by 1) and the LSN at that point. (The actual history file is written by StartupXLOG, not by pg_promote, but pg_promote triggers the process by writing a marker file.) If two servers go through the same sequence, e.g., start at the same timeline, does a promote, and write same length but different data (e.g., add a line to a table, but with different contents), they might end up with same TLI, same LSN, but different pg_promote calls, and different database contents, hence it is not possible to distinguish them. LSNs are usually different, so it is not a very likely scenario, but it is still there. The UUID is just generated and written when pg_promote is called, which is not very often, hence does not affect the server and replication very often. Note that the UUID is _not_ in the EOR (EndOfRecovery) record, just in the timeline history file. Best wishes, Mats Kindahl