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 1vAfDp-004lum-Eu for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Oct 2025 02:02:04 +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 1vAfDo-00DYqf-Bw for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Oct 2025 02:02:03 +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 1vAfDo-00DYqX-2A for pgsql-hackers@lists.postgresql.org; Mon, 20 Oct 2025 02:02:03 +0000 Received: from mail-qv1-xf2b.google.com ([2607:f8b0:4864:20::f2b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vAfDk-0038ww-2U for pgsql-hackers@postgresql.org; Mon, 20 Oct 2025 02:02:02 +0000 Received: by mail-qv1-xf2b.google.com with SMTP id 6a1803df08f44-879b99b7ca8so59632396d6.0 for ; Sun, 19 Oct 2025 19:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760925719; x=1761530519; darn=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=0irO0d+qY+XRe3chn6ZZ8ELmMhGYMH6BDbL5vknwDys=; b=harBVxAEbtqiMNSst0f+tlJO3mOIsIGgnMS4pxcHblFFUGdidVJGeHJVnd7kCNzhE4 w+B04WHtOEidB4jg2fgsrw5WztyNt/ny93lwNyZnGHzmqhKvtR0g5TgqcOVT1YU4t5TR CtDiitfOUi3RGtEIptC9nqFfq8MkpIW7ugpKtnNBheorr3LD9ULh89kmUmGrMbl6ZW49 JNWJx/u6jOe5RGql+2+UO3UVSH1uoFkMVRCQ8K/lIDT5neYZHkL+fvuw7ohYcLG2iIFy 4zMVu34rnV3m2crgXRx1bBemBpW+61ceTPW1HrqtWvofvBtkN0cDvWOEoGzwN6aKvS2r v9Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760925719; x=1761530519; 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=0irO0d+qY+XRe3chn6ZZ8ELmMhGYMH6BDbL5vknwDys=; b=YsvwW6A2Xc5vDvT9XUryJ+BvfYlfclQujYR/zt2yIVerNM/2HIM8M885xNMbk7gjjO N+ZWLElfw+tp4VuTk3MmM7nOk5Or/Tx7ofc71UjtPW1DUdQ7utwO57n4pu7KAgixyl0M emjORRFjZiSz40b8Mt0rAcem8lT34O3H1N22TEt6Wm2WwOg+r9X4QchFws7T+zRk/MJn B/P9CtzIjY1dZvCXcXC1+yw4u4H8q/HVkSeSc/oJHB0O33Orj/xNDwGSYcKymQt+Bf86 8fExd0uyHWnTGrn3rFgKYPZCY/FW+KNHH1e7GC4/Y/MIG7A7gR8pY9ne2a/dwZkqqD2m 06gg== X-Forwarded-Encrypted: i=1; AJvYcCX48CsCSLXjyV0dj18SrTJSk8CKeqbAsCA9L/h1dph0KGk6RzdYpQHH8DiUkgMyqZSvzXXRwJfOl8NeyMhy@postgresql.org X-Gm-Message-State: AOJu0Yz28SPRGjpoiRPvrXAvGUga8mizx7GPju6aEklmd2FUg7u7PEaa cbkGWWsbQz0apO3sH+g2OP0e7/M/Gr2+bVU2u+0b1uFGpvLQtPzkD7oYoxhepjUW+HwImcgyK3i k2ggH/CzLmXUNgUblMcHlY5623N7T9oE= X-Gm-Gg: ASbGncuh4sVw7xYEIGqYYtfOYS7PyGwt6GnaTcs94e92r42UIRWWUv4P9H2D/oHutDz Y/UqxxtLtQmWP8Mlkwi+djzIWTZUY/E5awUIdQypuu3BKCv1W+CzIsQLM8HU27wImVZKkDPYCfB k0pEkBCPQeKfNLlbv9hTsltE27rKhL77HmKfk3QL9fNCMvs+6ktC/5bG7RP0XjzxolbKKTZxfMZ RNjE+Z/Wnd97rixkqSD3jEUSSNUgloX/mgc9FqhkYXFleqo7qPaQHtuP3mjQ5+DBa9O8318AK0k jNpESqsv7FgZof2vjiQ= X-Google-Smtp-Source: AGHT+IGwsd40BtJuCJOq0zfEcaGfd/z+uhGvterU27J8G2YguWZKkjLmUz/+S1ypTOFRlWVt84kit2y8qr37Ju5qou4= X-Received: by 2002:ac8:5fd0:0:b0:4b7:90c0:3156 with SMTP id d75a77b69052e-4e89d1ffb86mr151854211cf.9.1760925718759; Sun, 19 Oct 2025 19:01:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Peter Smith Date: Mon, 20 Oct 2025 13:01:31 +1100 X-Gm-Features: AS18NWDMTeJXXAJyB67irv2D-kRe_Bda3z7BXbx7A85B_KD7ktVoYYSm-kT5KrY Message-ID: Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE To: "Aya Iwata (Fujitsu)" Cc: Michael Paquier , Chao Li , "Hayato Kuroda (Fujitsu)" , pgsql-hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Iwata-San, Some comments for the latest v8 patch. ====== src/backend/postmaster/bgworker.c TerminateBgWorkersByBbOid: 1. +void +TerminateBgWorkersByDbOid(Oid oid) Now the function name is more explicit, but that is not a good reason to make the parameter name more vague. IMO the parameter should still be "dbOid" or "databaseId" instead of just "oid". (ditto for the extern in bgworker.h) ====== src/backend/storage/ipc/procarray.c CountOtherDBBackends: 2. + /* + * Usually, we try 50 times with 100ms sleep between tries, making 5 sec + * total wait. If requested, it would be reduced to 10 times to shorten the + * test time. + */ The comment seemed vague to me. How about more like: /* * Retry up to 50 times with 100ms between attempts (max 5s total). * Can be reduced to 10 attempts (max 1s total) to speed up tests. */ ~~~ 3. + for (tries = 0; tries < ntries; tries++) 'tries' can be declared as a for-loop variable. ~~~ 4. Something feels strange about this function name (CountOtherDBBackends) which suggests it is just for counting stuff, but in reality is more about exiting/terminating the workers. In fact retuns a boolean, not a count. Compare this with this similarly named "CountUserBackends" which really *is* doing what it says. Can we give this function a better name, or is that out of scope for this patch? ====== src/test/modules/worker_spi/t/002_worker_terminate.pl 5. +# Firstly register an injection point to make the test faster. Normally, it +# spends more than 5 seconds because the backend retries, counting the number +# of connecting processes 50 times, but now the counting would be done only 10 +# times. See CountOtherDBBackends(). +$node->safe_psql('postgres', "CREATE EXTENSION injection_points;"); +$node->safe_psql('postgres', + "SELECT injection_points_attach('reduce-ncounts', 'error');"); + It seemed overkill to give details about what "normally" happens. I think it is enough to have a simple comment here: SUGGESTION The injection point 'reduce-ncounts' reduces the number of backend retries, allowing for shorter test runs. See CountOtherDBBackends(). ====== Kind Regards, Peter Smith. Fujitsu Australia