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 1udtZA-002AyI-58 for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jul 2025 16:40:41 +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 1udtZ8-001rlg-0x for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jul 2025 16:40:38 +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 1udtZ7-001rlX-MX for pgsql-hackers@lists.postgresql.org; Mon, 21 Jul 2025 16:40:38 +0000 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1udtZ4-0004R3-1o for pgsql-hackers@lists.postgresql.org; Mon, 21 Jul 2025 16:40:37 +0000 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-32b78b5aa39so43143771fa.1 for ; Mon, 21 Jul 2025 09:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753116034; x=1753720834; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=tVRuCbiBN0n3ZH/Isk6y1j7Tynix2zaGMGyh1J4hDM8=; b=fBYBuPbW+A4l9sKlpoMhIYT0zwXCuSXb7ZW8yoz3SlV0U4ntb/LzwZa6EChteaGUR6 vSMtQ1ctfGloyJ3ATnPjBddAxVQ4yVo8irjuwwR59xI2c6SwsV8kNXAynaep4ZiQKAi4 d0p6e5hi47XYVrwskgtRDSq07/DcdFIYKhhBXIWfY1k/e3AlrtkRJjBqXzkGsdI5oSOR rQ8Nc0/ZPBdahzNwsAbw6MXZ+BcWdsIZQ1OJ8KhzJWteYvvjTLewOuFqCqHsSB52VYFM 8gTkp2gqn15FtV9IiWPFlcE+2TelhnlIhakV6K6u95uMCKoMucGEQgwGrwH+qEcEbUiE 2IGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753116034; x=1753720834; h=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=tVRuCbiBN0n3ZH/Isk6y1j7Tynix2zaGMGyh1J4hDM8=; b=QY+6+tnZzhjvq2Q6nDADdl25VRksE06z+NJZ5w7myseL9WOYzv2RZibViArQ3dZCCg ubOiQ2jX5nCLMB5d2Itm7DMnM63GZ3WrQ5th7edQmkthUMW9lf749KauueXJziv1/DiR 3DV0lyyzberyC2S7cHAdHNt6m+xdJgOfNC9G2HWyY0yj92Wa23nHSFnL5cLdfArFwKBj MSlVf79vPJip1Wn6sRuortcU986pPGhvUs8EhYifhfSOITe0wWC1JL7z/bGSlKcARBCD 001xtLrN8tZxDnPmpjlwsTapCnY9dQ6TtxtmxTyUIY9g6+g1Nj1tFsnR2GHnSm6MGXZG 5amg== X-Forwarded-Encrypted: i=1; AJvYcCXip1mh5yEgXG7fEhHFCGssNxer1wyGbNGtpYRz4poJaVkoeSMKaJHHu8xQJnyGArKrkKkHOq5UtHD8aUjI@lists.postgresql.org X-Gm-Message-State: AOJu0YyIDyqOufZMJ2kXvY0WFyjAEBcm0FUB/zA+wZgqm1iXXk/NSzR9 VoFXx2LaR7/dAtAjJlbljjl1Ta0jq8SOTEhVtvgI4kz1E4S2DaHqQngTfB5asE03UL5QYrHA3ry hQs2+TjuDr23I9ZHPj6BllLY08wzfHhE= X-Gm-Gg: ASbGncs5Cm9E3TbrabmC/84EKKL6dTz+DQKbHTrpXldOVq2cwyFIt/qESzbhBEdnvt+ TkaM9CzP6X0orEGOLDeHxdXiJfoFBoDsWQMj3ATJT4nZfW6W+V19y6G1Bx6NxwGtnw0hLoTKJyj sFxlkt/r5HjR9NCYn6AVIlziHD4Rst1f9G8OcviGGP5dwoXu7uAE0M8GclcDlVRrLDOUTYaMBEI uBeiOs= X-Google-Smtp-Source: AGHT+IF2OhVne96XSSodsfX2T4eBTfhfgLHSwJnB58ALgvMp+liPl7Nsn5eytmcbqjKgk6aCgoN7sL2+H//JXlJ2Ie4= X-Received: by 2002:a2e:a99f:0:b0:32a:7315:fff3 with SMTP id 38308e7fff4ca-3308f6061camr59959591fa.35.1753116034243; Mon, 21 Jul 2025 09:40:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Sami Imseih Date: Mon, 21 Jul 2025 11:40:22 -0500 X-Gm-Features: Ac12FXwL_tm6cbmyo5s8Exfht6vGcsnsYKE7sMnjnNFDnj095qtTh-A-fU9O-U0 Message-ID: Subject: Re: POC: Parallel processing of indexes in autovacuum To: Daniil Davydov <3danissimo@gmail.com> Cc: Masahiko Sawada , Matheus Alcantara , Maxim Orlov , Postgres hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks for the patches! I have only reviewed the v8-0001-Parallel-index-autovacuum.patch so far and have a few comments from my initial pass. 1/ Please run pgindent. 2/ Documentation is missing. There may be more, but here are the places I found that likely need updates for the new behavior, reloptions, GUC, etc. Including docs in the patch early would help clarify expected behavior. https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-BASICS https://www.postgresql.org/docs/current/routine-vacuuming.html#AUTOVACUUM https://www.postgresql.org/docs/current/runtime-config-autovacuum.html https://www.postgresql.org/docs/current/sql-createtable.html https://www.postgresql.org/docs/current/sql-altertable.html https://www.postgresql.org/docs/current/runtime-config-resource.html#GUC-MAX-WORKER-PROCESSES https://www.postgresql.org/docs/current/runtime-config-resource.html#GUC-MAX-PARALLEL-MAINTENANCE-WORKERS One thing I am unclear on is the interaction between max_worker_processes, max_parallel_workers, and max_parallel_maintenance_workers. For example, does the following change mean that manual VACUUM PARALLEL is no longer capped by max_parallel_maintenance_workers? @@ -597,8 +614,8 @@ parallel_vacuum_compute_workers(Relation *indrels, int nindexes, int nrequested, parallel_workers = (nrequested > 0) ? Min(nrequested, nindexes_parallel) : nindexes_parallel; - /* Cap by max_parallel_maintenance_workers */ - parallel_workers = Min(parallel_workers, max_parallel_maintenance_workers); + /* Cap by GUC variable */ + parallel_workers = Min(parallel_workers, max_parallel_workers); 3/ Shouldn't this be "max_parallel_workers" instead of "bgworkers pool" ? + "autovacuum_parallel_workers", + "Maximum number of parallel autovacuum workers that can be taken from bgworkers pool for processing this table. " 4/ The comment "When parallel autovacuum worker die" suggests an abnormal exit. "Terminates" seems clearer, since this applies to both normal and abnormal exits. instead of: + * When parallel autovacuum worker die, how about this: * When parallel autovacuum worker terminates, 5/ Any reason AutoVacuumReleaseParallelWorkers cannot be called before DestroyParallelContext? + nlaunched_workers = pvs->pcxt->nworkers_launched; /* remember this value */ DestroyParallelContext(pvs->pcxt); + + /* Release all launched (i.e. reserved) parallel autovacuum workers. */ + if (AmAutoVacuumWorkerProcess()) + AutoVacuumReleaseParallelWorkers(nlaunched_workers); 6/ Also, would it be cleaner to move AmAutoVacuumWorkerProcess() inside AutoVacuumReleaseParallelWorkers()? if (!AmAutoVacuumWorkerProcess()) return; 7/ It looks like the psql tab completion for autovacuum_parallel_workers is missing: test=# alter table t set (autovacuum_ autovacuum_analyze_scale_factor autovacuum_analyze_threshold autovacuum_enabled autovacuum_freeze_max_age autovacuum_freeze_min_age autovacuum_freeze_table_age autovacuum_multixact_freeze_max_age autovacuum_multixact_freeze_min_age autovacuum_multixact_freeze_table_age autovacuum_vacuum_cost_delay autovacuum_vacuum_cost_limit autovacuum_vacuum_insert_scale_factor autovacuum_vacuum_insert_threshold autovacuum_vacuum_max_threshold autovacuum_vacuum_scale_factor autovacuum_vacuum_threshold -- Sami Imseih Amazon Web Services (AWS)