Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jC5Aj-0002xR-30 for pgsql-general@arkaria.postgresql.org; Wed, 11 Mar 2020 17:29:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jC5Ah-000247-M8 for pgsql-general@arkaria.postgresql.org; Wed, 11 Mar 2020 17:29:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jC5Ah-000240-9Y for pgsql-general@lists.postgresql.org; Wed, 11 Mar 2020 17:29:31 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jC5Ad-0005TH-Tt for pgsql-general@lists.postgresql.org; Wed, 11 Mar 2020 17:29:30 +0000 Received: by mail-wm1-x341.google.com with SMTP id 11so3007923wmo.2 for ; Wed, 11 Mar 2020 10:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=LoFoBqYB8pssqjd0XhDmL9Mv2Eib3nvRi4HuQOMVMbA=; b=R6E/vs0enFDnFbSsvOtZRVO5S12iSlrnkhs982bSO03RHrVlPa2QkuvuRtruqElqq2 8GgWnwf1NMszX1twLpWl8pFotk6hP+57IStQhjAeWkrjNYMsd1o4LpV6vMvmYpvfDkNa PixzZoufS0cS3DqBTp1VX1aZ7W8N2jSesA9Knppv0ni0HWBP36SUoOEL1kk9uHVlUSMh NR/u4/NIrTLYTqHr5T3xoPhge7oAn9Gj2oEekBKcv2yku+/8S8XLs0epZOOHLTDeuCns 4SDUyetKHcrPMNUeHfsmTf/WBYg34hAe7U6iRQGPsMCqMQx6e1jcdq0Sxz6t1ziK/jzV 7CWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=LoFoBqYB8pssqjd0XhDmL9Mv2Eib3nvRi4HuQOMVMbA=; b=o4jaYWCpSa1klm/OBSprzCFBe7M7Ak/2oOUk5swkx7ek4BQO/DqzKYZCmIEaykV5NC 6dNjZz61oAA/o5HCrNLLT9CNVPo38i5VYbSRLqk6epeIDjfItm4PSAvLFr9Eel5bkuZ/ FKMApS8uEer+//zMpEbHZVZFfr2wxpV2Jc8amQe6glq/67IRDtEaD/Dd0yx9uKo4BVa1 Sfl94PKpLZz3F7Y0mGWcRprFG3CR7BsY3KijdiOilhBqwv65AOCZHKQerDJyNv2pyALr L+6Hc15MieLSsB/BA8FHotvx4ralMOOB0ggvZ1/3RTe5zCBIRm9KyNyXGosrzozFTELv IV+Q== X-Gm-Message-State: ANhLgQ2UupYcdvQNYGI4Q6LD5S63KoGOuCAHqGRjETLPaS7vFc+crtq3 3BThKKEFDII3kEJJGhefWnY= X-Google-Smtp-Source: ADFU+vuZiS2XjjbNvBqfuhAX/7zOa+TYbEjVxoBnDx36kcO9S6c+Jj7dp2Opz/6hRKxJulL9EdQImA== X-Received: by 2002:a05:600c:2188:: with SMTP id e8mr4929587wme.83.1583947765591; Wed, 11 Mar 2020 10:29:25 -0700 (PDT) Received: from [192.168.1.8] (241-57-239-77.dyn.cable.fcom.ch. [77.239.57.241]) by smtp.gmail.com with ESMTPSA id o7sm19330139wrx.60.2020.03.11.10.29.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Mar 2020 10:29:24 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) Subject: Re: Force WAL cleanup on running instance From: =?utf-8?Q?Paul_F=C3=B6rster?= In-Reply-To: Date: Wed, 11 Mar 2020 18:29:23 +0100 Cc: Simon Riggs , krah.tm@gmail.com, pgsql-general Content-Transfer-Encoding: quoted-printable Message-Id: References: <3f91429eb65ac8aa3c77361c587e786a290b92f0.camel@gmail.com> To: Justin X-Mailer: Apple Mail (2.3608.60.0.2.5) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 wrote: >=20 > Question everyone isn't this a problem with the order of operations? >=20 > switching the wal files then running checkpoint means the Checkpoint = can cross wal files, so the previous wal file can not be deleted??? >=20 > To my understanding the order operations should be=20 >=20 > Checkpoint=20 > which flushes everything to disk, then > pg_switch_wal() >=20 > which creates an empty wal file and the previous wal can be deleted? > =20 > http://www.interdb.jp/pg/pgsql09.html#_9.7. > https://www.postgresql.org/docs/current/wal-configuration.html >=20 > Or am i missing something? >=20 > On Wed, Mar 11, 2020 at 11:45 AM Simon Riggs = wrote: > On Wed, 11 Mar 2020 at 08:59, Torsten Krah wrote: > Hi, >=20 > 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. >=20 > When finished I don't need all those wal files anymore and tried to > force the daemon to clean them up and tried this: >=20 > select pg_switch_wal(); > CHECKPOINT; >=20 > and did wait for a minute. >=20 > 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. >=20 > 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. >=20 > The size of the task varies, so sometimes takes longer than 60s, = depending upon your hardware. >=20 > --=20 > Simon Riggs http://www.2ndQuadrant.com/ > PostgreSQL Solutions for the Enterprise