Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQeMl-0004ec-5j for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Apr 2013 13:50:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UQeMk-0002kb-E1 for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Apr 2013 13:50:10 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQd4Q-0004ju-2m for pgsql-bugs@postgresql.org; Fri, 12 Apr 2013 12:27:10 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQd4N-0001E7-1J for pgsql-bugs@postgresql.org; Fri, 12 Apr 2013 12:27:09 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQd4M-0008Lg-CV for pgsql-bugs@postgresql.org; Fri, 12 Apr 2013 12:27:06 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1UQd4H-0000TP-6T for pgsql-bugs@postgresql.org; Fri, 12 Apr 2013 12:27:01 +0000 Date: Fri, 12 Apr 2013 12:27:01 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #8059: sequence crash recovery is not working properly To: pgsql-bugs@postgresql.org From: tarvip@gmail.com X-Pg-Spam-Score: -3.4 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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:=20=20=20=20=20=20=20=20 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=20 --------- 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=20 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 $=20 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=20 --------- 1 (1 row) test=3D#=20 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=20 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=20 --------- 130501 (1 row) test=3D# --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs