Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uA9Mj-00BO0i-S9 for pgsql-hackers@arkaria.postgresql.org; Wed, 30 Apr 2025 15:28:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uA9Mh-00Eg2E-An for pgsql-hackers@arkaria.postgresql.org; Wed, 30 Apr 2025 15:28:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uA9Mh-00Eg25-10 for pgsql-hackers@lists.postgresql.org; Wed, 30 Apr 2025 15:28:52 +0000 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uA9Mg-000NcP-17 for pgsql-hackers@lists.postgresql.org; Wed, 30 Apr 2025 15:28:51 +0000 Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-86135d11760so647877939f.2 for ; Wed, 30 Apr 2025 08:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746026928; x=1746631728; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=sxrzqyeDxOwu5Zf0Ms5uxpw+dV3dsyu8JwAH5VHuLH4=; b=VzkZwaCifF+xMYX9T4l/2+WNOWWel1iByITdxbzw+I+Uc74OJr80LPrH9qO2HIPQnq OjgU3KKl9dSiqGd3lXV3F51O5rFBns/eGq9QBl+IgAquRY5OJRUjMiaooufEzPLEcVf5 1Ndul/OYdtNbUqH7267Xnd/V/TRmbUhDJZClm0UCMxDDU5ZkOuCK1fRMWmWB46pNvNBK 1M6MBQPC/37G6UN4SPeZT+n0U+9ZDJRBjNj60VY05N9rM8Yl9Pg8m7DlVuC8FJ/hokew ynJRUeOZxOo77WWFJbunqM+4JsASqdTTInuDglzcfhP2zzTOgsnhyrK0Hmv/3Z+KzJ07 UCkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746026928; x=1746631728; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=sxrzqyeDxOwu5Zf0Ms5uxpw+dV3dsyu8JwAH5VHuLH4=; b=v6OhlaxahMmui7DKy6e2TjLjGUAyE+EzvLL4qP3AUIRNYWmeUSxlQOUbUlxRnnn315 FbQQypk3bmEFpiyc+o6PfKSoQyXh1qTKjDwGaP/WMA+y+NaqpZV8aEKavPmJ9KP3j3/R rUcXXzKaAYJeUE4a5YjPDV592rGZLKSMNNXAJgL9MKi890pPnGj8Br/lBTteLpIViJS+ qB08do0GjnBkkwrgpEvPIQvGjbRCrLYWyIuOe8l6b8gD747nnMG87+9N/OCbhXgjl3BZ HX0NrR7sqG2hR8y04Qi41HnJKb5Wg8fDPgqqNcTaArqdQmfM6GSY6eE1K64bUgnKzV2D eQhw== X-Gm-Message-State: AOJu0YwGLfQ0M5cyI/sWY27Dqa8hIQHqXnx81kdFZwF8uOGwjBmXWnrd cknsi6NC/RUt8bHet6H6SxcbSotkijEefjqiWMnNjz+Pu7ZnV2WG X-Gm-Gg: ASbGncsg4LztKtczHY/alniBpbIycm0MyqpAm1fIEX4JzF5piU42uAka8zUh94GJRr1 BVZYwqb16r8NYuaE900xdqISKVQiqyZdxWIpJ8uBGYohnkHdcXoK4CQyjxbIuTO8vOngftsevaE YA91QwrWYjHWiY7uLUmKBqV6GwuvuNTwWmCnNhmXOkRV7i4RgiE0CQpDCKhsBc/ZX/pT4W1cizr nBCGMA0jW+WgiK+1laCTLcxW++dur4xFC/YBk49ROM/6nVSFXreCbbzsuuR4TlXh3gTx03cucOc 9XmuXveT7VXEQiYvHjtQWodOwnQAYbTGxIBr7lLreYcgVqgwEmBN5w9zIFqpzS09WexI0Hr/uY6 X+4ZYU+ItvI6P1kes3AYCKNoRBwFESxk= X-Google-Smtp-Source: AGHT+IGJyC+6GOyk9YKVNx1wywjX6xoXozAX3d2ms8nohUGlgTKJV8Dk/YqRta2/pFId7+G/VPbrdQ== X-Received: by 2002:a05:6602:4147:b0:861:628f:2d2b with SMTP id ca18e2360f4ac-86495e173fbmr477004139f.1.1746026928238; Wed, 30 Apr 2025 08:28:48 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-8648bf05b89sm72273639f.9.2025.04.30.08.28.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Apr 2025 08:28:47 -0700 (PDT) Date: Wed, 30 Apr 2025 10:28:45 -0500 From: Nathan Bossart To: Junwang Zhao Cc: PostgreSQL Hackers Subject: Re: Introduce some randomness to autovacuum Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Apr 25, 2025 at 10:02:49PM +0800, Junwang Zhao wrote: > After watching Robert's talk[1] on autovacuum and participating in the related > workshop yesterday, it appears that people are inclined to use prioritization > to address the issues highlighted in Robert's presentation. Here I list two > of the failure modes that were discussed. > > - Spinning. Running repeatedly on the same table but not accomplishing > anything useful. > - Starvation. autovacuum can't vacuum everything that needs vacuuming. > - ... > > The prioritization way needs some basic stuff that postgres doesn't have now. > > I had a random thought that introducing some randomness might help > mitigate some of the issues mentioned above. Before performing vacuum > on the collected tables, we could rotate the table_oids list by a random > number within the range [0, list_length(table_oids)]. This way, every table > would have an equal chance of being vacuumed first, thus no spinning and > starvation. > > Even if there is a broken table that repeatedly gets stuck, this random > approach would still provide opportunities for other tables to be vacuumed. > Eventually, the system would converge. First off, thank you for thinking about this problem and for sharing your thoughts. Adding randomness to solve this is a creative idea. That being said, I am -1 for this proposal. Autovacuum parameters and scheduling are already quite complicated, and making it nondeterministic would add an additional layer of complexity (and may introduce its own problems). But more importantly, IMHO it masks the problems instead of solving them more directly, and it could mask future problems, too. It'd probably behoove us to think about the known problems more deeply and to craft more targeted solutions. -- nathan