Re: pg_standby -l might destory the archived file - Mailing list pgsql-hackers
From | Aidan Van Dyk |
---|---|
Subject | Re: pg_standby -l might destory the archived file |
Date | |
Msg-id | 20090601152736.GL15213@yugib.highrise.ca Whole thread Raw |
In response to | Re: pg_standby -l might destory the archived file (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>) |
Responses |
Re: pg_standby -l might destory the archived file
|
List | pgsql-hackers |
* Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> [090601 10:56]: > Tom Lane wrote: >> Fujii Masao <masao.fujii@gmail.com> writes: >>> pg_standby can use ln command to restore an archived file, >>> which might destroy the archived file as follows. >> >> Does it matter? pg_standby's source area wouldn't normally be an >> "archive" in the real sense of the word, it's just a temporary staging >> area between master and slave. (If it were being used as a real >> archive, keeping it on the same disk as the live slave seems pretty >> foolish anyway, so the case wouldn't arise.) > > It seems perfectly sane to source pg_standby directly from the archive > to me. And we're talking about symbolic linking, so the archive > directory might well be on an NFS mount. I would expect that any archive directly available would at least be RO to the postgres slave... But.... Something like this would stop the "symlink" being renamed... Not portable, but probably portable across platforms that have symlinks...diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.cindex1b575e2..cba3f7a 100644--- a/src/backend/access/transam/xlog.c+++ b/src/backend/access/transam/xlog.c@@-3042,13 +3042,23 @@ RemoveOldXlogFiles(uint32 log, uint32 seg, XLogRecPtr endptr) { if (XLogArchiveCheckDone(xlde->d_name)) {+ struct stat stat_buf; snprintf(path, MAXPGPATH, XLOGDIR "/%s", xlde->d_name); /* * Before deleting the file, see if it can be recycled as a * future logsegment.+ * If it's a symlink, we don't recycle it */- if (InstallXLogFileSegment(&endlogId, &endlogSeg, path,+ if ( (stat(path, &stat_buf)== 0) && S_ISLNK(stat_buf.st_mode))+ {+ ereport(DEBUG2,+ (errmsg("removing transaction log symlink \"%s\"",+ xlde->d_name)));+ unlink(path);+ CheckpointStats.ckpt_segs_removed++;+ }+ else if (InstallXLogFileSegment(&endlogId, &endlogSeg, path, true, &max_advance, true)) { You can make a smaller patch if your not interested in the DEBUG2 message saying that it deleted a symlink... -- Aidan Van Dyk Create like a god, aidan@highrise.ca command like a king, http://www.highrise.ca/ work like a slave.
pgsql-hackers by date: