.\\" auto-generated by docbook2man-spec $Revision: 1.25 $ .TH "PG_RESETXLOG" "1" "2002-11-22" "Application" "PostgreSQL Server Applications" .SH NAME pg_resetxlog \- reset write-ahead log and pg_control contents .SH SYNOPSIS .sp \fBpg_resetxlog\fR\fR [ \fR\fB -f \fR\fR]\fR\fR [ \fR\fB -n \fR\fR]\fR\fR [ \fR\fB -o \fIoid\fB \fR\fR]\fR\fR [ \fR\fB -x \fIxid\fB \fR\fR]\fR\fR [ \fR\fB -l \fIfileid\fB,\fIseg\fB \fR\fR]\fR \fB\fIdatadir\fB\fR .SH "DESCRIPTION" .PP \fBpg_resetxlog\fR clears the write-ahead log and optionally resets some fields in the \fIpg_control\fR file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption. .PP After running this command, it should be possible to start the server, but bear in mind that the database may contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run \fBinitdb\fR, and reload. After reload, check for inconsistencies and repair as needed. .PP This utility can only be run by the user who installed the server, because it requires read/write access to the datadir. For safety reasons, you must specify the data directory on the command line. \fBpg_resetxlog\fR does not use the environment variable \fBPGDATA\fR. .PP If \fBpg_resetxlog\fR complains that it cannot determine valid data for \fIpg_control\fR, you can force it to proceed anyway by specifying the -f (force) switch. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance may be needed for the next OID, next transaction ID, WAL starting address, and database locale fields. The first three of these can be set using the switches discussed below. \fBpg_resetxlog\fR's own environment is the source for its guess at the locale fields; take care that \fBLANG\fR and so forth match the environment that \fBinitdb\fR was run in. If you are not able to determine correct values for all these fields, -f can still be used, but the recovered database must be treated with even more suspicion than usual --- an immediate dump and reload is imperative. \fBDo not\fR execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse. .PP The -o, -x, and -l switches allow the next OID, next transaction ID, and WAL starting address values to be set manually. These are only needed when \fBpg_resetxlog\fR is unable to determine appropriate values by reading \fIpg_control\fR. A safe value for the next transaction ID may be determined by looking for the largest file name in \fB$PGDATA\fR\fI/pg_clog\fR, adding one, and then multiplying by 1048576. Note that the file names are in hexadecimal. It is usually easiest to specify the switch value in hexadecimal too. For example, if \fI0011\fR is the largest entry in \fIpg_clog\fR, -x 0x1200000 will work (five trailing zeroes provide the proper multiplier). The WAL starting address should be larger than any file number currently existing in \fB$PGDATA\fR\fI/pg_xlog\fR. These also are in hex, and have two parts. For example, if \fI000000FF0000003A\fR is the largest entry in \fIpg_xlog\fR, -l 0xFF,0x3B will work. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right. .PP The -n (no operation) switch instructs \fBpg_resetxlog\fR to print the values reconstructed from \fIpg_control\fR and then exit without modifying anything. This is mainly a debugging tool, but may be useful as a sanity check before allowing \fBpg_resetxlog\fR to proceed for real. .SH "NOTES" .PP This command must not be used when the \fBpostmaster\fR is running. \fBpg_resetxlog\fR will refuse to start up if it finds a postmaster lock file in the datadir. If the \fBpostmaster\fR crashed then a lock file may have been left behind; in that case you can remove the lock file to allow \fBpg_resetxlog\fR to run. But before you do so, make doubly certain that there is no postmaster nor any backend server process still alive.