Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY - Mailing list pgsql-hackers

From Michail Nikolaev
Subject Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY
Date
Msg-id CANtu0oj4RgWKJi-id5enjB1AtkRuAg_x18uS6kwYaS5xeYLuCA@mail.gmail.com
Whole thread Raw
In response to Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY  (Michail Nikolaev <michail.nikolaev@gmail.com>)
Responses Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY
List pgsql-hackers
Hello.

> But I was unable to reproduce that using some random usleep(), however - maybe it is a wrong assumption.
It seems like the assumption is correct - we may use an invalid index as arbiter due to race condition.

The attached patch adds a check for that case, and now the test fails like this:

    # pgbench: error: client 16 script 1 aborted in command 1 query 0: ERROR:  duplicate key value violates unique constraint "tbl_pkey_ccold"
    # DETAIL:  Key (i)=(42) already exists.
    # pgbench: error: client 9 script 1 aborted in command 1 query 0: ERROR:  ON CONFLICT does not support invalid indexes as arbiters
    # pgbench: error: client 0 script 2 aborted in command 1 query 0: ERROR:  duplicate key value violates unique constraint "tbl_pkey"
    # DETAIL:  Key (i)=(69) already exists.
    # pgbench: error: client 7 script 0 aborted in command 1 query 0: ERROR:  ON CONFLICT does not support invalid indexes as arbiters
    # pgbench: error: client 10 script 0 aborted in command 1 query 0: ERROR:  ON CONFLICT does not support invalid indexes as arbiters
    # pgbench: error: client 11 script 0 aborted in command 1 query 0: ERROR:  ON CONFLICT does not support invalid indexes as arbiters

I think It is even possible to see !alive index in the same situation (it is worse case), but I was unable to reproduce it so far.

Best regards,
Mikhail.

Attachment

pgsql-hackers by date:

Previous
From: Kohei KaiGai
Date:
Subject: assertion failure at cost_memoize_rescan()
Next
From: Maxim Orlov
Date:
Subject: Bugfix and improvements in multixact.c