Thread: Transaction log file screwed up

Transaction log file screwed up

From
"Kevin Schroeder"
Date:
Hello,
    A client database crashed last night and I think I found the solution to
the problem at http://www.varlena.com/varlena/GeneralBits/45.php "Database
Recovery Procedures ".  The solution was to append the file with enough
zeros to get the file size correct.  The solution was to run

dd bs=8k count=1 < /dev/zero >> $PGDATA/pg_clog/0005

which added the zeros to the end.  However my error values are a little
different from ones in the example and the person who posted this noted that
this should NOT be tried haphazardly.  Since I'd rather not crash a client's
database to the point of no recovery I wouldn't mind having someone with
more knowledge of PostgreSQL post the command with the correct arguments to
fix the problem, or tell me I'm off my rocker trying to fix it this way.

Following is pg_ctl's output when trying to start the database.  Following
that is the directory listing for the pg_clog directory.

LOG:  checkpoint record is at 1/383BDFC0
LOG:  redo record is at 1/383BDFC0; undo record is at 0/0; shutdown TRUE
LOG:  next transaction id: 15038948; next oid: 3293693
LOG:  database system was not properly shut down; automatic recovery in
progress
LOG:  ReadRecord: unexpected pageaddr 1/363BE000 in log file 1, segment 56,
offset 3923968
LOG:  redo is not required
PANIC:  XLogWrite: write request 1/383BE000 is past end of log 1/383BE000
LOG:  startup process (pid 1555) was terminated by signal 6
LOG:  aborting startup due to startup process failure

pgsql/data/pg_clog/*

-rw-------    1 postgres  postgres   262144 Mar 14 13:10 0000
-rw-------    1 postgres  postgres    262144 Mar 24 15:35 0001
-rw-------    1 postgres  postgres    262144 Mar 27 00:04 0002
-rw-------    1 postgres  postgres    262144 Mar 29 18:06 0003
-rw-------    1 postgres  postgres    262144 Apr  1 00:39 0004
-rw-------    1 postgres  postgres    262144 Apr  3 09:54 0005
-rw-------    1 postgres  postgres    262144 Apr  5 21:39 0006
-rw-------    1 postgres  postgres    262144 Apr  8 03:26 0007
-rw-------    1 postgres  postgres    262144 Apr 10 10:15 0008
-rw-------    1 postgres  postgres    262144 Apr 12 21:05 0009
-rw-------    1 postgres  postgres    262144 Apr 15 00:32 000A
-rw-------    1 postgres  postgres    262144 Apr 17 03:38 000B
-rw-------    1 postgres  postgres    262144 Apr 19 13:07 000C
-rw-------    1 postgres  postgres    262144 Apr 21 13:38 000D
-rw-------    1 postgres  postgres     90112 Apr 22 07:01 000E

Thanks

Kevin


Re: Transaction log file screwed up

From
Tom Lane
Date:
"Kevin Schroeder" <kschroeder@mirageworks.com> writes:
> PANIC:  XLogWrite: write request 1/383BE000 is past end of log 1/383BE000

The correct solution to this is to update your 7.3.3 installation to a
version without that page-boundary-case bug; as long as you're on 7.3.3
you have a one-in-several-hundred chance of the above startup failure.

7.3.6 is the right version to be using if you're on the 7.3.* line.

            regards, tom lane