Fix WITHOUT OVERLAPS multirange with location replication
Fix WITHOUT OVERLAPS multirange with location replication
Hi Hackers,
Andres reported that a WITHOUT OVERLAPS replica identity using
multiranges can update/delete the wrong row, because a recheck is
needed.[0] This patch fixes that problem by performing a recheck when
the scan indicates one is needed.
RelationFindReplTupleByIndex() and
RelationFindDeletedTupleInfoByIndex() skipped the tuples_equal() check
whenever the scan used the primary key or replica identity index,
assuming any match is exact. But a GiST index on a multirange is
lossy: two multiranges with the same bounding range, like {[1,5)} and
{[1,2),[3,5)}, look the same to the index. Now we recheck the
candidate whenever the scan sets xs_recheck, like
check_exclusion_or_unique_constraint() does. Btree and range-type GiST
indexes never set it, so they keep the fast path. When we do recheck,
we compare only the key columns, since those are all the search slot
has (and we only look up that bitmap if we need it).
The second function is used for conflict detection with
retain_dead_tuples. There the bug can't modify the wrong row, but it
can report update_deleted (blaming the transaction that deleted an
unrelated row) instead of update_missing.[1]
The patch adds a TAP test to 034_temporal.pl using two multiranges
with the same bounding range.
[0] https://www.postgresql.org/message-id/kcyaok346iwocfdourf2oojgtz7ggxmh2ugis7qqhggs4qfzc2%40cu6pkox4rfwp
[1] https://www.postgresql.org/message-id/e5nb5jbus2oa3pffmlo7pdvdckmchd54tqld4k3n6huyg5xxqn%407rounyvufjx6
Yours,
--
Paul ~{:-)
pj@illuminatedcomputing.com
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
Nisha Moond <nisha.moond412@gmail.com>
Дата:
On Fri, Oct 9, 2026 at 9:50 AM Paul A Jungwirth
wrote:
>
> Hi Hackers,
>
> Andres reported that a WITHOUT OVERLAPS replica identity using
> multiranges can update/delete the wrong row, because a recheck is
> needed.[0] This patch fixes that problem by performing a recheck when
> the scan indicates one is needed.
>
> RelationFindReplTupleByIndex() and
> RelationFindDeletedTupleInfoByIndex() skipped the tuples_equal() check
> whenever the scan used the primary key or replica identity index,
> assuming any match is exact. But a GiST index on a multirange is
> lossy: two multiranges with the same bounding range, like {[1,5)} and
> {[1,2),[3,5)}, look the same to the index. Now we recheck the
> candidate whenever the scan sets xs_recheck, like
> check_exclusion_or_unique_constraint() does. Btree and range-type GiST
> indexes never set it, so they keep the fast path. When we do recheck,
> we compare only the key columns, since those are all the search slot
> has (and we only look up that bitmap if we need it).
>
> The second function is used for conflict detection with
> retain_dead_tuples. There the bug can't modify the wrong row, but it
> can report update_deleted (blaming the transaction that deleted an
> unrelated row) instead of update_missing.[1]
>
> The patch adds a TAP test to 034_temporal.pl using two multiranges
> with the same bounding range.
>
Hi Paul,
Thanks for the patch. I reviewed v1 and tested it manually. I was able
to reproduce both the wrong-row update/delete and the update_deleted
misreport (update_deleted reported instead of update_missing with
retain_dead_tuples) using a multirange key, and the patch fixes both.
I didn't find any critical issues. Just a few small suggestions:
1) The change to RelationFindDeletedTupleInfoByIndex() doesn't seem to
be covered by a test. Maybe we could add a case to 035_conflicts.pl?
2) The header comment of RelationFindReplTupleByIndex() needs an
update. It still says:
* 'skipduplicates' specifies whether the first matching tuple can be used
* without comparing it against 'searchslot'.
-- This no longer holds when the index scan requires a recheck.
3) The commit message could also mention the update_deleted vs.
update_missing impact, and that this patch fixes it.
--
Thanks,
Nisha
Re: Fix WITHOUT OVERLAPS multirange with location replication
On Fri, Oct 9, 2026, Nisha Moond wrote:
>
> Thanks for the patch. I reviewed v1 and tested it manually. I was able
> to reproduce both the wrong-row update/delete and the update_deleted
> misreport (update_deleted reported instead of update_missing with
> retain_dead_tuples) using a multirange key, and the patch fixes both.
Thanks for the review!
> 1) The change to RelationFindDeletedTupleInfoByIndex() doesn't seem to
> be covered by a test. Maybe we could add a case to 035_conflicts.pl?
This was tricky, but I figured out a way to do it. My test adds a row
on the publisher before creating the subscription, then uses
copy_data=false. Then I add & delete a "decoy" row with a different
multirange but the same lossy bounding range. When the publisher
updates the first row, it gets update_deleted before the fix and
update_missing after.
> 2) The header comment of RelationFindReplTupleByIndex() needs an
> update. It still says:
>
> * 'skipduplicates' specifies whether the first matching tuple can be used
> * without comparing it against 'searchslot'.
> -- This no longer holds when the index scan requires a recheck.
Done.
> 3) The commit message could also mention the update_deleted vs.
> update_missing impact, and that this patch fixes it.
Done.
v2 attached, rebased on current master.
Yours,
--
Paul ~{:-)
pj@illuminatedcomputing.com
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
kedar anavardekar <kedar.anavardekar@gmail.com>
Дата:
> v2 attached, rebased on current master. Hi Paul, Thank you for the patches. I tested v2-0001 and have two results and one question. 1. Lossy REPLICA IDENTITY index (034_temporal.pl scenario) I used a multirange WITHOUT OVERLAPS identity index with two rows whose bounding ranges are the same. Without the patch, the apply worker reports conflict=update_exists. With the patch, it reports conflict=conflict=update_origin_differs. 2. update_missing vs update_deleted (035_conflicts.pl scenario) Without the patch, the conflict is reported as update_deleted. With the patch, it is reported as update_missing. That matches what the test expects. t/034_temporal.pl and t/035_conflicts.pl both pass for me. Question about RelationFindReplTupleByIndex() The scan uses the idxoid passed in. The recheck bitmap comes from RelationGetIndexAttrBitmap(rel, ...), which describes the relation's currently configured identity or PK index. This might not be the index that was scanned. worker.c (around line 3250) mentions that a concurrent index update can change the index's validity or identity while the worker still holds a cached index OID. If that happens, the bitmap may no longer describe the scanned index. The recheck would then compare unrelated columns, or all columns if no bitmap is available. The incoming old-key tuple doesn't necessarily contain those other values. The real candidate could then be rejected, which would give a missing-row result or the wrong conflict classification. The same applies to RelationFindDeletedTupleInfoByIndex(). I haven't reproduced this concurrency case yet. as much as I have tried, ordinary DDL is not triggering it for a GiST WITHOUT OVERLAPS index. Would it make sense to build the recheck bitmap from the scanned index's own key columns (idxrel->rd_index->indkey, up to indnkeyatts)? That would remove the dependency on the relation's current identity. Or do you think the current approach is safe for a reason I'm missing? Thanks, Kedar
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Fri, Oct 9, 2026 at 4:55 PM Paul A Jungwirth wrote: > > On Fri, Oct 9, 2026, Nisha Moond wrote: > > > > > 1) The change to RelationFindDeletedTupleInfoByIndex() doesn't seem to > > be covered by a test. Maybe we could add a case to 035_conflicts.pl? > > This was tricky, but I figured out a way to do it. My test adds a row > on the publisher before creating the subscription, then uses > copy_data=false. Then I add & delete a "decoy" row with a different > multirange but the same lossy bounding range. When the publisher > updates the first row, it gets update_deleted before the fix and > update_missing after. > I think this test is timing dependent because if Delete happens before Update, the conflict slot could be updated and the row could be removed. If it is too tricky/tough to write this test, we can even skip it. -- With Regards, Amit Kapila.
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Sat, Oct 10, 2026 at 9:31 PM kedar anavardekar wrote: > > > v2 attached, rebased on current master. > > Hi Paul, > Thank you for the patches. > I tested v2-0001 and have two results and one question. > > 1. Lossy REPLICA IDENTITY index (034_temporal.pl scenario) > I used a multirange WITHOUT OVERLAPS identity index with two rows > whose bounding ranges are the same. > > Without the patch, the apply worker reports conflict=update_exists. > With the patch, it reports conflict=conflict=update_origin_differs. > > 2. update_missing vs update_deleted (035_conflicts.pl scenario) > > Without the patch, the conflict is reported as update_deleted. > With the patch, it is reported as update_missing. > That matches what the test expects. t/034_temporal.pl and > t/035_conflicts.pl both pass for me. > > Question about RelationFindReplTupleByIndex() > The scan uses the idxoid passed in. The recheck bitmap comes from > RelationGetIndexAttrBitmap(rel, ...), which describes the relation's > currently configured identity or PK index. This might not be the index > that was scanned. > > worker.c (around line 3250) mentions that a concurrent index update > can change the index's validity or identity while the worker still > holds a cached index OID. If that happens, the bitmap may no longer > describe the scanned index. The recheck would then compare unrelated > columns, or all columns if no bitmap is available. The incoming > old-key tuple doesn't necessarily contain those other values. The real > candidate could then be rejected, which would give a missing-row > result or the wrong conflict classification. The same applies to > RelationFindDeletedTupleInfoByIndex(). > > I haven't reproduced this concurrency case yet. as much as I have > tried, ordinary DDL is not triggering it for a GiST WITHOUT OVERLAPS > index. > > Would it make sense to build the recheck bitmap from the scanned > index's own key columns (idxrel->rd_index->indkey, up to indnkeyatts)? > That would remove the dependency on the relation's current identity. > Or do you think the current approach is safe for a reason I'm missing? > IIUC, the current approach is safe because concurrent operations won't change index columns. Having said that, I think your suggested approach sounds more robust. Additionally, I think we can build the bitmap inside (if (eq == NULL)) check to avoid building it again and again for each tuple scan. -- With Regards, Amit Kapila.
Re: Fix WITHOUT OVERLAPS multirange with location replication
Hi, On Sun, Oct 11, 2026 at 1:51 PM Amit Kapila wrote: > > On Sat, Oct 10, 2026 at 9:31 PM kedar anavardekar > wrote: > > > > > v2 attached, rebased on current master. > > > > Would it make sense to build the recheck bitmap from the scanned > > index's own key columns (idxrel->rd_index->indkey, up to indnkeyatts)? > > That would remove the dependency on the relation's current identity. > > Or do you think the current approach is safe for a reason I'm missing? > > > > IIUC, the current approach is safe because concurrent operations won't > change index columns. Having said that, I think your suggested > approach sounds more robust. Additionally, I think we can build the > bitmap inside (if (eq == NULL)) check to avoid building it again and > again for each tuple scan. I think that instead of building a bitmap and passing it to tuples_equal(), we can write a new helper function that directly traverses the index columns in the slot and compares each of them, similar to what identity_key_equal() does in pg_repack. I think that's a more standard approach, because we can use the index's opclass equality function and collation for the comparison rather than reusing the table attributes'. It is also more efficient, since it avoids building a new bitmap and avoids the typecache lookup. It may not show a performance difference, but I feel it's worth doing better in a common code path (update/delete replay) like this one. And based on the above, testing further, I realized this can fix a real issue: when the index's operator class and collation differ from the table's default ones, the patch's code (and the code on HEAD) uses the table's pg_attribute collation to compare the tuple, which is inconsistent with the index's. For the WITHOUT OVERLAPS index, we need to create a new extension with a new operator class to reproduce the issue (I did not find a way to use WITHOUT OVERLAPS together with a index specific collation, otherwise setting a different index collation can also reproduce it); see 0003 (generated with AI assistance), which reproduces it that way (it fails with v2 and passes with v3). I don't think we should commit this heavy test patch, so I'm just sharing it for reference. The same issue exists on HEAD as well for the update_deleted detection code path. I tried writing a patch to replace the update_deleted code path first in 0001 (since it's an existing issue, I've kept it in a separate patch for now to make it easier to review; we can merge the two patches and commit them together later if we agree). 0001 includes a test for the collation inconsistency issue. And I rebased the WITHOUT OVERLAPS fix on top of it, modifying it to use the new approach for tuple comparison and slightly adjusting some commit messages and comments. I'm sharing both patches here since both touch the same code path and overlap. Hope it helps move the thread forward. Best Regards, Zhijie Hou
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
kedar anavardekar <kedar.anavardekar@gmail.com>
Дата:
Hi Zhijie Hou, Thank you for the patches, I built and tested the patches locally, and they work as expected. > I think that instead of building a bitmap and passing it to tuples_equal(), we > can write a new helper function that directly traverses the index columns in > the slot and compares each of them, similar to what identity_key_equal() does > in pg_repack. I think that's a more standard approach, because we can use the > index's opclass equality function and collation for the comparison rather than > reusing the table attributes'. It is also more efficient, since it avoids > building a new bitmap and avoids the typecache lookup. It may not show a > performance difference, but I feel it's worth doing better in a common code > path (update/delete replay) like this one. +1 > The same issue exists on HEAD as well for the update_deleted detection code > path. I tried writing a patch to replace the update_deleted code path first in > 0001 (since it's an existing issue, I've kept it in a separate patch for now to > make it easier to review; we can merge the two patches and commit them together > later if we agree). 0001 includes a test for the collation inconsistency issue. > > And I rebased the WITHOUT OVERLAPS fix on top of it, modifying it to use the > new approach for tuple comparison and slightly adjusting some commit messages > and comments. > > I'm sharing both patches here since both touch the same code path > and overlap. Hope it helps move the thread forward. v30001 +v30002 LGTM.
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Sun, Oct 11, 2026 at 8:58 PM Zhijie Hou wrote: > > On Sun, Oct 11, 2026 at 1:51 PM Amit Kapila wrote: > > > > On Sat, Oct 10, 2026 at 9:31 PM kedar anavardekar > > wrote: > > > > > > > v2 attached, rebased on current master. > > > > > > Would it make sense to build the recheck bitmap from the scanned > > > index's own key columns (idxrel->rd_index->indkey, up to indnkeyatts)? > > > That would remove the dependency on the relation's current identity. > > > Or do you think the current approach is safe for a reason I'm missing? > > > > > > > IIUC, the current approach is safe because concurrent operations won't > > change index columns. Having said that, I think your suggested > > approach sounds more robust. Additionally, I think we can build the > > bitmap inside (if (eq == NULL)) check to avoid building it again and > > again for each tuple scan. > > I think that instead of building a bitmap and passing it to tuples_equal(), we > can write a new helper function that directly traverses the index columns in > the slot and compares each of them, similar to what identity_key_equal() does > in pg_repack. I think that's a more standard approach, because we can use the > index's opclass equality function and collation for the comparison rather than > reusing the table attributes'. It is also more efficient, since it avoids > building a new bitmap and avoids the typecache lookup. It may not show a > performance difference, but I feel it's worth doing better in a common code > path (update/delete replay) like this one. > About 0001 patch: The index is created after the conflict detection +# slot's xmin is pinned, so the sequential scan is used; the locally deleted +# row 'ABC' must still be reported as update_deleted for the publisher's key +# 'abc', exactly as if the index had been used. It is not clear to me why here the behaviour should be similar to index scan? As index is created after the slot is pinned, so isn't it okay to behave as there is no index at all? I see the point that for live tuples scan we may have used index but for conflicts as the index could be created after the tuple we are searching is deleted, we are doing sequence scan and comparing just indexed columns and that could be seen as inconsistent. As this is sort of a grey area and we are not sure whether to change the code or not, I feel we can fix Paul's reported issue now as that is a clear bug. -- With Regards, Amit Kapila.
Re: Fix WITHOUT OVERLAPS multirange with location replication
Hi, On Mon, Oct 12, 2026 at 10:29 PM Amit Kapila wrote: > > On Sun, Oct 11, 2026 at 8:58 PM Zhijie Hou wrote: > > > > I think that instead of building a bitmap and passing it to tuples_equal(), we > > can write a new helper function that directly traverses the index columns in > > the slot and compares each of them, similar to what identity_key_equal() does > > in pg_repack. I think that's a more standard approach, because we can use the > > index's opclass equality function and collation for the comparison rather than > > reusing the table attributes'. It is also more efficient, since it avoids > > building a new bitmap and avoids the typecache lookup. It may not show a > > performance difference, but I feel it's worth doing better in a common code > > path (update/delete replay) like this one. > > About 0001 patch: > The index is created after the conflict detection > +# slot's xmin is pinned, so the sequential scan is used; the locally deleted > +# row 'ABC' must still be reported as update_deleted for the publisher's key > +# 'abc', exactly as if the index had been used. > > It is not clear to me why here the behaviour should be similar to > index scan? As index is created after the slot is pinned, so isn't it > okay to behave as there is no index at all? I see the point that for > live tuples scan we may have used index but for conflicts as the index > could be created after the tuple we are searching is deleted, we are > doing sequence scan and comparing just indexed columns and that could > be seen as inconsistent. As this is sort of a grey area and we are not > sure whether to change the code or not, I feel we can fix Paul's > reported issue now as that is a clear bug. Agreed. We can fix the reported issue for now. I'm attaching a merged patch that uses the index comparison approach to fix only the reported issue here. I also improved the test for the update_deleted detection code path to hold slot.xmin stable, and removed some unnecessary instance creation/deletion to make it lighter. Please see the updated patch. Best Regards, Zhijie Hou
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
Paul A Jungwirth <pj@illuminatedcomputing.com>
Дата:
On Mon, Oct 12, 2026 at 7:50 AM Zhijie Hou wrote:
>
> Agreed. We can fix the reported issue for now. I'm attaching a merged patch
> that uses the index comparison approach to fix only the reported issue here. I
> also improved the test for the update_deleted detection code path to hold
> slot.xmin stable, and removed some unnecessary instance creation/deletion to
> make it lighter. Please see the updated patch.
This v4 looks good to me. Thank you for helping with this! Maybe one
minor change:
src/test/subscription/t/035_conflicts.pl
+# Publisher table holding the row that will be updated.
+$node_B->safe_psql(
+ 'postgres', "
+ CREATE TABLE tab_mr (id int4multirange, valid_at daterange, v int);
+ ALTER TABLE tab_mr REPLICA IDENTITY FULL;
+ INSERT INTO tab_mr VALUES ('{[1,5)}', '[2000-01-01,2010-01-01)', 1);
+ ALTER PUBLICATION tap_pub_B ADD TABLE tab_mr;
+");
If we say PRIMARY KEY (id, valid_at WITHOUT OVERLAPS) then we don't
need REPLICA IDENTITY FULL.
Yours,
--
Paul ~{:-)
pj@illuminatedcomputing.com
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
kedar anavardekar <kedar.anavardekar@gmail.com>
Дата:
> This v4 looks good to me. Thank you for helping with this! Maybe one > minor change: +1 I couldn't find the CF entry for this, could you please point me to it?
Re: Fix WITHOUT OVERLAPS multirange with location replication
On Tue, Oct 13, 2026 at 5:37 AM Paul A Jungwirth
wrote:
>
> This v4 looks good to me. Thank you for helping with this! Maybe one
> minor change:
>
> src/test/subscription/t/035_conflicts.pl
> +# Publisher table holding the row that will be updated.
> +$node_B->safe_psql(
> + 'postgres', "
> + CREATE TABLE tab_mr (id int4multirange, valid_at daterange, v int);
> + ALTER TABLE tab_mr REPLICA IDENTITY FULL;
> + INSERT INTO tab_mr VALUES ('{[1,5)}', '[2000-01-01,2010-01-01)', 1);
> + ALTER PUBLICATION tap_pub_B ADD TABLE tab_mr;
> +");
>
> If we say PRIMARY KEY (id, valid_at WITHOUT OVERLAPS) then we don't
> need REPLICA IDENTITY FULL.
>
Yeah, but keeping RI FULL also doesn't harm; rather it tests something
extra which is that it can extract required values from the full
tuple. So, I am okay either way. I have modified the comments at
multiple places in the patch as I find there is a lot of redundancy in
the comments. See attached top-up patch. BTW, we need a separate patch
for v18 as well.
--
With Regards,
Amit Kapila.
Re: Fix WITHOUT OVERLAPS multirange with location replication
Hi,
On Tue, Oct 13, 2026 at 7:21 PM Amit Kapila wrote:
>
> On Tue, Oct 13, 2026 at 5:37 AM Paul A Jungwirth
> wrote:
> >
> > This v4 looks good to me. Thank you for helping with this! Maybe one
> > minor change:
> >
> > src/test/subscription/t/035_conflicts.pl
> > +# Publisher table holding the row that will be updated.
> > +$node_B->safe_psql(
> > + 'postgres', "
> > + CREATE TABLE tab_mr (id int4multirange, valid_at daterange, v int);
> > + ALTER TABLE tab_mr REPLICA IDENTITY FULL;
> > + INSERT INTO tab_mr VALUES ('{[1,5)}', '[2000-01-01,2010-01-01)', 1);
> > + ALTER PUBLICATION tap_pub_B ADD TABLE tab_mr;
> > +");
> >
> > If we say PRIMARY KEY (id, valid_at WITHOUT OVERLAPS) then we don't
> > need REPLICA IDENTITY FULL.
> >
>
> Yeah, but keeping RI FULL also doesn't harm; rather it tests something
> extra which is that it can extract required values from the full
> tuple. So, I am okay either way. I have modified the comments at
> multiple places in the patch as I find there is a lot of redundancy in
> the comments. See attached top-up patch. BTW, we need a separate patch
> for v18 as well.
Thanks for the diff. I have merged and prepared the patches for
back branches as well.
Best Regards,
Zhijie Hou
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
Paul A Jungwirth <pj@illuminatedcomputing.com>
Дата:
On Mon, Oct 12, 2026 at 10:38 PM kedar anavardekar
wrote:
>
> > This v4 looks good to me. Thank you for helping with this! Maybe one
> > minor change:
> +1
> I couldn't find the CF entry for this, could you please point me to it?
I just created it: https://commitfest.postgresql.org/patch/7463/
I asked at [0] whether these bugs should be pg19 Open Items instead
(especially that one), but since I didn't hear back I'll create CF
entries for the rest too.
[0] https://www.postgresql.org/message-id/CA%2BrenyUy%3D%2BoZoOg0qN_wAHTL3MwVEnp4zdfX%2BBu54foz6OXpQw%40mail.gmail.com
Yours,
--
Paul ~{:-)
pj@illuminatedcomputing.com
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
Paul A Jungwirth <pj@illuminatedcomputing.com>
Дата:
On Tue, Oct 13, 2026 at 5:16 AM Zhijie Hou wrote:
>
> > Yeah, but keeping RI FULL also doesn't harm; rather it tests something
> > extra which is that it can extract required values from the full
> > tuple. So, I am okay either way. I have modified the comments at
> > multiple places in the patch as I find there is a lot of redundancy in
> > the comments. See attached top-up patch. BTW, we need a separate patch
> > for v18 as well.
>
> Thanks for the diff. I have merged and prepared the patches for
> back branches as well.
Thanks! These all apply and look good to me. I'll mark the CF entry as
Ready for Committer.
Yours,
--
Paul ~{:-)
pj@illuminatedcomputing.com
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
Nisha Moond <nisha.moond412@gmail.com>
Дата:
On Tue, Oct 13, 2026 at 5:46 PM Zhijie Hou wrote:
>
> Hi,
>
> On Tue, Oct 13, 2026 at 7:21 PM Amit Kapila wrote:
> >
> > On Tue, Oct 13, 2026 at 5:37 AM Paul A Jungwirth
> > wrote:
> > >
> > > This v4 looks good to me. Thank you for helping with this! Maybe one
> > > minor change:
> > >
> > > src/test/subscription/t/035_conflicts.pl
> > > +# Publisher table holding the row that will be updated.
> > > +$node_B->safe_psql(
> > > + 'postgres', "
> > > + CREATE TABLE tab_mr (id int4multirange, valid_at daterange, v int);
> > > + ALTER TABLE tab_mr REPLICA IDENTITY FULL;
> > > + INSERT INTO tab_mr VALUES ('{[1,5)}', '[2000-01-01,2010-01-01)', 1);
> > > + ALTER PUBLICATION tap_pub_B ADD TABLE tab_mr;
> > > +");
> > >
> > > If we say PRIMARY KEY (id, valid_at WITHOUT OVERLAPS) then we don't
> > > need REPLICA IDENTITY FULL.
> > >
> >
> > Yeah, but keeping RI FULL also doesn't harm; rather it tests something
> > extra which is that it can extract required values from the full
> > tuple. So, I am okay either way. I have modified the comments at
> > multiple places in the patch as I find there is a lot of redundancy in
> > the comments. See attached top-up patch. BTW, we need a separate patch
> > for v18 as well.
>
> Thanks for the diff. I have merged and prepared the patches for
> back branches as well.
>
Thanks for updated patches. The fix looks good to me. A few comments:
1) v5_PG18-0001: the commit message mentions
RelationFindDeletedTupleInfoByIndex() and the update_deleted vs
update_missing case, but it doesn't apply to PG18. Maybe that part
could be dropped.
A couple of nits, please consider if they make sense:
2) The updated header comment of RelationFindReplTupleByIndex() reads
a bit confusing to me, how about something like:
* 'skipduplicates' specifies whether the first matching tuple can be used
* without comparing it against 'searchslot', unless the index scan sets
* xs_recheck (as with a lossy GiST index for WITHOUT OVERLAPS), in which case
* only the index key columns are compared, using the index's own equality
* semantics. If false, all matching tuples are compared against 'searchslot',
* which must contain a complete row.
3) 035_conflicts.pl:
+ok( $node_A->poll_query_until(
+ 'postgres',
+ "SELECT xmin::text = '$pinned_xid' FROM
pg_replication_slots WHERE slot_name 'pg_conflict_detection'"
+ ),
Should we use "xmin::text::bigint = $pinned_xid" here, to match the
other slot xmin checks in the same file?
--
Thanks,
Nisha
Re: Fix WITHOUT OVERLAPS multirange with location replication
Hi, On Fri, Oct 16, 2026 at 2:57 PM Nisha Moond wrote: > > Thanks for updated patches. The fix looks good to me. A few comments: > > 1) v5_PG18-0001: the commit message mentions > RelationFindDeletedTupleInfoByIndex() and the update_deleted vs > update_missing case, but it doesn't apply to PG18. Maybe that part > could be dropped. Thanks for the comments. I added a general statement that update_delete changes only apply to PG19 for now. > > A couple of nits, please consider if they make sense: > > 2) The updated header comment of RelationFindReplTupleByIndex() reads > a bit confusing to me, how about something like: > > * 'skipduplicates' specifies whether the first matching tuple can be used > * without comparing it against 'searchslot', unless the index scan sets > * xs_recheck (as with a lossy GiST index for WITHOUT OVERLAPS), in which case > * only the index key columns are compared, using the index's own equality > * semantics. If false, all matching tuples are compared against 'searchslot', > * which must contain a complete row. Changed as suggested. > > 3) 035_conflicts.pl: > +ok( $node_A->poll_query_until( > + 'postgres', > + "SELECT xmin::text = '$pinned_xid' FROM > pg_replication_slots WHERE slot_name 'pg_conflict_detection'" > + ), > > Should we use "xmin::text::bigint = $pinned_xid" here, to match the > other slot xmin checks in the same file? I changed to xmin = $pinned_xid as equality does not need type conversion. Please see the updated patch set. Best Regards, Zhijie Hou
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
kedar anavardekar <kedar.anavardekar@gmail.com>
Дата:
> Please see the updated patch set. Thank you for the updates, I have tested the patches on the respective branches. The changes LGTM. I am able to apply the patches without conflict. But the cf bot suggests the patch needs a rebase.
Re: Fix WITHOUT OVERLAPS multirange with location replication
> I am able to apply the patches without conflict. But the cf bot > suggests the patch > needs a rebase. I think the cfbot is trying to apply the v18 patch on mater, I reproduced this locally and got the same error as cf bot merge records[1] I followed the naming convention as I have seen on [2] so that cfbot do not apply backport on master. I have attached the renamed patches for the same v6 version no updates in content. As I am new to the Postgres ecosystem, please suggest if there is another way to name the patches or to run the cfbot. 1: https://cfbot.cputube.org/patch_7463.log 2: https://www.postgresql.org/message-id/CALj2ACXtHqVRBb40OHXx1JAMnv-L%3D-PFU_nyk2aB%3D0wMgkpGOw%40mail.gmail.com
Re: Fix WITHOUT OVERLAPS multirange with location replication
От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Tue, Oct 20, 2026 at 8:23 AM kedar anavardekar wrote: > > I have attached the renamed patches for the same v6 version no updates > in content. > Thanks, I have pushed the attached patches. -- With Regards, Amit Kapila.