pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: tarvip@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #8059: sequence crash recovery is not working properly
Date: Fri, 12 Apr 2013 12:27:01 +0000
Message-ID: <E1UQd4H-0000TP-6T@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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=# create sequence s;
CREATE SEQUENCE
test=# begin;
BEGIN
test=# 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=# 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@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=# select nextval('s');
 nextval 
---------
  130501
(1 row)

test=#



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (6+ messages)  latest in thread

Message-ID: <E1UQd4H-0000TP-6T@wrigleys.postgresql.org>
Permalink:  ../E1UQd4H-0000TP-6T@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1UQd4H-0000TP-6T@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tarvip@gmail.com
  Subject: Re: BUG #8059: sequence crash recovery is not working properly
  In-Reply-To: <E1UQd4H-0000TP-6T@wrigleys.postgresql.org>
  References: <E1UQd4H-0000TP-6T@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox