From: Paul Förster <paul.foerster@gmail.com>
To: Justin <zzzzz.graf@gmail.com>
Cc: Simon Riggs <simon@2ndquadrant.com>
Cc: krah.tm@gmail.com
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Force WAL cleanup on running instance
Date: Wed, 11 Mar 2020 18:29:23 +0100
Message-ID: <BA5099CB-2798-4A04-B462-9DF58B219B80@gmail.com> (raw)
In-Reply-To: <CALL-XeNreM=MgoxK8e2XNDfyQUMgx45Fv0n-m1=TvB0sei3udw@mail.gmail.com>
References: <3f91429eb65ac8aa3c77361c587e786a290b92f0.camel@gmail.com>
<CANP8+j+q05ZsoZieAwJrbniOZmWjo6hXhzW4X86uL4HqdF-y_A@mail.gmail.com>
<CALL-XeNreM=MgoxK8e2XNDfyQUMgx45Fv0n-m1=TvB0sei3udw@mail.gmail.com>
Hi Justin,
that came to my mind also. Then I tried and found that not always a new WAL is created. I admit I tried on a test DC with no other transactions going on. Maybe I should have done that. Anyway, I also always do the checkpoint first and then the WAL switch, which in my case is also an old habit from Oracle. ;-)
Cheers,
Paul
> On 11. Mar, 2020, at 16:51, Justin <zzzzz.graf@gmail.com> wrote:
>
> Question everyone isn't this a problem with the order of operations?
>
> switching the wal files then running checkpoint means the Checkpoint can cross wal files, so the previous wal file can not be deleted???
>
> To my understanding the order operations should be
>
> Checkpoint
> which flushes everything to disk, then
> pg_switch_wal()
>
> which creates an empty wal file and the previous wal can be deleted?
>
> http://www.interdb.jp/pg/pgsql09.html#_9.7.
> https://www.postgresql.org/docs/current/wal-configuration.html
>
> Or am i missing something?
>
> On Wed, Mar 11, 2020 at 11:45 AM Simon Riggs <simon@2ndquadrant.com> wrote:
> On Wed, 11 Mar 2020 at 08:59, Torsten Krah <krah.tm@gmail.com> wrote:
> Hi,
>
> I am building a docker image with a postgresql 12.2 instance and while
> doing so and importing a dump and running some update scripts wal size
> is increasing.
>
> When finished I don't need all those wal files anymore and tried to
> force the daemon to clean them up and tried this:
>
> select pg_switch_wal();
> CHECKPOINT;
>
> and did wait for a minute.
>
> Sometimes it works and wal files are cleaned and moved away so my image
> size is way smaller - but it does not happen always in that minute.
>
> So is there a way to tell postgres to force the housekeeping of the wal
> stuff via a statement / command line tool?
> In a "normal" running instance it just takes care of itself and it will
> happen sooner or later and it doesn't really matter when that will
> happen - but with my docker image which is automatically build it would
> be nice to have a deterministic way of trigger that to reduce the final
> size image.
>
> The size of the task varies, so sometimes takes longer than 60s, depending upon your hardware.
>
> --
> Simon Riggs http://www.2ndQuadrant.com/
> PostgreSQL Solutions for the Enterprise
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: paul.foerster@gmail.com, zzzzz.graf@gmail.com, simon@2ndquadrant.com, krah.tm@gmail.com
Subject: Re: Force WAL cleanup on running instance
In-Reply-To: <BA5099CB-2798-4A04-B462-9DF58B219B80@gmail.com>
References: <3f91429eb65ac8aa3c77361c587e786a290b92f0.camel@gmail.com> <CANP8+j+q05ZsoZieAwJrbniOZmWjo6hXhzW4X86uL4HqdF-y_A@mail.gmail.com> <CALL-XeNreM=MgoxK8e2XNDfyQUMgx45Fv0n-m1=TvB0sei3udw@mail.gmail.com> <BA5099CB-2798-4A04-B462-9DF58B219B80@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox