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 1uB7xN-006prB-Er for pgsql-hackers@arkaria.postgresql.org; Sat, 03 May 2025 08:10:45 +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 1uB7xK-00E3j2-Qm for pgsql-hackers@arkaria.postgresql.org; Sat, 03 May 2025 08:10:43 +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 <3danissimo@gmail.com>) id 1uB7xK-00E3iu-H7 for pgsql-hackers@lists.postgresql.org; Sat, 03 May 2025 08:10:43 +0000 Received: from mail-yb1-xb35.google.com ([2607:f8b0:4864:20::b35]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from <3danissimo@gmail.com>) id 1uB7xJ-000pys-1Q for pgsql-hackers@lists.postgresql.org; Sat, 03 May 2025 08:10:43 +0000 Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-e6df1419f94so2029385276.0 for ; Sat, 03 May 2025 01:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746259839; x=1746864639; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=IGJsCC4wX/GdQRpqXBQTjkkLlvTULAq7Z/Bl9Op9bp4=; b=bw3TVYeuACryR/bx+PHef/FqEWR3FkMDwp23TLnpzWn6/IoPcNaxw5UWh0KYWQB4+4 xETRQgtlZL1gjXjJOpQ8HNMnfz9xuwSCvdJncDwQsWx7YPX9DDuu1v/8y2abbHx/lHLB rcosUDy8j5oxsrr5XfvSGEq/22Q7N2bu4Ijs1tIr77GH/HU+310yKSA4ADFKTtnox6Rz /CyPsEx4dOgnOuXmqJ1nK4RSJaWV9Lo0ELkw2p2lDFIonVsLeXbCvDMLgXq+RiGzxera C0+Gd0hiG1MBc0mtfetARukZAQ1f9RfhxC2U0GbBFCpqIz6N9ecBiIjt9yG6hX06V2Dc 7/9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746259839; x=1746864639; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IGJsCC4wX/GdQRpqXBQTjkkLlvTULAq7Z/Bl9Op9bp4=; b=OS9piFe+2e0W3q1c4p+Pcgtye/1Q2qcibslx2GUg1X7irvo26DbM6Sd+P7ic7cpj8s gd4WujG8m3c7dYTVoHQyvQ0YaFk0PccDyawW+j523qIJ50bCjOMWzcSODjRgEkIIxaLf S5Z48zvWQ7C2i59+iebD8NrDe+Z4Yxg/0U7385i+tDR33lMgw5wFEhJzyC4f5GqJHVxF mCrA4WWf00v406jYywZGVxw2y+QVn4rrYu0C6raS2+pPjOtH9D+owYFeXyVb7lmTWpJH WGxYWnggwN1/OOzwO6f9Kvfb0sy4yRRUz4E/KkrgDhyg5Glh5csAPDz+oLnVXz7ZJt49 XOFg== X-Forwarded-Encrypted: i=1; AJvYcCXjOt6VYvX2wnYWmNwUZQ7LVgCl3Jl114OKxXWL1p7pIWZpLWEKzo+q6morusHMkZcnsUkkIGgk6kDuPq6o@lists.postgresql.org X-Gm-Message-State: AOJu0Ywj0eeMKnx9H7eDtgxsz1c4t4Dmb8OBSUTe31N/EKYL6U/50sSG P8pQWtnboAAGM/mT7h9c5zlUZNC1W5dIuFQNcQvOQJKr7ngSvXMf4jCS2c/FRGgZC5xVGf5+nUq 3UU53lpz5b7AQL40fok4Tnl2qt/n5mXi47l7RBw== X-Gm-Gg: ASbGncsnoKAUcO1ueFa9a2wPN/XQc226PppG+3HNYBnaHabNd+B+D/dJJI9ABN32a9r fklnibCVW7EKARPc7rgxBUzq3na2UM6Gm5g/bYimj6AFVH5G/dMGjHWT3UMjIIb5jZwyIxZSkl6 0ObGsenKsHmNRg+jtHD6kWPDQ= X-Google-Smtp-Source: AGHT+IGk/R1UB87EP73JMM4uePXwyeW8Mivmx0a7ulHgEDw8jq2PpzVCiEyzG4OKFx2ZdpMudZQoZdDSnt/3c0V0Ptk= X-Received: by 2002:a05:6902:f88:b0:e61:1c56:d678 with SMTP id 3f1490d57ef6-e757d0c37c2mr286680276.5.1746259839527; Sat, 03 May 2025 01:10:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Daniil Davydov <3danissimo@gmail.com> Date: Sat, 3 May 2025 15:10:27 +0700 X-Gm-Features: ATxdqUHk0vUoTOEumtULd2WQIzkVQTVcS1MdgL_2SLhXyVeUtpe9imhA7eZ5HQ0 Message-ID: Subject: Re: POC: Parallel processing of indexes in autovacuum To: Masahiko Sawada Cc: Maxim Orlov , Postgres hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, May 3, 2025 at 5:28=E2=80=AFAM Masahiko Sawada wrote: > > > In current implementation, the leader process sends a signal to the > > a/v launcher, and the launcher tries to launch all requested workers. > > But the number of workers never exceeds `autovacuum_max_workers`. > > Thus, we will never have more a/v workers than in the standard case > > (without this feature). > > I have concerns about this design. When autovacuuming on a single > table consumes all available autovacuum_max_workers slots with > parallel vacuum workers, the system becomes incapable of processing > other tables. This means that when determining the appropriate > autovacuum_max_workers value, users must consider not only the number > of tables to be processed concurrently but also the potential number > of parallel workers that might be launched. I think it would more make > sense to maintain the existing autovacuum_max_workers parameter while > introducing a new parameter that would either control the maximum > number of parallel vacuum workers per autovacuum worker or set a > system-wide cap on the total number of parallel vacuum workers. > For now we have max_parallel_index_autovac_workers - this GUC limits the number of parallel a/v workers that can process a single table. I agree that the scenario you provided is problematic. The proposal to limit the total number of supportive a/v workers seems attractive to me (I'll implement it as an experiment). It seems to me that this question is becoming a key one. First we need to determine the role of the user in the whole scheduling mechanism. Should we allow users to determine priority? Will this priority affect only within a single vacuuming cycle, or it will be more 'global'? I guess I don't have enough expertise to determine this alone. I will be glad to receive any suggestions. > > About `at_params.nworkers =3D N` - that's exactly what we're doing (you > > can see it in the `vacuum_rel` function). But we cannot fully reuse > > code of VACUUM PARALLEL, because it creates its own processes via > > dynamic bgworkers machinery. > > As I said above - we don't want to consume additional resources. Also > > we don't want to complicate communication between processes (the idea > > is that a/v workers can only send signals to the a/v launcher). > > Could you elaborate on the reasons why you don't want to use > background workers and avoid complicated communication between > processes? I'm not sure whether these concerns provide sufficient > justification for implementing its own parallel index processing. > Here are my thoughts on this. A/v worker has a very simple role - it is born after the launcher's request and must do exactly one 'task' - vacuum table or participate in parallel index vacuum. We also have a dedicated 'launcher' role, meaning the whole design implies that only the launcher is able to launch processes. If we allow a/v worker to use bgworkers, then : 1) A/v worker will go far beyond his responsibility. 2) Its functionality will overlap with the functionality of the launcher. 3) Resource consumption can jump dramatically, which is unexpected for the user. Autovacuum will also be dependent on other resources (bgworkers pool). The current design does not imply this. I wanted to create a patch that would fit into the existing mechanism without drastic innovations. But if you think that the above is not so important, then we can reuse VACUUM PARALLEL code and it would simplify the final implementation) -- Best regards, Daniil Davydov