The following bug has been logged on the website:
Bug reference: 8059
Logged by: Tarvi Pillessaar
Email address: tarvip@gmail.com
PostgreSQL version: 9.2.4
Operating system: linux
Description: =
Very simple example:
postgres@sbox /usr/local/pgsql $ /usr/local/pgsql/bin/psql test
psql (9.2.4)
Type "help" for help.
test=3D# create sequence s;
CREATE SEQUENCE
test=3D# begin;
BEGIN
test=3D# select nextval('s');
nextval =
---------
1
(1 row)
Now let's crash the cluster:
postgres@sbox /usr/local/pgsql $ pgrep -lf writer
13638 postgres: writer process
13639 postgres: wal writer process
postgres@sbox /usr/local/pgsql $ kill -9 13638
postgres@sbox /usr/local/pgsql $ tail logfile =
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-12 14:28:26
EEST
LOG: database system was not properly shut down; automatic recovery in
progress
LOG: redo starts at 0/177C9E0
LOG: record with zero length at 0/1791888
LOG: redo done at 0/1791858
LOG: last completed transaction was at log time 2013-04-12
14:29:48.562356+03
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
postgres@sbox /usr/local/pgsql $ =
test=3D# select nextval('s');
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.
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. Attempting reset: Succeeded.
test=3D# select nextval('s');
nextval =
---------
1
(1 row)
test=3D# =
This problem occurs on the same conditions as described in commit
af026b5d9b8ae6ef4c75a796bdac209df6411181.
For another example i'm going to use very simple python script:
import psycopg2
cur =3D psycopg2.connect('dbname=3Dtest host=3D/tmp/').cursor()
while True:
try:
cur.execute("select nextval('s')")
val=3Dcur.fetchone()[0]
except Exception, e:
print "%s\n%s" % (val,e)
break
This script consumes a lot of values from sequence 's' within a single
transaction, when crash occurs it prints out last value that the script got
from database.
postgres@sbox /usr/local/pgsql $ python test.py =
132119
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
postgres@sbox /usr/local/pgsql $ /usr/local/pgsql/bin/psql test
psql (9.2.4)
Type "help" for help.
test=3D# select nextval('s');
nextval =
---------
130501
(1 row)
test=3D#