BUG #8095: postgres acquiring lock on a table when not in transaction - Mailing list pgsql-bugs

From vaiayand@gmail.com
Subject BUG #8095: postgres acquiring lock on a table when not in transaction
Date
Msg-id E1USzaZ-00011S-JL@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #8095: postgres acquiring lock on a table when not in transaction  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: BUG #8095: postgres acquiring lock on a table when not in transaction  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      8095
Logged by:          Nachiket Vaidya
Email address:      vaiayand@gmail.com
PostgreSQL version: 9.2.4
Operating system:   ubuntu
Description:        =


Issue:
------
We investigated one issue and found the following:
postgres is acquiring a lock on table when not in trancation during prepared
ROLLBACK statement. It is releasing the acquired lock at end.
but postgres should not get lock on a table when not in transaction. After
acquiring any lock, if backend process dies (say SIGTERM signal), the
postgres will be in lock-not-released state.

Steps to reproduce:
-------------------
1. configure with
export CFLAGS=3D"-DCLOBBER_CACHE_ALWAYS -DRELCACHE_FORCE_RELEASE -g ";
./configure --prefix=3D..
// forcing to release to system cache.

2. make and make install

3. compile prepare.c (attached)

4. Run server.

5. Run binary of prepare.c and grab pid of backend (it will be printed as
output of binary).

6. Attach gdb for backend gdb -p <pid>.

7. Put the break on exec_parse_message().

8. After break point got reached, put break on LockRelease().

9. After break point got reached for LockRelease(), send signal 15 (SIGTERM)
through gdb (signal 15).

// In steps 7-9, we make sure that we send signal SIGTERM to process after
lock acquire before lock release.

10. continue till process exits.

11. now run binary of prepare.c without attaching gdb (start psql client).
You will get the error at server:
-----------------------
LOG:  server process (PID 18314) was terminated by signal 11: Segmentation
fault
LOG:  terminating any other active server processes
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the
current transaction and exit, because another server process exited
abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and
repeat your command.
LOG:  all server processes terminated; reinitializing
LOG:  database system was interrupted; last known up at 2013-04-18 16:16:40
PDT
LOG:  database system was not properly shut down; automatic recovery in
progress
LOG:  record with zero length at 0/176B9B0
LOG:  redo is not required
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

on 8.4.17, I am getting an error:
--------------------------------
psql: FATAL:  lock AccessShareLock on object 11564/1259/0 is already held.

pgsql-bugs by date:

Previous
From: bmohareb@gmail.com
Date:
Subject: BUG #8093: After starting postgres, any attempt to connect generate a core dump and unable to login
Next
From: visionsw@sltnet.lk
Date:
Subject: BUG #8096: unable to create language PLl/TCL