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 1wPYDt-000pJu-0T for pgsql-hackers@arkaria.postgresql.org; Wed, 20 May 2026 04:07:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wPYDq-0068Do-2K for pgsql-hackers@arkaria.postgresql.org; Wed, 20 May 2026 04:07:55 +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.96) (envelope-from ) id 1wPYDq-0068De-1D for pgsql-hackers@lists.postgresql.org; Wed, 20 May 2026 04:07:55 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wPYDo-00000000QhY-2Fh0 for pgsql-hackers@lists.postgresql.org; Wed, 20 May 2026 04:07:54 +0000 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-3695bf7d082so3982242a91.0 for ; Tue, 19 May 2026 21:07:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779250072; cv=none; d=google.com; s=arc-20240605; b=OLPexyUS5hbbQqo/rxfIx/vAT5sphRQOwwt//6WrieoCmgRtzSol7/OTaspOHXrUPP 5huhJcx4af6L1bsv0WMNjnAkL+lIeTHySjK+zKItQ99Yn0KYJdM1vbWcthA1RdctIbu1 XDXaKy+3FvUjEncmoB8UYswCcRqVGAoy32VQpO9y1ziIlDKiVXSdBbmxUZATNm8Wdje5 qJXQ780vGn1QQGZxAVKkL8/e3zrEwzJkw0vCsfGuRjTK01uvuDPOELmYmzVn8YWnncks OMWyQ2XWe/7+vyjIrZJIFGf/nid5vTxQZe7ehf+668EX/wYFn6wnNc026/qywXRwcoAE mlvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Ur1aCQZX0MgExgJhYSYw2ug1Ggrxp4icE6AKIoCoh4w=; fh=QotKQ8x1WM9taE72VAQbb1TK0dq8Po+S+5YOXT36cno=; b=Ax7iPFY2VqF1u7hGU1fSBVFzM+PiB4aBDe3mQmDM5dvsbF2P0y5C536LldQKV2paMs mkTDjm8otquwWbJ7+uqX5HEHxsQ28xouxB2yFvm3C9eYavTO1gcil0ab0CedDVxbXGrQ F8M7MjHKt0Qcf5Bo67l+M8XElk2VnMZmbM8xTZ+dknOqNGqJKiSZvif6JoxUpO9mRDkP yqsJoZ5S26MIQ+GVbTYh06ROMGT6mz9nChOm9agfGd55o4zq8GKwTW5zkKcIt9e1EH8I kGcNVGdbTORwycyDdyAtfaE+s0JbJvgsrX7xO2Wkd3HtqOYLeWuUb2qvrmz0RJpZ0XfT 8G3A==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779250072; x=1779854872; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Ur1aCQZX0MgExgJhYSYw2ug1Ggrxp4icE6AKIoCoh4w=; b=XPer2ZJzX3Q7c4MRgKdwQNtfPqQPqZ254O5XQzeeVqqt8O69zvOP2+RRnMjM7lD9/h MmxR9z2rCw5cHSVygsTBtIMRHZdqasDpCUqERM7XZw0EsSxRltmr3RnvqKnAafIkykbl 7Q0eJNnwcObqtkwdRvA06P/He4yaYVDKNEbhfTKi+zpJKV5OGa8IQZzbi7q2lUKJeq1/ FbDQTAHC2yn4IkYgz68esEnIlkQ5Pbz0AfD7C7SiRy36p8wADyFOLYqNuzxeLO4zqacL kdCUwrykspXkbde4zVUMmgrlNyTUenUMpu3lXajQznMUwgNQPm5OxV9y7n3+ABOY5rhv NOkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779250072; x=1779854872; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Ur1aCQZX0MgExgJhYSYw2ug1Ggrxp4icE6AKIoCoh4w=; b=kx/HJBCXbdUdLwJdcH1EJ4Ng/6CUg2P3VErlkYSW2A9TAGlugtixShlPGAwOcIqK0t 5VLeIgMVO+L1+QLRwz1PJxMCapgSNC4UmdMiKTpul/PjprRTeIGMgNS7Htu6pWA3+L2l Nd/KquATYsj2roTBeOwsQXQeYmolMngNc6cEmLzXj5NwzaKBcfDdpRQ+VpZ2umNVQJfH Zi4tdSopa+Z1EmVmkFxQW7RoOdR2XBafXH4dGvS41RbxpsgaR3wLxc1A9urRjBkpfKhB EQtXmMziq37/fePf/pwxtJgBWaWULdWRkPzJH7W3FeVAGP/c8apJCxjsbV9fEkrdzKMj Ohrw== X-Gm-Message-State: AOJu0YyBzvSFwvvWqjQf9/ZAJZ91fWw21cthCKGeLoVpMpy8ILZ/Xo6d Gnc3s8RQpZcEzVGEz01hf5b0m0mJmgrfJls4znEGy95MZKSdaOQH+rvERoGTg/q+ZZ0P8KrcBVa gUmNRGUawukD+anpxVQKnCB803ZYbYQo= X-Gm-Gg: Acq92OGYmaB7R27pnL6tVj66ZjkTUiMXg1WM1DLWCr9hBTJwUXEfQvadIHmSRpaaTZI lwfPRhFs+N/+mFhQftygaswzbx0UhzLp8Ke1banm6PPVA+McQLFTsSTaGr6KqpfKzZEXC6qiAU4 ADVtCT7gzqRxhJNJXba2ms4/aDEmaK1GmbjBzTP4M/AxMHN9asvXCuXIn6gCg1bUhOaRJSJjJty 3puZ9ZYqe70UjyYr11EZuGUnHb51YQvHEVOByvRf/MvJoLdqfxSWAsDp/F+KPNZKTC+LE1w/+9F ha62CLySzUMUDSDUo2ncLgsJVJgo1gp/oN7eZEMcatyvTWIVXe5YEgcD7sgpZ4AV X-Received: by 2002:a17:90b:260b:b0:35f:b987:4dac with SMTP id 98e67ed59e1d1-369519f3559mr24735915a91.12.1779250072051; Tue, 19 May 2026 21:07:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Wed, 20 May 2026 09:37:39 +0530 X-Gm-Features: AVHnY4KxkC1-wfHMpTkIFPoXwGTMZgVZe4aGMftpvraCcnbTnh2HaOwD6Pd5CrE Message-ID: Subject: Re: Improve conflict detection when replication origins are reused To: Nisha Moond Cc: PostgreSQL Hackers , shveta malik Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, May 19, 2026 at 7:08=E2=80=AFPM Nisha Moond wrote: > > On Tue, May 19, 2026 at 2:52=E2=80=AFPM shveta malik wrote: > > > > I find Approach 2 the most practical. I explored other ideas but none > > seem completely reliable or worth the effort to justify this use-case. > > A few ideas I considered are: > > > > 1) We could modify replorigin_create to exhaust the full range of IDs > > sequentially before reusing them. But this is not a reliable solution. > > It would make the bug much harder to hit, but a busy system could > > still eventually exhaust the 2-byte limit of 65K IDs, after which the > > problem may reappear. > > > > 2) Using LSN Matching instead of timestamp. To completely eliminate > > the edge case where a timestamp results in a false-positive case, we > > could track the origin_creation_lsn and compare it against the tuple's > > commit LSN. IIUC, it would require extending commit_ts to include > > 8-byte of commit-lsn which might not be a good idea. So this idea may > > also not be desirable unless there is an existing way to extract > > commit-lsn (which I am not aware of) without extending the commit-ts > > structure? > > > > Using LSN is a good idea. I looked through the code a bit, and > extending `commit_ts` seems like the only option. I also could not > find anything existing from which we can extract the commit LSN of a > tuple while applying a change. > Every heap page has pd_lsn (accessible via PageGetLSN(page)), which > stores the LSN of the most recent WAL record that modified the page. > But this doesn't help, as there is no correlation to a specific > tuple's xmin. > Even I could not find any existing way to get the commit-LSN. We have TransactionIdGetCommitLSN() but this does not return exact commit-lsn. thanks Shveta