Обсуждение: is it safe to clear oroginal xlog after archiving it?
hi, i have archive_command which copies the wal segment someplace. is it safe, if i would do: dd if=/dev/zero of=$ORIGINAL_XLOG_SEGMENT bs=1M count=16 before returning from archive_command script? the point of doing so is pretty simple: i have a system with rather low traffic, so i use archive_timeout. and most of the xlog segments are unused, but they contain previous data, since the files are reused. if zero-ing the files was safe, i could compress them more effectively. i am aware that there is pg_lesslog or clearxlogtail, but if this zeroing would be ok, then i'd rather use it (one less program to worry about, and it looks safer because i modify file that will be overwritten anyway). Best regards, depesz -- Linkedin: http://www.linkedin.com/in/depesz / blog: http://www.depesz.com/ jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007
On Thu, 4 Jun 2009, hubert depesz lubaczewski wrote: > is it safe, if i would do: > dd if=/dev/zero of=$ORIGINAL_XLOG_SEGMENT bs=1M count=16 > before returning from archive_command script? Nope. At that point, the files are still needed for crash recovery on that system. There will be a future point where a checkpoint will note the files aren't needed anymore, and at that point they'll be recycled (renamed with a new id and used again) or deleted. You can't change the files until then though, and that time can be several minutes after archive_command is called. -- * Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD
On Thu, 2009-06-04 at 14:42 +0200, hubert depesz lubaczewski wrote: > if zero-ing the files was safe, i could compress them more effectively. Simple rule: Never, ever, ever remove or edit any file in pg_xlog. There is a command called pg_resetxlog, though that is not designed to reduce the amount of space in pg_xlog and using it can cause data loss if used inappropriately. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support