Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msbTd-0001Qh-6a for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Dec 2021 02:05:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1msbTa-0008Io-Ut for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Dec 2021 02:05:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msbTZ-0008If-Qv for pgsql-hackers@lists.postgresql.org; Thu, 02 Dec 2021 02:05:34 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msbTU-00051J-Tg for pgsql-hackers@postgresql.org; Thu, 02 Dec 2021 02:05:32 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 4C4F25C0132; Wed, 1 Dec 2021 21:05:26 -0500 (EST) Received: from imap49 ([10.202.2.99]) by compute5.internal (MEProxy); Wed, 01 Dec 2021 21:05:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eulerto.com; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm3; bh=53moHN1qmPN2Vjtu1qWrIP1AKwAo5dz pRoJzVpXpgNE=; b=NlSUVen1mNKuNKEJWGy86kAlFcqij3sbc9Qpi1rEMDCpv5D p0eLC8oIN9/kzSQzc+EGP+AHcgHFd9Ul5ryXfS5HagXM67Jijbdp1kN1yMkcuTkP GRd+dJl4iwuIK2JRRUWzg8uqPI2nxEPCu6cnG6poZA9uJTrEThAGJUFh5XNTzkRv KBzDyNEwMiJEpKUOfBYkOONesTCl3iiARKC/Fg422wXJR/LooL1M5rMQvWPs3oJF c8IUPA1MstkSyak6n7oKpqlvwjASSvop4tv3+o3pEEIkehBgr0xyNJjyizA/M3X2 nN53i5hcE13sSpeoUoyosICSve+R9AcBhO0DVMg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=53moHN 1qmPN2Vjtu1qWrIP1AKwAo5dzpRoJzVpXpgNE=; b=Ru1IQwowrovoxDBaU471cF 0J1vS7y5+tGUlnsDn8w2cygR2O4mW8Xh7t4b937kbLGDK6TOHTIUfXB09Y07dnIJ FaXQNWx5QddBQF5POBB01O8hpIDU6JFmrXxwmpRogq/GJaptPs55zMIc2ljVgE2p NpV/J5H14R32QFT22MlzYRlXsFdz1XfNANasLvScmVfsTG7pwoPrPkJwIp0dtig0 oWXmThD1HpfPw3YPy8CV1awr5wdmouc21zRRL8XpVW/4ZeHN4UOEfo+sVGnRfLrn mSAX/9lUig66CWXDK8C2MhRu/9MUQRSNUSl5aNQChrT/oN0reGNfb1sO/dF2sEVg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrieeggdegvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsegrtderreerredtnecuhfhrohhmpedfgfhulhgv rhcuvfgrvhgvihhrrgdfuceovghulhgvrhesvghulhgvrhhtohdrtghomheqnecuggftrf grthhtvghrnhepjeethfeuvdfgffdtteevudeftdejueffkeelveekhfevkeegleefhfej hedtjeegnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegvuhhlvghrsegvuhhl vghrthhordgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id E6BECF60073; Wed, 1 Dec 2021 21:05:25 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-4458-g51a91c06b2-fm-20211130.004-g51a91c06 Mime-Version: 1.0 Message-Id: In-Reply-To: References: <20211201225632.wrbrrofm4cbxvnqw@alap3.anarazel.de> Date: Wed, 01 Dec 2021 23:05:03 -0300 From: "Euler Taveira" To: "Bossart, Nathan" , "Andres Freund" Cc: pgsql-hackers Subject: Re: O(n) tasks cause lengthy startups and checkpoints Content-Type: multipart/alternative; boundary=e3cbb1d61b064f6a943aaa052bd8da75 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --e3cbb1d61b064f6a943aaa052bd8da75 Content-Type: text/plain On Wed, Dec 1, 2021, at 9:19 PM, Bossart, Nathan wrote: > On 12/1/21, 2:56 PM, "Andres Freund" wrote: > > On 2021-12-01 20:24:25 +0000, Bossart, Nathan wrote: > >> I realize adding a new maintenance worker might be a bit heavy-handed, > >> but I think it would be nice to have somewhere to offload tasks that > >> really shouldn't impact startup and checkpointing. I imagine such a > >> process would come in handy down the road, too. WDYT? > > > > -1. I think the overhead of an additional worker is disproportional here. And > > there's simplicity benefits in having a predictable cleanup interlock as well. > > Another idea I had was to put some upper limit on how much time is > spent on such tasks. For example, a checkpoint would only spend X > minutes on CheckPointSnapBuild() before giving up until the next one. > I think the main downside of that approach is that it could lead to > unbounded growth, so perhaps we would limit (or even skip) such tasks > only for end-of-recovery and shutdown checkpoints. Perhaps the > startup tasks could be limited in a similar fashion. Saying that a certain task is O(n) doesn't mean it needs a separate process to handle it. Did you have a use case or even better numbers (% of checkpoint / startup time) that makes your proposal worthwhile? I would try to optimize (1) and (2). However, delayed removal can be a long-term issue if the new routine cannot keep up with the pace of file creation (specially if the checkpoints are far apart). For (3), there is already a GUC that would avoid the slowdown during startup. Use it if you think the startup time is more important that disk space occupied by useless files. For (4), you are forgetting that the on-disk state of replication slots is stored in the pg_replslot/SLOTNAME/state. It seems you cannot just rename the replication slot directory and copy the state file. What happen if there is a crash before copying the state file? While we are talking about items (1), (2) and (4), we could probably have an option to create some ephemeral logical decoding files into ramdisk (similar to statistics directory). I wouldn't like to hijack this thread but this proposal could alleviate the possible issues that you pointed out. If people are interested in this proposal, I can start a new thread about it. -- Euler Taveira EDB https://www.enterprisedb.com/ --e3cbb1d61b064f6a943aaa052bd8da75 Content-Type: text/html Content-Transfer-Encoding: quoted-printable
On Wed, Dec 1, = 2021, at 9:19 PM, Bossart, Nathan wrote:
On 12/1/21, 2:56 PM, "Andres Freund" <<= a href=3D"mailto:andres@anarazel.de">andres@anarazel.de> wrote:
> On 2021-12-01 20:24:25 +0000, Bossart, Nathan wrote:
>> I realize adding a new maintenance worker might be= a bit heavy-handed,
>> but I think it would be nice= to have somewhere to offload tasks that
>> really s= houldn't impact startup and checkpointing.  I imagine such a
>> process would come in handy down the road, too.  W= DYT?
>
> -1. I think the overhead of a= n additional worker is disproportional here. And
> ther= e's simplicity benefits in having a predictable cleanup interlock as wel= l.

Another idea I had was to put some upper= limit on how much time is
spent on such tasks.  For = example, a checkpoint would only spend X
minutes on CheckP= ointSnapBuild() before giving up until the next one.
I thi= nk the main downside of that approach is that it could lead to
=
unbounded growth, so perhaps we would limit (or even skip) such tas= ks
only for end-of-recovery and shutdown checkpoints. = ; Perhaps the
startup tasks could be limited in a similar = fashion.
Saying that a certain task is O(n) d= oesn't mean it needs a separate process to
handle it. Did = you have a use case or even better numbers (% of checkpoint /
<= div>startup time) that makes your proposal worthwhile?
I would try to optimize (1) and (2). However, delayed remova= l can be a
long-term issue if the new routine cannot keep = up with the pace of file
creation (specially if the checkp= oints are far apart).

For (3), there is already= a GUC that would avoid the slowdown during startup.
Use i= t if you think the startup time is more important that disk space occupi= ed
by useless files.

For (4),= you are forgetting that the on-disk state of replication slots is
stored in the pg_replslot/SLOTNAME/state. It seems you cannot j= ust rename the
replication slot directory and copy the sta= te file. What happen if there is a
crash before copying th= e state file?

While we are talking about it= ems (1), (2) and (4), we could probably have an
option to = create some ephemeral logical decoding files into ramdisk (similar to
statistics directory). I wouldn't like to hijack this thread= but this proposal
could alleviate the possible issues tha= t you pointed out. If people are
interested in this propos= al, I can start a new thread about it.


=
--
Euler Taveira

--e3cbb1d61b064f6a943aaa052bd8da75--