mirror of
https://github.com/postgres/postgres.git
synced 2025-06-01 00:01:20 -04:00
Adjust pg_resetxlog to handle 8.0 WAL file names properly.
This commit is contained in:
parent
8562b032d8
commit
59bffa3707
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_resetxlog.sgml,v 1.8 2003/11/29 19:51:39 pgsql Exp $
|
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_resetxlog.sgml,v 1.9 2004/12/20 01:42:09 tgl Exp $
|
||||||
PostgreSQL documentation
|
PostgreSQL documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ PostgreSQL documentation
|
|||||||
<arg> -n </arg>
|
<arg> -n </arg>
|
||||||
<arg> -o <replaceable class="parameter">oid</replaceable> </arg>
|
<arg> -o <replaceable class="parameter">oid</replaceable> </arg>
|
||||||
<arg> -x <replaceable class="parameter">xid</replaceable> </arg>
|
<arg> -x <replaceable class="parameter">xid</replaceable> </arg>
|
||||||
<arg> -l <replaceable class="parameter">fileid</replaceable>,<replaceable class="parameter">seg</replaceable> </arg>
|
<arg> -l <replaceable class="parameter">timelineid</replaceable>,<replaceable class="parameter">fileid</replaceable>,<replaceable class="parameter">seg</replaceable> </arg>
|
||||||
<arg choice="plain"><replaceable>datadir</replaceable></arg>
|
<arg choice="plain"><replaceable>datadir</replaceable></arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
@ -79,17 +79,25 @@ PostgreSQL documentation
|
|||||||
<command>pg_resetxlog</command> is unable to determine appropriate values
|
<command>pg_resetxlog</command> is unable to determine appropriate values
|
||||||
by reading <filename>pg_control</>. A safe value for the
|
by reading <filename>pg_control</>. A safe value for the
|
||||||
next transaction ID may be determined by looking for the numerically largest
|
next transaction ID may be determined by looking for the numerically largest
|
||||||
file name in the directory <filename>pg_clog</> under the data directory, adding one,
|
file name in the directory <filename>pg_clog</> under the data directory,
|
||||||
|
adding one,
|
||||||
and then multiplying by 1048576. Note that the file names are in
|
and then multiplying by 1048576. Note that the file names are in
|
||||||
hexadecimal. It is usually easiest to specify the switch value in
|
hexadecimal. It is usually easiest to specify the switch value in
|
||||||
hexadecimal too. For example, if <filename>0011</> is the largest entry
|
hexadecimal too. For example, if <filename>0011</> is the largest entry
|
||||||
in <filename>pg_clog</>, <literal>-x 0x1200000</> will work (five trailing
|
in <filename>pg_clog</>, <literal>-x 0x1200000</> will work (five trailing
|
||||||
zeroes provide the proper multiplier).
|
zeroes provide the proper multiplier).
|
||||||
The WAL starting address should be
|
The WAL starting address should be
|
||||||
larger than any file number currently existing in
|
larger than any file name currently existing in
|
||||||
the directory <filename>pg_xlog</> under the data directory. The addresses are also in hexadecimal and
|
the directory <filename>pg_xlog</> under the data directory.
|
||||||
have two parts. For example, if <filename>000000FF0000003A</> is the
|
These names are also in hexadecimal and have three parts. The first
|
||||||
largest entry in <filename>pg_xlog</>, <literal>-l 0xFF,0x3B</> will work.
|
part is the <quote>timeline ID</> and should usually be kept the same.
|
||||||
|
Do not choose a value larger than 255 (<literal>0xFF</>) for the third
|
||||||
|
part; instead increment the second part and reset the third part to 0.
|
||||||
|
For example, if <filename>00000001000000320000004A</> is the
|
||||||
|
largest entry in <filename>pg_xlog</>, <literal>-l 0x1,0x32,0x4B</> will
|
||||||
|
work; but if the largest entry is
|
||||||
|
<filename>000000010000003A000000FF</>, choose <literal>-l 0x1,0x3B,0x0</>
|
||||||
|
or more.
|
||||||
There is no comparably easy way to determine a next OID that's beyond
|
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
|
the largest one in the database, but fortunately it is not critical to
|
||||||
get the next-OID setting right.
|
get the next-OID setting right.
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.26 2004/12/14 01:59:41 neilc Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.27 2004/12/20 01:42:11 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -77,10 +77,12 @@ main(int argc, char *argv[])
|
|||||||
bool noupdate = false;
|
bool noupdate = false;
|
||||||
TransactionId set_xid = 0;
|
TransactionId set_xid = 0;
|
||||||
Oid set_oid = 0;
|
Oid set_oid = 0;
|
||||||
uint32 minXlogId = 0,
|
uint32 minXlogTli = 0,
|
||||||
|
minXlogId = 0,
|
||||||
minXlogSeg = 0;
|
minXlogSeg = 0;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
char *endptr2;
|
char *endptr2;
|
||||||
|
char *endptr3;
|
||||||
char *DataDir;
|
char *DataDir;
|
||||||
int fd;
|
int fd;
|
||||||
char path[MAXPGPATH];
|
char path[MAXPGPATH];
|
||||||
@ -147,15 +149,22 @@ main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
minXlogId = strtoul(optarg, &endptr, 0);
|
minXlogTli = strtoul(optarg, &endptr, 0);
|
||||||
if (endptr == optarg || *endptr != ',')
|
if (endptr == optarg || *endptr != ',')
|
||||||
{
|
{
|
||||||
fprintf(stderr, _("%s: invalid argument for option -l\n"), progname);
|
fprintf(stderr, _("%s: invalid argument for option -l\n"), progname);
|
||||||
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
minXlogSeg = strtoul(endptr + 1, &endptr2, 0);
|
minXlogId = strtoul(endptr + 1, &endptr2, 0);
|
||||||
if (endptr2 == endptr + 1 || *endptr2 != '\0')
|
if (endptr2 == endptr + 1 || *endptr2 != ',')
|
||||||
|
{
|
||||||
|
fprintf(stderr, _("%s: invalid argument for option -l\n"), progname);
|
||||||
|
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
minXlogSeg = strtoul(endptr2 + 1, &endptr3, 0);
|
||||||
|
if (endptr3 == endptr2 + 1 || *endptr3 != '\0')
|
||||||
{
|
{
|
||||||
fprintf(stderr, _("%s: invalid argument for option -l\n"), progname);
|
fprintf(stderr, _("%s: invalid argument for option -l\n"), progname);
|
||||||
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
||||||
@ -238,6 +247,9 @@ main(int argc, char *argv[])
|
|||||||
if (set_oid != 0)
|
if (set_oid != 0)
|
||||||
ControlFile.checkPointCopy.nextOid = set_oid;
|
ControlFile.checkPointCopy.nextOid = set_oid;
|
||||||
|
|
||||||
|
if (minXlogTli > ControlFile.checkPointCopy.ThisTimeLineID)
|
||||||
|
ControlFile.checkPointCopy.ThisTimeLineID = minXlogTli;
|
||||||
|
|
||||||
if (minXlogId > ControlFile.logId ||
|
if (minXlogId > ControlFile.logId ||
|
||||||
(minXlogId == ControlFile.logId &&
|
(minXlogId == ControlFile.logId &&
|
||||||
minXlogSeg > ControlFile.logSeg))
|
minXlogSeg > ControlFile.logSeg))
|
||||||
@ -597,8 +609,8 @@ KillExistingXLOG(void)
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
while ((xlde = readdir(xldir)) != NULL)
|
while ((xlde = readdir(xldir)) != NULL)
|
||||||
{
|
{
|
||||||
if (strlen(xlde->d_name) == 16 &&
|
if (strlen(xlde->d_name) == 24 &&
|
||||||
strspn(xlde->d_name, "0123456789ABCDEF") == 16)
|
strspn(xlde->d_name, "0123456789ABCDEF") == 24)
|
||||||
{
|
{
|
||||||
snprintf(path, MAXPGPATH, "%s/%s", XLogDir, xlde->d_name);
|
snprintf(path, MAXPGPATH, "%s/%s", XLogDir, xlde->d_name);
|
||||||
if (unlink(path) < 0)
|
if (unlink(path) < 0)
|
||||||
@ -739,7 +751,7 @@ usage(void)
|
|||||||
printf(_("Usage:\n %s [OPTION]... DATADIR\n\n"), progname);
|
printf(_("Usage:\n %s [OPTION]... DATADIR\n\n"), progname);
|
||||||
printf(_("Options:\n"));
|
printf(_("Options:\n"));
|
||||||
printf(_(" -f force update to be done\n"));
|
printf(_(" -f force update to be done\n"));
|
||||||
printf(_(" -l FILEID,SEG force minimum WAL starting location for new transaction log\n"));
|
printf(_(" -l TLI,FILE,SEG force minimum WAL starting location for new transaction log\n"));
|
||||||
printf(_(" -n no update, just show extracted control values (for testing)\n"));
|
printf(_(" -n no update, just show extracted control values (for testing)\n"));
|
||||||
printf(_(" -o OID set next OID\n"));
|
printf(_(" -o OID set next OID\n"));
|
||||||
printf(_(" -x XID set next transaction ID\n"));
|
printf(_(" -x XID set next transaction ID\n"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user