1PG_RESETXLOG(1)         PostgreSQL 9.2.24 Documentation        PG_RESETXLOG(1)
2
3
4

NAME

6       pg_resetxlog - reset the write-ahead log and other control information
7       of a PostgreSQL database cluster
8

SYNOPSIS

10       pg_resetxlog [-f] [-n] [-o oid] [-x xid] [-e xid_epoch] [-m mxid]
11                    [-O mxoff] [-l timelineid,fileid,seg] datadir
12

DESCRIPTION

14       pg_resetxlog clears the write-ahead log (WAL) and optionally resets
15       some other control information stored in the pg_control file. This
16       function is sometimes needed if these files have become corrupted. It
17       should be used only as a last resort, when the server will not start
18       due to such corruption.
19
20       After running this command, it should be possible to start the server,
21       but bear in mind that the database might contain inconsistent data due
22       to partially-committed transactions. You should immediately dump your
23       data, run initdb, and reload. After reload, check for inconsistencies
24       and repair as needed.
25
26       This utility can only be run by the user who installed the server,
27       because it requires read/write access to the data directory. For safety
28       reasons, you must specify the data directory on the command line.
29       pg_resetxlog does not use the environment variable PGDATA.
30
31       If pg_resetxlog complains that it cannot determine valid data for
32       pg_control, you can force it to proceed anyway by specifying the -f
33       (force) option. In this case plausible values will be substituted for
34       the missing data. Most of the fields can be expected to match, but
35       manual assistance might be needed for the next OID, next transaction ID
36       and epoch, next multitransaction ID and offset, and WAL starting
37       address fields. These fields can be set using the options discussed
38       below. If you are not able to determine correct values for all these
39       fields, -f can still be used, but the recovered database must be
40       treated with even more suspicion than usual: an immediate dump and
41       reload is imperative.  Do not execute any data-modifying operations in
42       the database before you dump, as any such action is likely to make the
43       corruption worse.
44
45       The -o, -x, -e, -m, -O, and -l options allow the next OID, next
46       transaction ID, next transaction ID's epoch, next multitransaction ID,
47       next multitransaction offset, and WAL starting address values to be set
48       manually. These are only needed when pg_resetxlog is unable to
49       determine appropriate values by reading pg_control. Safe values can be
50       determined as follows:
51
52       ·   A safe value for the next transaction ID (-x) can be determined by
53           looking for the numerically largest file name in the directory
54           pg_clog under the data directory, adding one, and then multiplying
55           by 1048576. Note that the file names are in hexadecimal. It is
56           usually easiest to specify the option value in hexadecimal too. For
57           example, if 0011 is the largest entry in pg_clog, -x 0x1200000 will
58           work (five trailing zeroes provide the proper multiplier).
59
60       ·   A safe value for the next multitransaction ID (-m) can be
61           determined by looking for the numerically largest file name in the
62           directory pg_multixact/offsets under the data directory, adding
63           one, and then multiplying by 65536. As above, the file names are in
64           hexadecimal, so the easiest way to do this is to specify the option
65           value in hexadecimal and add four zeroes.
66
67       ·   A safe value for the next multitransaction offset (-O) can be
68           determined by looking for the numerically largest file name in the
69           directory pg_multixact/members under the data directory, adding
70           one, and then multiplying by 65536. As above, the file names are in
71           hexadecimal, so the easiest way to do this is to specify the option
72           value in hexadecimal and add four zeroes.
73
74       ·   The WAL starting address (-l) should be larger than any WAL segment
75           file name currently existing in the directory pg_xlog under the
76           data directory. These names are also in hexadecimal and have three
77           parts. The first part is the “timeline ID” and should usually be
78           kept the same. Do not choose a value larger than 255 (0xFF) for the
79           third part; instead increment the second part and reset the third
80           part to 0. For example, if 00000001000000320000004A is the largest
81           entry in pg_xlog, -l 0x1,0x32,0x4B will work; but if the largest
82           entry is 000000010000003A000000FF, choose -l 0x1,0x3B,0x0 or more.
83
84               Note
85               pg_resetxlog itself looks at the files in pg_xlog and chooses a
86               default -l setting beyond the last existing file name.
87               Therefore, manual adjustment of -l should only be needed if you
88               are aware of WAL segment files that are not currently present
89               in pg_xlog, such as entries in an offline archive; or if the
90               contents of pg_xlog have been lost entirely.
91
92       ·   There is no comparably easy way to determine a next OID that's
93           beyond the largest one in the database, but fortunately it is not
94           critical to get the next-OID setting right.
95
96       ·   The transaction ID epoch is not actually stored anywhere in the
97           database except in the field that is set by pg_resetxlog, so any
98           value will work so far as the database itself is concerned. You
99           might need to adjust this value to ensure that replication systems
100           such as Slony-I work correctly — if so, an appropriate value should
101           be obtainable from the state of the downstream replicated database.
102
103       The -n (no operation) option instructs pg_resetxlog to print the values
104       reconstructed from pg_control and then exit without modifying anything.
105       This is mainly a debugging tool, but can be useful as a sanity check
106       before allowing pg_resetxlog to proceed for real.
107
108       The -V and --version options print the pg_resetxlog version and exit.
109       The options -?  and --help show supported arguments, and exit.
110

NOTES

112       This command must not be used when the server is running.  pg_resetxlog
113       will refuse to start up if it finds a server lock file in the data
114       directory. If the server crashed then a lock file might have been left
115       behind; in that case you can remove the lock file to allow pg_resetxlog
116       to run. But before you do so, make doubly certain that there is no
117       server process still alive.
118
119       pg_resetxlog works only with servers of the same major version.
120
121
122
123PostgreSQL 9.2.24                 2017-11-06                   PG_RESETXLOG(1)
Impressum