Skip site navigation (1) Skip section navigation (2)

Assertion failure in AtCleanup_Portals

From: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Assertion failure in AtCleanup_Portals
Date: 2012-02-03 15:30:14
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
If I run the following sequence of commands, I get an assertion
failure in current HEAD.

postgres=# BEGIN;
postgres=# SELECT 1/0;
ERROR:  division by zero
postgres=# ROLLBACK TO A;
ERROR:  no such savepoint
postgres=# \q

The process fails when the session is closed and aborted transaction
gets cleaned at the proc_exit time. The stack trace is as below.

(gdb) bt
#0  0x00c16422 in __kernel_vsyscall ()
#1  0x00244651 in *__GI_raise (sig=6) at
#2  0x00247a82 in *__GI_abort () at abort.c:92
#3  0x0844b800 in ExceptionalCondition (conditionName=0x86161e8
"!(portal->cleanup == ((void *)0))", errorType=0x8615e94
    fileName=0x8615e88 "portalmem.c", lineNumber=793) at assert.c:57
#4  0x08472a5a in AtCleanup_Portals () at portalmem.c:793
#5  0x080f2535 in CleanupTransaction () at xact.c:2373
#6  0x080f40d7 in AbortOutOfAnyTransaction () at xact.c:3855
#7  0x0845cc5e in ShutdownPostgres (code=0, arg=0) at postinit.c:966
#8  0x08332ba7 in shmem_exit (code=0) at ipc.c:221
#9  0x08332ab3 in proc_exit_prepare (code=0) at ipc.c:181
#10 0x08332a15 in proc_exit (code=0) at ipc.c:96
#11 0x0835b07c in PostgresMain (argc=2, argv=0xa12fa64,
username=0xa12f958 "pavan") at postgres.c:4091

I analyzed this a bit. It seems that the first statement throws an
error, runs AbortCurrentTransaction and puts the transaction block in
TBLOCK_ABORT state. Any commands executed after this would usually
fail with error "current transaction is aborted". But the ROLLBACK TO
gets past this check because IsTransactionExitStmt() returns success
(and rightly so). So we end up creating a portal to run the ROLLBACK
TO command. This command fails because the SAVEPOINT A does not exist
and we throw an error. But since the transaction block is already in
TBLOCK_ABORT state, the AbortCurrentTransaction doesn't do any work.
The cleanup routine for the portal remains unexecuted. Later when the
backend exits and cleanup routines are called, the assertion inside
AtCleanup_Portals fails.

I am not sure what is the right fix for this. I see Tom fixed a
similar complain sometime back.

But may its not enough to cover all code paths, as demonstrated by this example.


Pavan Deolasee


pgsql-hackers by date

Next:From: Joachim WielandDate: 2012-02-03 15:43:17
Subject: Re: patch for parallel pg_dump
Previous:From: Robert HaasDate: 2012-02-03 15:28:05
Subject: Re: Should I implement DROP INDEX CONCURRENTLY?

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group