Re: pg_stop_backup wait bug fix - Mailing list pgsql-hackers
From | Heikki Linnakangas |
---|---|
Subject | Re: pg_stop_backup wait bug fix |
Date | |
Msg-id | 493596CE.6040408@enterprisedb.com Whole thread Raw |
In response to | Re: pg_stop_backup wait bug fix ("Fujii Masao" <masao.fujii@gmail.com>) |
Responses |
Re: pg_stop_backup wait bug fix
|
List | pgsql-hackers |
Fujii Masao wrote: > On Wed, Oct 8, 2008 at 10:23 PM, Simon Riggs <simon@2ndquadrant.com> wrote: >> Minor bug fix for pg_stop_backup() to prevent it waiting longer than >> necessary in certain circumstances. > > Why don't you use XLByteToPrevSeg like pg_xlogfile_name? > I think that we should uniform the logic as much as possible. Agreed, should use XLByteToPrevSeg. But I wonder if we can just replace the current XLByteToSeg call with XLByteToPrevSeg? That would offset the return value of the function by one byte as well, as well as the value printed to the backup history file. In fact, I think the original patch got that wrong; it would return the location of the *beginning* of the last xlog file. I also noticed that the 2nd BackupHistoryFileName call in that function is useless; histfilepath variable is already filled in earlier. How does the attached patch look to you? Do you have an easy way to test this? -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com Index: src/backend/access/transam/xlog.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v retrieving revision 1.322 diff -c -r1.322 xlog.c *** src/backend/access/transam/xlog.c 9 Nov 2008 17:51:15 -0000 1.322 --- src/backend/access/transam/xlog.c 2 Dec 2008 20:10:03 -0000 *************** *** 6674,6679 **** --- 6674,6680 ---- char histfilepath[MAXPGPATH]; char startxlogfilename[MAXFNAMELEN]; char stopxlogfilename[MAXFNAMELEN]; + char lastxlogfilename[MAXFNAMELEN]; uint32 _logId; uint32 _logSeg; FILE *lfp; *************** *** 6711,6716 **** --- 6712,6720 ---- XLByteToSeg(stoppoint, _logId, _logSeg); XLogFileName(stopxlogfilename, ThisTimeLineID, _logId, _logSeg); + XLByteToPrevSeg(stoppoint, _logId, _logSeg); + XLogFileName(lastxlogfilename, ThisTimeLineID, _logId, _logSeg); + /* Use the log timezone here, not the session timezone */ stamp_time = (pg_time_t) time(NULL); pg_strftime(strfbuf, sizeof(strfbuf), *************** *** 6801,6813 **** * we assume the admin wanted his backup to work completely. If you * don't wish to wait, you can set statement_timeout. */ - BackupHistoryFileName(histfilepath, ThisTimeLineID, _logId, _logSeg, - startpoint.xrecoff % XLogSegSize); - seconds_before_warning = 60; waits = 0; ! while (XLogArchiveIsBusy(stopxlogfilename) || XLogArchiveIsBusy(histfilepath)) { CHECK_FOR_INTERRUPTS(); --- 6805,6814 ---- * we assume the admin wanted his backup to work completely. If you * don't wish to wait, you can set statement_timeout. */ seconds_before_warning = 60; waits = 0; ! while (XLogArchiveIsBusy(lastxlogfilename) || XLogArchiveIsBusy(histfilepath)) { CHECK_FOR_INTERRUPTS();
pgsql-hackers by date: