Re: BUG #17792: MERGE uses uninitialized pointer and crashes when target tuple is updated concurrently

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: BUG #17792: MERGE uses uninitialized pointer and crashes when target tuple is updated concurrently
Дата
Msg-id 20230214191937.sri5zsqqogpidmxp@alvherre.pgsql
обсуждение исходный текст
Ответ на Re: BUG #17792: MERGE uses uninitialized pointer and crashes when target tuple is updated concurrently  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Ответы Re: BUG #17792: MERGE uses uninitialized pointer and crashes when target tuple is updated concurrently
Список pgsql-bugs
On 2023-Feb-14, Dean Rasheed wrote:

> After trying to induce that, I realised that it doesn't appear to be
> possible, because a delete after a failed update will always succeed,
> because it has the target row locked by that point. So I think that it
> will never need to retry more than once.

Hmm, yeah, that makes sense.  Thanks for checking.

> That said, it seems wrong to be checking cpUpdateRetrySlot after an
> attempted delete anyway.

True.

> Perhaps a better fix would be to just change
> the check in ExecMergeMatched() to
> 
>     if (commandType == CMD_UPDATE && !TupIsNull(context->cpUpdateRetrySlot))
>         goto lmerge_matched;
> 
> and update the preceding comment, since only an update should set
> cpUpdateRetrySlot.

I agree, this looks to be a good fix.  However, I couldn't in a quick
try reproduce the problem, so I haven't been able to verify it.  I'll
try to do that early tomorrow.

(I also delete the XXX comment there.)

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end." (2nd Commandment for C programmers)

Вложения

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Francisco Olarte
Дата:
Сообщение: Re: BUG #17793: Query with large number of joins crashes PostgreSQL
Следующее
От: Andres Freund
Дата:
Сообщение: Re: BUG #17791: Assert on procarray.c