Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2025-02-20 Thread Міхаіл Нікалаеў
Hello! Just rebased. From 2db0af6a7b5ba485464ad5a59ce106a6e438d41a Mon Sep 17 00:00:00 2001 From: nkey Date: Thu, 20 Feb 2025 14:50:58 +0300 Subject: [PATCH v8 2/4] Modify the infer_arbiter_indexes function to consider both indisvalid and indisready indexes. Ensure that at least one indisvalid

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2025-01-18 Thread Michail Nikolaev
Hello, everyone! This is just small test refactoring after the last stabilization. Best regards, Mikhail. > v7-0001-Specs-top-reproduce-the-issues-with-CREATE-INDEX.patch Description: Binary data v7-0004-Modify-the-ExecInitPartitionInfo-function-to-cons.patch Description: Binary data v7-00

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2025-01-13 Thread Michail Nikolaev
Hello, everyone! I have noticed tests are still flapping a little bit on FreeBSD. Now I have added some markers to isolation specs to avoid possible race conditions. Best regards, Mikhail. > v6-0003-Modify-the-infer_arbiter_indexes-function-to-also.patch Description: Binary data v6-0001-Spec

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-11-28 Thread Michail Nikolaev
Hello, everyone! I've improved the test stability. The revised version should provide consistent results in all test runs. Best regards, Mikhail. > From e9a562587a509ace581d7ccf40eb41eb73b93b6f Mon Sep 17 00:00:00 2001 From: nkey Date: Sun, 24 Nov 2024 14:55:13 +0100 Subject: [PATCH v5 4/4] Mod

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-11-14 Thread Michail Nikolaev
Hello, everyone. Rebased on master. > From 9c85b499793e9a4bcbb55cc5d78cfeacab368b58 Mon Sep 17 00:00:00 2001 From: nkey Date: Thu, 14 Nov 2024 22:36:26 +0100 Subject: [PATCH v4 2/4] Modify the infer_arbiter_indexes function to consider both indisvalid and indisready indexes. Ensure that at lea

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-08-24 Thread Michail Nikolaev
Hello, everyone! This patch set addresses the issues discussed in this thread. The main idea behind this fix is that it is safe to consider indisready indexes alongside indisvalid indexes as arbiter indexes. However, it's crucial that at least one fully valid index is present. Why is it necessar

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-08-16 Thread Michail Nikolaev
Hello, everyone. I have updated the spec to reproduce the issue, now it includes cases with both CREATE INDEX and REINDEX. To run: make -C src/test/modules/injection_points/ check Issue reproduced on empty index, but it may happen on index of any with the same probability. It is not critic

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-08-07 Thread Michail Nikolaev
Hell, everyone! Using the brand-new injection points support in specs, I created a spec to reproduce the issue. It fails like this currently: make -C src/test/modules/injection_points/ check @@ -64,6 +64,7 @@ step s3_s1: <... completed> step s2_s1: <... completed> +ERROR: duplicate key valu

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-06-25 Thread Michail Nikolaev
Hello, Noah! Answering https://www.postgresql.org/message-id/flat/20240612194857.1c.nmisch%40google.com#684361ba86bad11f4e9fd84dfa8e0084 > On your other thread, it would be useful to see stack traces from the high-CPU > processes once the live lock has ended all query completion. I was wrong, it

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-06-25 Thread Michail Nikolaev
Hello, Michael! > As far as I can see, it depends on what kind of query semantics and > the amount of transparency you are looking for here in your > application. An error in the query itself can also be defined as > useful so as your application is aware of what happens as an effect of > the con

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-06-24 Thread Michael Paquier
On Fri, Jun 21, 2024 at 11:31:21AM +0200, Michail Nikolaev wrote: > Yes, I also have tried that approach, but it doesn't work, unfortunately. > You may fail test increasing number of connections: > > '--no-vacuum --client=10 -j 2 --transactions=1000', > > The source of the issue is not the swap o

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-06-24 Thread Michael Paquier
On Mon, Jun 17, 2024 at 07:00:51PM +0200, Michail Nikolaev wrote: > The same issue may happen in case of CREATE/DROP INDEX CONCURRENTLY as well. While looking at all that, I've been also curious about this specific point, and it is indeed possible to finish in a state where a duplicate key would b

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-06-21 Thread Michail Nikolaev
Hello, Michael! > This is a non-fresh Friday-afternoon idea, but it would make sure that > we don't have any transactions using the indexes switched to _ccold > with indisvalid that are waiting for a drop in phase 5. Your tests > seem to pass with that, and that keeps the operation intact > concu

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-06-20 Thread Michael Paquier
On Mon, Jun 17, 2024 at 07:00:51PM +0200, Michail Nikolaev wrote: > The simplest possible fix is to use ShareLock > instead ShareUpdateExclusiveLock in the index_concurrently_swap > > oldClassRel = relation_open(oldIndexId, ShareLock); > newClassRel = relation_open(newIndex

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-06-17 Thread Michail Nikolaev
Hello, everyone. > 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. Fortunately, it is not possible. So, seems like I have found the source of the problem: 1) infer_arbiter_indexes calls RelationGetIndexList to get

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-06-14 Thread Michail Nikolaev
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

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-06-14 Thread Michail Nikolaev
Hello, Michael. > Isn't the issue that we may select as arbiter indexes stuff that's !indisvalid? As far as I can see (1) !indisvalid indexes are filtered out. But... It looks like this choice is not locked in any way (2), so index_concurrently_swap or index_concurrently_set_dead can change this

Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-06-13 Thread Michael Paquier
On Tue, Jun 11, 2024 at 01:00:00PM +0200, Michail Nikolaev wrote: > Probably something wrong with arbiter index selection for different > backends. I am afraid it could be a symptom of a more serious issue. ON CONFLICT selects an index that may be rebuilt in parallel of the REINDEX happening, and

Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY

2024-06-11 Thread Michail Nikolaev
Hello, hackers. While testing my work on (1) I was struggling with addressing a strange issue with ON CONFLICT UPDATE and REINDEX CONCURRENTLY. After some time, I have realized the same issue persists on the master branch as well :) I have prepared two TAP tests to reproduce the issues (2), also