Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitced83f7

Browse files
author
Michael Paquier
committed
Fix WAL segment file generation
Name file of WAL segment was generated using the API of xlog_internal.hcalled XlogFileName, based on XLogSegNo and not XLogRecPtr as theprevious code assumed. This leaded to backup incorrect, actually toomany WAL files in the archive code path because the analysis was basedon a name completely fucked up. This commit fixes at the same time anissue in search_next_wal where the function could loop for a too longamount of time, eating much CPU when looking for the next WAL file.Regression tests are passing cleanly with this patch.
1 parent78d92ff commitced83f7

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

‎backup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ do_backup_arclog(parray *backup_list)
433433
charprev_file_txt[MAXPGPATH];
434434
pgBackup*prev_backup;
435435
int64arclog_write_bytes=0;
436-
charlast_wal[MAXPGPATH];
436+
charlast_wal[MAXFNAMELEN];
437437

438438
Assert(current.backup_mode==BACKUP_MODE_ARCHIVE||
439439
current.backup_mode==BACKUP_MODE_INCREMENTAL||
@@ -485,7 +485,7 @@ do_backup_arclog(parray *backup_list)
485485
dir_list_file(files,arclog_path,NULL, true, false);
486486

487487
/* remove WALs archived after pg_stop_backup()/pg_switch_xlog() */
488-
xlog_fname(last_wal,lengthof(last_wal),current.tli,&current.stop_lsn);
488+
xlog_fname(last_wal,current.tli,current.stop_lsn);
489489
for (i=0;i<parray_num(files);i++)
490490
{
491491
pgFile*file= (pgFile*)parray_get(files,i);
@@ -1023,7 +1023,7 @@ wait_for_archive(pgBackup *backup, const char *sql)
10231023
}
10241024

10251025
/* As well as WAL file name */
1026-
XLogFileName(file_name,tli,lsn);
1026+
xlog_fname(file_name,tli,lsn);
10271027

10281028
snprintf(ready_path,lengthof(ready_path),
10291029
"%s/pg_xlog/archive_status/%s.ready",pgdata,

‎pg_rman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ extern int pgFileCompareMtimeDesc(const void *f1, const void *f2);
307307

308308
/* in xlog.c */
309309
externboolxlog_is_complete_wal(constpgFile*file);
310-
externvoidxlog_fname(char*fname,size_tlen,TimeLineIDtli,XLogRecPtr*lsn);
310+
externvoidxlog_fname(char*fname,TimeLineIDtli,XLogRecPtrlsn);
311311

312312
/* in data.c */
313313
externboolbackup_data_file(constchar*from_root,constchar*to_root,

‎restore.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ search_next_wal(const char *path, XLogRecPtr *need_lsn, parray *timelines)
992992
{
993993
pgTimeLine*timeline= (pgTimeLine*)parray_get(timelines,i);
994994

995-
XLogFileName(xlogfname,timeline->tli,*need_lsn);
995+
xlog_fname(xlogfname,timeline->tli,*need_lsn);
996996
join_path_components(xlogpath,path,xlogfname);
997997

998998
if (stat(xlogpath,&st)==0)
@@ -1021,8 +1021,8 @@ search_next_wal(const char *path, XLogRecPtr *need_lsn, parray *timelines)
10211021
parray_remove(timelines,i+1);
10221022
/* XXX: should we add a linebreak when we find a timeline? */
10231023

1024-
/* Move to next xlogrecord */
1025-
(*need_lsn)++;
1024+
/* Move to next xlogsegment */
1025+
*need_lsn+=XLogSegSize;
10261026
}
10271027
}
10281028

‎xlog.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ xlog_is_complete_wal(const pgFile *file)
7373
* based on XLogFileName() in xlog_internal.h
7474
*/
7575
void
76-
xlog_fname(char*fname,size_tlen,TimeLineIDtli,XLogRecPtr*lsn)
76+
xlog_fname(char*fname,TimeLineIDtli,XLogRecPtrlsn)
7777
{
78-
snprintf(fname,len,"%08X%08X%08X",tli,
79-
(uint32) (*lsn/XLogSegSize),
80-
(uint32) (*lsn%XLogSegSize));
78+
snprintf(fname,MAXFNAMELEN,"%08X%08X%08X",tli,
79+
(uint32) (lsn>>32),
80+
(uint32) (lsn/XLogSegSize));
8181
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp