Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsHFd-00033T-2O for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Aug 2018 00:43:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fsHFa-0004o4-W5 for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Aug 2018 00:43:54 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsHFY-0004nw-Ub for pgsql-hackers@lists.postgresql.org; Wed, 22 Aug 2018 00:43:54 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsHFQ-0006Uq-MT for pgsql-hackers@postgresql.org; Wed, 22 Aug 2018 00:43:52 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 68545212C8; Tue, 21 Aug 2018 20:43:42 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 21 Aug 2018 20:43:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=1kPmyC+zPssCSEtxPPDrIP99/WV2VwCigSavBt9qFzY=; b=tUJhL0wc T9U+A1vgV3lJIXbH/Ww5MO9slnBlDfeYcUF7SjgpdSsXMCyzVJjywJH0a11pzk7+ vreVHKsdRJXq2gbl0n1s4pGAfl1a3qA7RBPeUaGx73NzSDD2rDPyGI0LdHu3Zn3R NZCyKmu4zHMm6go04jSKqoiAuyVUBRwQss37nNpm04dlf+j1SII1D5zNA3qmdVc4 P9epyjgjpbUjvJSfN5aODifbVzs/7XPGWxSYMJYriKKO7Ho036HHPCS/VH0spvTm Cu7X+JyygBewHPjoXLnywwZZy5GoweuBHujy5PQGULYyppGbK0BzDJPST0dqlFNl T2sk+VWZbZegpA== 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-sender :x-me-sender:x-sasl-enc; s=fm3; bh=1kPmyC+zPssCSEtxPPDrIP99/WV2V wCigSavBt9qFzY=; b=cWoQVD7IAf7YWrtzIlTwmhA9QYdCmkqzKDvswta2sRVgC vjqOYDUwIMhXorzEpR5NEkJovek2Dm9wsF6wCQjpmPOCzCJYBkmpKJSp5c+nr8xx 93i1YspPzEdxtw/0K4/JItGNZ4I1pCIYlUE5xdRRN7m/cfKIVobmAqYpyc6YA4pz GIHcQbj5k0CxfH9VBLhGYWKFfzb6+FwBGTBsMzGzyqBg8O5VsJ6tn9bd8LjijlIY CSYZjmi5NeDWuc0GQJ5isoBAsGfjU8vqAFAJv8IiHapRk3ETDFeSN4JjiXDVk9x+ PEI35ztbjwjpHTyfoq3oI3x2/VydlRES+rWTvGnGA== X-ME-Proxy: X-ME-Sender: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 6A4E110289; Tue, 21 Aug 2018 20:43:39 -0400 (EDT) Date: Wed, 22 Aug 2018 09:43:35 +0900 From: Michael Paquier To: "Bossart, Nathan" Cc: Postgres hackers , "horiguchi.kyotaro@lab.ntt.co.jp" Subject: Re: Improve behavior of concurrent ANALYZE/VACUUM Message-ID: <20180822004335.GA4333@paquier.xyz> References: <20180812222142.GA6097@paquier.xyz> <20180817064223.GH1693@paquier.xyz> <720DF5E4-053F-46C7-B11F-550EF2C39F6D@amazon.com> <20180821012815.GB2897@paquier.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="LQksG6bCIzRHxTLp" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --LQksG6bCIzRHxTLp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 21, 2018 at 04:01:50PM +0000, Bossart, Nathan wrote: > I think my biggest concern with this approach is that we'd be > introducing inconsistent behavior whenever there are concurrent > changes. If a user never had permissions to VACUUM the partitioned > table, the partitions are skipped outright. However, if the user > loses permissions to VACUUM the partitioned table between > expand_vacuum_rel() and vacuum_rel(), we'll still attempt to VACUUM > each individual partition. >=20 > I'll admit I don't have a great alternative proposal that doesn't > involve adding deadlock risk or complexity, but it still seems worth > mulling over. That counts only for a manual vacuum/analyze listing directly the relation in question. If running a system-wide VACUUM then all the relations are still processed. This is a rather edge case in my opinion but.. I don't mind mulling over it (as you say). So please let me think over it for a couple of days. I don't see a smart solution which does not create risks of lock upgrades and deadlocks now, there may be one able to preserve the existing behavior. >> I have split the patch into two parts: >> - 0001 includes new tests which generate WARNING messages for VACUUM, >> ANALYZE and VACUUM (ANALYZE). That's useful separately. >=20 > 0001 looks good to me. Thanks, I have pushed this one. >> - 0002 is the original patch discussed here. >=20 > I'd suggest even splitting 0002 into two patches: one for refactoring > the existing permissions checks into vacuum_is_relation_owner() and > another for the new checks. Hmmm. The second patch changes also some comment blocks when calling vacuum_is_relation_owner(), so we finish by changing the same code areas, resulting in more code churn for no real gain. > +# The role doesn't have privileges to vacuum the table, so VACUUM should > +# immediately skip the table without waiting for a lock. >=20 > Can we add tests for concurrent changes that cause the relation to be > skipped in vacuum_rel() and analyze_rel() instead of > expand_vacuum_rel()? Doing that deterministically with concurrent tests look difficult to me as doing ALTER TABLE OWNER TO to a relation in a first session causes a second session running VACUUM to block in expand_vacuum_rel(), be it with a plain table or a partitioned table (doing the ALTER TABLE on a leaf will block scanning the parent as well). -- Michael --LQksG6bCIzRHxTLp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlt8sbcACgkQnvQgOdby QH3KHw//TWuC0lfBfBbfEmNvVkG07aunsaXjxcmeFrNTFzkNUAPiycb2fEg853Ri lDfixWix+cSAOG7zQKtC7+/Yx/bFilY3NVmZ0YG7BDQWzSWCdqnpBpP1wNBcknuw k7zq6vBH01PuKRwBvK5R9h+LJkWYbpOUI/udMHMSGudJQcLhtcP8OkVPY2fHRiBV rPuv4riUt3ntkucVjAuDxXowp92GXvV2YOZnSoEYuwn0rPKiM7ncYCTKsGx3UI0l MrQUrJDmnAijBKP/34o1D8GdVRkWVFF+DAkWuoIIZLYkwBFCox8A+Wk1VxtRLaVZ OPPW7TWupCFJxdp2J74GzLM8E/WRHNqM2dOwbPqzWsttemCtbfWJ9EFcEpLHfDVH BJTsdrKHCHnAo+FMSXKvXeTXl1N5yljXXjVekNqTrbcZRENYyT9SpOaOuZR+/yB9 YJhymETYDwLiZAIBGMkE9AKKAL/xCpkK8WTtMknSIjnkTXDvRylU6zQMLlWG/QjS 7Wn9Ii+ljV/eUNWY0dIO3esPmq58PJL7Tq0onJyxIFRKBA+Wltj/SWTiiI99XA7j uGCriQ+BqyFPD3SPjkHo4+NakG7f3TPM+IgfRHrBevdIWmgmiQ/dNObhF41MMKb9 XSP9q8RTfjA51BJo5ZF6eMoEU1Q1N0S2F7RkwplNRrEwuk6pKNg= =3hVQ -----END PGP SIGNATURE----- --LQksG6bCIzRHxTLp--