[BUG] failed assertion in EnsurePortalSnapshotExists()

Поиск
Список
Период
Сортировка
От Drouvot, Bertrand
Тема [BUG] failed assertion in EnsurePortalSnapshotExists()
Дата
Msg-id ff82b8c5-77f4-3fe7-6028-fcf3303e82dd@amazon.com
обсуждение исходный текст
Ответы Re: [BUG] failed assertion in EnsurePortalSnapshotExists()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi hackers,

I recently observed a failed assertion in EnsurePortalSnapshotExists().

The steps to reproduce the issue on the master branch are:

create table bdt (a int primary key);
insert into bdt values (1),(2);
create table bdt2 (a int);
insert into bdt2 values (1);

Then launching:

DO $$
BEGIN
   FOR i IN 1..2 LOOP
     BEGIN
       INSERT INTO bdt (a) VALUES (i);
        exception when unique_violation then update bdt2 set a = i;
      COMMIT;
     END;
   END LOOP;
END;
$$;

Would produce:

server closed the connection unexpectedly
         This probably means the server terminated abnormally
         before or while processing the request.
The connection to the server was lost

Due to:

#2  0x0000000000b2ffcb in ExceptionalCondition (conditionName=0xd0d598 
"portal->portalSnapshot == NULL", errorType=0xd0d0b3 "FailedAssertion", 
fileName=0xd0d174 "pquery.c", lineNumber=1785) at assert.c:69
#3  0x000000000099e666 in EnsurePortalSnapshotExists () at pquery.c:1785

 From what i have seen, we end up having ActiveSnapshot set to NULL in 
AtSubAbort_Snapshot() (while we still have ActivePortal->portalSnapshot 
not being NULL and not set to NULL later on).

That leads to ActiveSnapshotSet() not being true in the next call to 
EnsurePortalSnapshotExists() and leads to the failed assertion (checking 
that ActivePortal->portalSnapshot is NULL) later on in the code.

Based on this, i have created the attached patch (which fixes the issue 
mentioned in the repro) but I have the feeling that I may have missed 
something more important here (that would not be addressed with the 
attached patch), thoughts?

Thanks

Bertrand

Вложения

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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: when the startup process doesn't (logging startup delays)
Следующее
От: Robert Haas
Дата:
Сообщение: Re: when the startup process doesn't (logging startup delays)