BUG #8059: sequence crash recovery is not working properly

From: tarvip(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #8059: sequence crash recovery is not working properly
Date: 2013-04-12 12:27:01
Message-ID: E1UQd4H-0000TP-6T@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 8059
Logged by: Tarvi Pillessaar
Email address: tarvip(at)gmail(dot)com
PostgreSQL version: 9.2.4
Operating system: linux
Description:

Very simple example:

postgres(at)sbox /usr/local/pgsql $ /usr/local/pgsql/bin/psql test
psql (9.2.4)
Type "help" for help.

test=# create sequence s;
CREATE SEQUENCE
test=# begin;
BEGIN
test=# select nextval('s');
nextval
---------
1
(1 row)

Now let's crash the cluster:

postgres(at)sbox /usr/local/pgsql $ pgrep -lf writer
13638 postgres: writer process
13639 postgres: wal writer process
postgres(at)sbox /usr/local/pgsql $ kill -9 13638
postgres(at)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(at)sbox /usr/local/pgsql $

test=# 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=# select nextval('s');
nextval
---------
1
(1 row)

test=#

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 = psycopg2.connect('dbname=test host=/tmp/').cursor()
while True:
try:
cur.execute("select nextval('s')")
val=cur.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(at)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(at)sbox /usr/local/pgsql $ /usr/local/pgsql/bin/psql test
psql (9.2.4)
Type "help" for help.

test=# select nextval('s');
nextval
---------
130501
(1 row)

test=#

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message shaun.c.mccrery 2013-04-12 13:04:50 BUG #8060: postgresql service not in Microsoft services
Previous Message daniel 2013-04-12 08:34:24 BUG #8058: CLUSTER and VACUUM FULL fail to free space