Re: pgsql: Allow pg_resetxlog -f to reset pg_control - Mailing list pgsql-committers
From | Bruce Momjian |
---|---|
Subject | Re: pgsql: Allow pg_resetxlog -f to reset pg_control |
Date | |
Msg-id | 200604261856.k3QIuH017761@candle.pha.pa.us Whole thread Raw |
In response to | Re: pgsql: Allow pg_resetxlog -f to reset pg_control (Simon Riggs <simon@2ndquadrant.com>) |
List | pgsql-committers |
Simon Riggs wrote: > > It appears to me that a line like this has been missed out for when > mode==GUESS > > ControlFile.checkPointCopy.ThisTimeLineID = 2; > > (search for 514...) > > The old line which guessed at > ControlFile.checkPointCopy.ThisTimeLineID = 1; > has been removed, but with nothing to replace it, except in WAL mode. > > I'd prefer to guess the TLI as 2, since that is usually one more than > where we got to previously, and much more likely to be a reasonable > value choice. Good analysis. I cleaned up that section and added the line you suggested. -- Bruce Momjian http://candle.pha.pa.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. + Index: src/bin/pg_resetxlog/pg_resetxlog.c =================================================================== RCS file: /cvsroot/pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v retrieving revision 1.44 diff -c -c -r1.44 pg_resetxlog.c *** src/bin/pg_resetxlog/pg_resetxlog.c 26 Apr 2006 02:17:15 -0000 1.44 --- src/bin/pg_resetxlog/pg_resetxlog.c 26 Apr 2006 18:55:03 -0000 *************** *** 565,571 **** { struct timeval tv; char *localeptr; ! bool successed=true; /* * Set up a completely default set of pg_control values. --- 565,571 ---- { struct timeval tv; char *localeptr; ! bool successed = true; /* * Set up a completely default set of pg_control values. *************** *** 579,605 **** * update the checkpoint value in control file,by searching * xlog segment file, or just guessing it. */ ! if (mode == WAL) ! { int result = SearchLastCheckpoint(); ! if ( result > 0 ) /* The last checkpoint had been found. */ { ControlFile.checkPointCopy = lastcheckpoint; ControlFile.checkPoint = lastchkp; ControlFile.prevCheckPoint = prevchkp; ControlFile.logId = LastXLogFile->logid; ControlFile.logSeg = LastXLogFile->seg + 1; - ControlFile.checkPointCopy.ThisTimeLineID = LastXLogFile->tli; ControlFile.state = state; ! } else successed = false; /* Clean up the list. */ CleanUpList(xlogfilelist); ! ! } ! ! if (mode == GUESS) { ControlFile.checkPointCopy.redo.xlogid = 0; ControlFile.checkPointCopy.redo.xrecoff = SizeOfXLogLongPHD; ControlFile.checkPointCopy.undo = ControlFile.checkPointCopy.redo; --- 579,608 ---- * update the checkpoint value in control file,by searching * xlog segment file, or just guessing it. */ ! if (mode == WAL) ! { int result = SearchLastCheckpoint(); ! ! if (result > 0) /* The last checkpoint had been found. */ { ControlFile.checkPointCopy = lastcheckpoint; + ControlFile.checkPointCopy.ThisTimeLineID = LastXLogFile->tli; ControlFile.checkPoint = lastchkp; ControlFile.prevCheckPoint = prevchkp; + ControlFile.logId = LastXLogFile->logid; ControlFile.logSeg = LastXLogFile->seg + 1; ControlFile.state = state; ! } ! else ! successed = false; /* Clean up the list. */ CleanUpList(xlogfilelist); ! } ! else /* GUESS */ { + ControlFile.checkPointCopy.ThisTimeLineID = 2; ControlFile.checkPointCopy.redo.xlogid = 0; ControlFile.checkPointCopy.redo.xrecoff = SizeOfXLogLongPHD; ControlFile.checkPointCopy.undo = ControlFile.checkPointCopy.redo; *************** *** 609,614 **** --- 612,618 ---- ControlFile.checkPointCopy.nextMultiOffset = 0; ControlFile.checkPointCopy.time = time(NULL); ControlFile.checkPoint = ControlFile.checkPointCopy.redo; + /* * Create a new unique installation identifier, since we can no longer * use any old XLOG records. See notes in xlog.c about the algorithm. *************** *** 644,649 **** --- 648,654 ---- exit(1); } StrNCpy(ControlFile.lc_collate, localeptr, LOCALE_NAME_BUFLEN); + localeptr = setlocale(LC_CTYPE, ""); if (!localeptr) {
pgsql-committers by date: