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 1jZKjG-000275-Ee for pgsql-general@arkaria.postgresql.org; Thu, 14 May 2020 20:45:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jZKjF-0002uh-Bm for pgsql-general@arkaria.postgresql.org; Thu, 14 May 2020 20:45:17 +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 1jZKjE-0002ua-Tk for pgsql-general@lists.postgresql.org; Thu, 14 May 2020 20:45:17 +0000 Received: from sonic308-9.consmr.mail.ne1.yahoo.com ([66.163.187.32]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jZKjB-0003Bk-Dg for pgsql-general@postgresql.org; Thu, 14 May 2020 20:45:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1589489109; bh=SiidwjBF9JNPD+0X5dMCp9eORLZUgrqE27dNXhxKXiA=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=l7irGeYmcrMF5FJO9ih1tyk3FyJ5Ppjf3sIkGQWO4GzNgVcBqtt3a6ONYTlfO3etsbpB7NtOhmxJwnwYFu+cz7Ofm4A6JPfj475TT2UyaFXuMapRwagRHGTjcN8rX77NlyLklTSmR/AQOciVwpN4qimfn/wL7Pjvxb0/W7+TwqLpvIv/URQLRtgBiEgoJm51GuMgqE9Xz4npsOL+XnBVtlpY53UqgwluvjALAiacEWcxMzkR0h0i/6xYVEaCycnZH8NriH8ZzGdmW5SlhMAQhFWQ7i6NdSmdqjP3TpVc7LRB8W3tGgyg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8rhYZ4JQ12E7T56edUyM ZmVaSyaS6pJxKGwbZtOa9MngXNKxwm.8QpOv6TWo4RbSBhW4Io9i4.PYp9Kx7HgdfrFIMhyxAq5_ mAJUfaRitDy77HKle1y1hGyG4.oWxTQbeH6fxJw.325S4u2_nIEtgHfqivnEXnEkP1kXNKVE.UOI NZiPS1pFFUU06e.tR_7HgVbJBl.oImRycP79925syVorYgPgqhftSctvxNvIKn_E.3ESpNW9EqdH wbcM3B4ePE_znQZmwNmXfFUIo8czMKoixyJFO4pw7U6tYE7pTzSQNcOg716TeNJ825k4tsBx_mMb ysiZuMQMlXfX_fgrw34yXUW7pZeVKjX7Ie2wa5w54 Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ne1.yahoo.com with HTTP; Thu, 14 May 2020 20:45:09 +0000 Date: Thu, 14 May 2020 20:45:06 +0000 (UTC) From: Virendra Kumar Reply-To: Virendra Kumar To: Adrian Klaver , Eduard Rozenberg Cc: pgsql-general@postgresql.org Message-ID: <1986950400.430297.1589489106304@mail.yahoo.com> In-Reply-To: <05EFC29A-795C-44DD-8D0B-14C579A9F876@gmail.com> References: <4C3B3D43-F3BE-4BE7-A812-E3FB4E43236A@gmail.com> <3E4B3E2A-CBBE-472A-8FDE-C1A9538F2DF0@gmail.com> <20790094-993c-a00b-3246-25a9f04539a6@aklaver.com> <05EFC29A-795C-44DD-8D0B-14C579A9F876@gmail.com> Subject: Re: vacuumdb --jobs deadlock: how to avoid pg_catalog ? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_430296_1299325917.1589489106302" X-Mailer: WebService/1.1.15941 YMailNorrin Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0 Content-Length: 8766 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_430296_1299325917.1589489106302 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable You might have index fragmentation and possibly reindexing them conncurrent= ly on PG12, should do that. As everyone agreed most of space will be marked= for re-use later for table segments but indices in your case could be prob= lem. On previous versions you can use pg_repack to do index rebuilds which = will help reduce space consumed. Regards, Virendra=20 On Thursday, May 14, 2020, 1:20:41 PM PDT, Eduard Rozenberg wrote: =20 =20 @Adrian thanks again. I read the postgres docs the same way - that previously used space is marke= d as available and therefore no need for vacuum full. Previously used =3D n= ow available space, which gets re-used, in theory. And yet this same DB is growing at 30-50 GB weekly, despite the fact that 2= .4 TB of previously used space is clearly available ("clearly available" as= proven by vacuum full shrinking the DB space usage by 2.4 TB). I did verif= y postgresql.conf has always been properly configured re: autovacuum:=C2=A0= 'autovacuum =3D on'and 'track_counts =3D on' I'm not planning on running VACUUM FULL regularly, just "this one time". An= d I was trying to to parallelize VACUUM FULL and minimize downtime of the p= roduction DB caused by table locking. And then I found the option of using = "vacuumdb --jobs" which sounded like the perfect solution except for "well = you can't actually use --jobs because you'll run into a deadlock and everyb= ody knows that and nobody has a (good) solution for it" :). --Ed > On May 14, 2020, at 11:46, Adrian Klaver wrot= e: >=20 > On 5/14/20 11:27 AM, Eduard Rozenberg wrote: >> @Adrian thanks. >> I did a test vacuum full the "normal" non-parallel way (VACUUM FULL sql)= previously on a test db copy and saw the DB size (postgres 9.6) shrink fro= m 6.8 TB to 4.4 TB of actual, real disk space usage ($ df -d 1). >> I don't know the reason so much space was "locked up" (other than there = is a lot of data "churn" from daily updates). But I definitely do need to d= o the vac full on the production db to get down to the smaller size - canno= t afford the 2.4 TB of "wasted" space on an ongoing basis. >=20 > It may not be wasted space. A regular VACUUM marks space within a table a= vailable for reuse(and not returned to OS) when it removes unneeded tuples.= It then fills that space up with new tuples, roughly speaking. So if the v= acuuming is working properly you will reach a steady state where space is r= eused and the database on disk size grows slowly as reusable space is occup= ied. I would monitor the database size on a regular basis. My guess is that= the VACUUM FULL is dropping the OS used space and then it fills up again a= s the database does those updates. >=20 >> Based on your email it sounds like the vacuuming of those pg_catalog.* t= ables is done regardless, as a normal part of doing vac full on my own data= base. >> Unfortunately I still don't see an ideal way to run vacuum full in paral= lel via vacuumdb without running into the expected and documented deadlock.= Only method I'm aware of is to list each table individually with "-t table= 1 -t table2..." to "vacuum db --jobs" which is not pleasant and not exceedi= ngly beautiful. >> Thanks. >=20 >=20 > --=20 > Adrian Klaver > adrian.klaver@aklaver.com =20 ------=_Part_430296_1299325917.1589489106302 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
You might have index fragmen= tation and possibly reindexing them conncurrently on PG12, should do that. = As everyone agreed most of space will be marked for re-use later for table = segments but indices in your case could be problem. On previous versions yo= u can use pg_repack to do index rebuilds which will help reduce space consu= med.

Regards,
Virendra


=20
=20
On Thursday, May 14, 2020, 1:20:41 PM PDT, Eduard Rozen= berg <edrozenberg@gmail.com> wrote:


@Adrian thanks again.

I read the postgres docs the same way - that previous= ly used space is marked as available and therefore no need for vacuum full.= Previously used =3D now available space, which gets re-used, in theory.
And yet this same DB is growing at 30-50= GB weekly, despite the fact that 2.4 TB of previously used space is clearl= y available ("clearly available" as proven by vacuum full shrinking the DB = space usage by 2.4 TB). I did verify postgresql.conf has always been proper= ly configured re: autovacuum:  'autovacuum =3D on'and 'track_counts = =3D on'

I'm not planning on running VA= CUUM FULL regularly, just "this one time". And I was trying to to paralleli= ze VACUUM FULL and minimize downtime of the production DB caused by table l= ocking. And then I found the option of using "vacuumdb --jobs" which sounde= d like the perfect solution except for "well you can't actually use --jobs = because you'll run into a deadlock and everybody knows that and nobody has = a (good) solution for it" :).

--Ed

> On May 14, 2020, at 11:46, Adrian Klaver &= lt;adrian.klaver@aklaver.com> wrote:
>
> On 5/14/20 11:27 AM, Eduard Rozenberg w= rote:
>> @Adrian thanks.
>>= I did a test vacuum full the "normal" non-parallel way (VACUUM FULL sql) p= reviously on a test db copy and saw the DB size (postgres 9.6) shrink from = 6.8 TB to 4.4 TB of actual, real disk space usage ($ df -d 1).
>> I don't know the reason so much space was "locked up" (other= than there is a lot of data "churn" from daily updates). But I definitely = do need to do the vac full on the production db to get down to the smaller = size - cannot afford the 2.4 TB of "wasted" space on an ongoing basis.
>
> It may not be wasted space. A re= gular VACUUM marks space within a table available for reuse(and not returne= d to OS) when it removes unneeded tuples. It then fills that space up with = new tuples, roughly speaking. So if the vacuuming is working properly you w= ill reach a steady state where space is reused and the database on disk siz= e grows slowly as reusable space is occupied. I would monitor the database = size on a regular basis. My guess is that the VACUUM FULL is dropping the O= S used space and then it fills up again as the database does those updates.=
>
>> Based on your email it = sounds like the vacuuming of those pg_catalog.* tables is done regardless, = as a normal part of doing vac full on my own database.
&g= t;> Unfortunately I still don't see an ideal way to run vacuum full in p= arallel via vacuumdb without running into the expected and documented deadl= ock. Only method I'm aware of is to list each table individually with "-t t= able1 -t table2..." to "vacuum db --jobs" which is not pleasant and not exc= eedingly beautiful.
>> Thanks.
&g= t;
>
> --
&g= t; Adrian Klaver
> adrian.klaver@a= klaver.com


------=_Part_430296_1299325917.1589489106302--