pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feed"insert [...] on conflict" hangs on conflict on an unmentioned gist index
5+ messages / 3 participants
[nested] [flat]
* "insert [...] on conflict" hangs on conflict on an unmentioned gist index
@ 2016-07-04 12:10 Heikki Rauhala <heikki.rauhala@reaktor.fi>
0 siblings, 1 reply; 5+ messages in thread
From: Heikki Rauhala @ 2016-07-04 12:10 UTC (permalink / raw)
To: pgsql-bugs; +Cc: Miko Kiiski <miko.kiiski@reaktor.com>
Hi,
The last insert of the following statements causes a busy loop that does not complete:
create table gist_test (
bar text,
foo text,
constraint gist_test_bar_unique unique (bar),
constraint gist_test_foo_gist_unique exclude using gist (foo with =)
);
insert into gist_test (bar, foo) values ('bar', 'foo');
insert into gist_test (bar, foo) values ('baz', 'foo’) on conflict on constraint gist_test_bar_unique do nothing;
Expected behaviour is a conflict on the gist_test_foo_gist_unique -index.
The issue is present at least in the following PostgreSQL versions:
PostgreSQL 9.5.3 on x86_64-apple-darwin15.4.0, compiled by Apple LLVM version 7.3.0 (clang-703.0.31), 64-bit
PostgreSQL 9.5.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16), 64-bit
Best regards,
- Heikki Rauhala.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: "insert [...] on conflict" hangs on conflict on an unmentioned gist index
@ 2016-07-04 15:00 Tom Lane <tgl@sss.pgh.pa.us>
parent: Heikki Rauhala <heikki.rauhala@reaktor.fi>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2016-07-04 15:00 UTC (permalink / raw)
To: Peter Geoghegan <pg@heroku.com>; +Cc: pgsql-bugs@postgresql.org, Miko Kiiski <miko.kiiski@reaktor.com>; Heikki Rauhala <heikki.rauhala@reaktor.fi>
Heikki Rauhala <heikki.rauhala@reaktor.fi> writes:
> The last insert of the following statements causes a busy loop that does not complete:
> create table gist_test (
> bar text,
> foo text,
> constraint gist_test_bar_unique unique (bar),
> constraint gist_test_foo_gist_unique exclude using gist (foo with =)
> );
> insert into gist_test (bar, foo) values ('bar', 'foo');
> insert into gist_test (bar, foo) values ('baz', 'foo’) on conflict on constraint gist_test_bar_unique do nothing;
It looks to me like the ON CONFLICT code has exactly zero chance of
working with non-btree (or more generally, non-amcanunique) indexes.
Was this case ever considered during development?
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: "insert [...] on conflict" hangs on conflict on an unmentioned gist index
@ 2016-07-04 16:38 Tom Lane <tgl@sss.pgh.pa.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2016-07-04 16:38 UTC (permalink / raw)
To: Peter Geoghegan <pg@heroku.com>; +Cc: pgsql-bugs@postgresql.org, Miko Kiiski <miko.kiiski@reaktor.com>; Heikki Rauhala <heikki.rauhala@reaktor.fi>
I wrote:
> It looks to me like the ON CONFLICT code has exactly zero chance of
> working with non-btree (or more generally, non-amcanunique) indexes.
Nah, I take that back --- I was expecting this to be handled somewhere
else than it is. It looks like the actual cause is just sloppy
handling of noDupErr in ExecInsertIndexTuples; the attached fixes it
for me.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
fix-non-arbiter-exclusion-index.patch (text/x-diff, 647B) download
diff --git a/src/backend/executor/execIndexing.c b/src/backend/executor/execIndexing.c
index c819d19..e73bad3 100644
*** a/src/backend/executor/execIndexing.c
--- b/src/backend/executor/execIndexing.c
*************** ExecInsertIndexTuples(TupleTableSlot *sl
*** 407,413 ****
bool violationOK;
CEOUC_WAIT_MODE waitMode;
! if (noDupErr)
{
violationOK = true;
waitMode = CEOUC_LIVELOCK_PREVENTING_WAIT;
--- 407,413 ----
bool violationOK;
CEOUC_WAIT_MODE waitMode;
! if (noDupErr && (arbiterIndexes == NIL || arbiter))
{
violationOK = true;
waitMode = CEOUC_LIVELOCK_PREVENTING_WAIT;
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: "insert [...] on conflict" hangs on conflict on an unmentioned gist index
@ 2016-07-04 17:35 Peter Geoghegan <pg@heroku.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: Peter Geoghegan @ 2016-07-04 17:35 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs; Miko Kiiski <miko.kiiski@reaktor.com>; Heikki Rauhala <heikki.rauhala@reaktor.fi>
On Mon, Jul 4, 2016 at 9:38 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Nah, I take that back --- I was expecting this to be handled somewhere
> else than it is. It looks like the actual cause is just sloppy
> handling of noDupErr in ExecInsertIndexTuples; the attached fixes it
> for me.
I agree that that's all this was; it's uncommon to specify an
exclusion constraint by name with DO NOTHING, so we didn't catch this
until now.
Thanks for looking into this.
--
Peter Geoghegan
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: "insert [...] on conflict" hangs on conflict on an unmentioned gist index
@ 2016-07-05 11:44 Heikki Rauhala <heikki.rauhala@reaktor.fi>
parent: Peter Geoghegan <pg@heroku.com>
0 siblings, 0 replies; 5+ messages in thread
From: Heikki Rauhala @ 2016-07-05 11:44 UTC (permalink / raw)
To: Peter Geoghegan <pg@heroku.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs; Miko Kiiski <miko.kiiski@reaktor.com>
> On 4.7.2016, at 20:35, Peter Geoghegan <pg@heroku.com> wrote:
>
> On Mon, Jul 4, 2016 at 9:38 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Nah, I take that back --- I was expecting this to be handled somewhere
>> else than it is. It looks like the actual cause is just sloppy
>> handling of noDupErr in ExecInsertIndexTuples; the attached fixes it
>> for me.
>
> I agree that that's all this was; it's uncommon to specify an
> exclusion constraint by name with DO NOTHING, so we didn't catch this
> until now.
Thanks for the quick response! I tested the patch with the more complex query that initially brought this up, which is more like:
insert into gist_test (bar, foo) values ('baz', 'foo')
on conflict on constraint gist_test_bar_unique
do update set foo = excluded.foo;
The patch works as expected also for that case.
Best regards,
- Heikki.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2016-07-05 11:44 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-07-04 12:10 "insert [...] on conflict" hangs on conflict on an unmentioned gist index Heikki Rauhala <heikki.rauhala@reaktor.fi>
2016-07-04 15:00 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-07-04 16:38 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-07-04 17:35 ` Peter Geoghegan <pg@heroku.com>
2016-07-05 11:44 ` Heikki Rauhala <heikki.rauhala@reaktor.fi>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox