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.96) (envelope-from ) id 1vnu5J-00DHkO-1o for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Feb 2026 07:47:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vnu5I-00Fvj1-1Q for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Feb 2026 07:47:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vnu5I-00Fvit-02 for pgsql-hackers@lists.postgresql.org; Thu, 05 Feb 2026 07:47:27 +0000 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vnu5F-00000000eHY-3uSG for pgsql-hackers@postgresql.org; Thu, 05 Feb 2026 07:47:26 +0000 Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-505e2e4c35fso6689431cf.3 for ; Wed, 04 Feb 2026 23:47:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1770277645; cv=none; d=google.com; s=arc-20240605; b=EK/mcBOFtAAHNNcB/abi+4ZziW1HIGmTkAXnxBuUf6VpSxMxknqKhKAM1OSBBl/Q1S zhvx3v7rBGkH1yVuIUVTU2pubaVIi8BhSXFJxiYTAX6fLeXKqLodElWf3hNrXZOqYzz4 LS407I2XDeS6lHp0QDLuiRse8urK13TkbERZEH4aNkKfz5PoTLrRMN4Y140iO7z3lthb BsRZiqp0zp20Q9pTfpt5mg2x91mcwZqy4As0D/y1nN3g2i1BcjYzcOyarGPzEgrosUKo cObZhav8y++X7UO5BZHF2Q5e2vNgUSPlHEn9u0jtTnZgLqPVM7JTN5vhrdB8E23T8WfC cfHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=SqsY0MYkdorQ3G7+CyIIQeR5EsaMBLSNFkC8wDqY5G0=; fh=wG2O5chZ56JwlKs5fklU8DQUUSn850XLtBx+Fp5dUQ8=; b=IFFhh+I/d5zafDUaz8vo4eBiqQnoh5uXOMPzJC3CICmBXUBjkS7QvO7DTniekrPc6P wcB3IOCXmLnWLvivookDQzLcwv7E6DI7L6OjJ0dyazJSchKHIsNvjrrH/+V4HoZa8Co4 yCmDRsx2SFsLiaQvhiimZXkoT8aFCwUwZpQArGxjdN2KV/79HMdhVjRWN7rMuqRe58lO bRJ7gw9s69RWAa7f+m4oKuuS1CC0amQJ8+WjSFxlhQtgpO5WCAZXZKslBi/DNh1icJjM yX5+N722rcgs9qeram/VqZvyHCb3xTgOr36wOjsIPmcgVXKFzNmKVfH7GPfXDh7vLOwI vdkQ==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770277645; x=1770882445; 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=SqsY0MYkdorQ3G7+CyIIQeR5EsaMBLSNFkC8wDqY5G0=; b=Fo523XCwkM+9chjtd3Fgb7VWbw46yp+sAj7NyIaEWw0uVoqVmW8Rnysj4M12PywV8w 0gdxdEdzixN7CQecz8J8Q/4ETrq3z9EaBUm5v+pAsu9rMFiJaMEj7OoDTYXyU6QyWC9+ hudybIXijwKIORINlkW/x8ZEODMJ/s1csXrYeUVEDpSUdoSbWJ8HBvoh2w3W8nWSorka CnKWuHf60afCTEZ4q3+NQcXfVzZOHUs7jNn4/D/oY3SBNOVwkj1X6rfjxoXBvzt6trPR ov3d/Mm7YbyLFfGx6+lO27UCe/eJdyRwvdCHk76wBa36+DqwO6S59Id5dZhA5rgPsIBs IpiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770277645; x=1770882445; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SqsY0MYkdorQ3G7+CyIIQeR5EsaMBLSNFkC8wDqY5G0=; b=UHMoVuFDi0NjATGdKrEBLItI81ka7TCbI7mVcPt6HL0DWs9Wm5NLYDMs8/Lsdfh1RT foM0UAmsebQzIKhabFjG7WffIFaBDWdLmGdlL8Cbc17Je5vg8y97QUAjBF+O6ILE3WdD JqP3gclL5i1+qKq33v2g+iU1Aof2dVV2BA1j8oRdQ8zbAZPEV8nRJgXfl5wGfJ9rmv1P OIq8S5rluIT/Q/7tefz4gLnp73+ICjUu8SLione5JezNu1cyDMvEMJHtW2XGUwo7LrLx S88zyVtgUO1vwD8lJx6cW8opg66SLDrVP5q1WR+kgoL102WcDhI/HlwzBbw6Un4/N2cI /n7g== X-Gm-Message-State: AOJu0YxAtiAoE95qhZqz01CjmzNe6iAX7tkqlHToaKIslZ6XO5VxBRKy 11qhyUGl0oCG3lfoGa2JvosQ6iE103uRe9Z6MuZpxuDhTJqqeGwDT8mHelbxuElUZko+W4yIlM/ DRivvez3UUx47vV+crBCCOvbijYudoFA= X-Gm-Gg: AZuq6aK+huCGNwb286uetBtQa6cyE0K6buURDbJPSyssAzVlW1FAFQE/5x5HXZg5KJy 7P1PsWMmoGuw33cY9kxhndJGdgac7HwGNGBYBEUuwK/R/C+qy/PH5zZaDxX2L7OfCnYcmeHrt3k Nc4uXs1Eg3rdjtKQXfU8GgjEU5v/rNuU3469oDo8z/GSTYHbmGOMr5tvZt5uLnOhyEUUCYv1oly 0mc3M5luJsnUWgI6MoRsl7VTX0rhErQlkf0TgXZcNyam1lY7GlA0houLHXOLjFwJD6vtuuSL4Eq d0tYpQYSRCTmVpmthWN/0EnSOL9OyXjVRipQTiee X-Received: by 2002:a05:622a:189a:b0:505:e448:1b10 with SMTP id d75a77b69052e-5061c18616bmr69206731cf.41.1770277644733; Wed, 04 Feb 2026 23:47:24 -0800 (PST) MIME-Version: 1.0 References: <20260204140731.0e4b511906ac748abad1f3d9@sraoss.co.jp> <20260205101239.3c432a7766bc962bad9c6c51@sraoss.co.jp> In-Reply-To: <20260205101239.3c432a7766bc962bad9c6c51@sraoss.co.jp> From: Peter Smith Date: Thu, 5 Feb 2026 18:46:58 +1100 X-Gm-Features: AZwV_QhEUyIXe-9PKSzxY3RDm0hW8blR7BSuPZsteqZgwM-ai2CNc-Hdzfgnjd4 Message-ID: Subject: Re: Warn when creating or enabling a subscription with max_logical_replication_workers = 0 To: Yugo Nagata Cc: Pgsql Hackers Content-Type: multipart/mixed; boundary="0000000000002b2438064a0ee2ef" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000002b2438064a0ee2ef Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 5, 2026 at 12:12=E2=80=AFPM Yugo Nagata w= rote: > > On Wed, 4 Feb 2026 17:26:25 +1100 > Peter Smith wrote: > > > On Wed, Feb 4, 2026 at 4:07=E2=80=AFPM Yugo Nagata wrote: > > > > > > Hi, > > > > > > I would like to propose emitting a warning when creating or enabling = a > > > subscription while max_logical_replication_workers is set to 0. In th= is > > > case, the CREATE/ALTER SUBSCRIPTION command completes successfully wi= thout > > > any warning, making it difficult to notice that logical replication c= annot > > > start. > > > > > > Of course, users can confirm whether logical replication is working b= y > > > checking system views such as pg_stat_replication or pg_stat_subscrip= tion. > > > However, emitting warnings explicitly in these cases would make this > > > situation more visible. We have seen user reports where this behavior > > > caused confusion, with users wondering why replication did not start. > > > > > > > Hi Nagata-San. > > > > AFAIK the default for `max_logical_replication_workers` is 4. So how > > does the maximum get to be 0 unless the user had explicitly configured > > it that way? > > That's correct, but the goal here is simply to make it easier for users t= o > be aware of this condition, since the current behavior provides no > indication that replication will not start. > > > Also subscriptions require multiple workers in order to work properly > > [1] so why check only 0? Why not check 1 or 2 or 3.... those low > > numbers are also likely to cause similar problems aren't they? > > > > And what about when the `max_logical_replication_workers` is 100, but > > those 100 are already being used. IOW, would it be more useful to warn > > when you do not have enough *available* workers for the Subscription > > to function properly, rather than checking what the maximum value is > > set to? > > When max_logical_replication_workers is zero, the logical replication > launcher will never start. Otherwise, it does start and emits the > following warning to the server log when workers cannot be obtained: > > WARNING: out of logical replication worker slots > HINT: You might need to increase "max_logical_replication_workers" > > Given this, I think it is sufficient to warn only when > max_logical_replication_workers is zero. > Hi Nagata-San, Oh right, I mistook that you had run out of logical replication "workers", but in fact, because max_logical_replication_workers =3D 0 the main "logical replication launcher" process had failed to start, so logical replication was entirely disabled. See code: in backend/replication/logical/launcher.c ApplyLauncherRegister(void) { ... if (max_logical_replication_workers =3D=3D 0 || IsBinaryUpgrade) return; ~~~ Given this, I felt that instead of testing the GUC, what you really want to know is just whether that "logical replication launcher" is running or not. And that launcher pid is already tested when the Subscription commands send a "kill" to the launcher. e.g. see function ApplyLauncherWakeup. So, here is a diff patch, of what I tried: ------ diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index 3ed86480be2..f880380ce4e 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -1195,6 +1195,13 @@ ApplyLauncherWakeup(void) { if (LogicalRepCtx->launcher_pid !=3D 0) kill(LogicalRepCtx->launcher_pid, SIGUSR1); + else + { + if (max_logical_replication_workers =3D=3D 0) + ereport(WARNING, + errmsg("Logical replication is currently disabled"), + errhint("\"%s\" is 0.", "max_logical_replication_workers")); + } } ------ AND THE RESULT: ---------- test_sub=3D# create subscription sub1 connection 'dbname=3Dtest_pub' publication pub1; NOTICE: created replication slot "sub1" on publisher WARNING: Logical replication is currently disabled HINT: "max_logical_replication_workers" is 0 CREATE SUBSCRIPTION test_sub=3D# test_sub=3D# alter subscription sub1 disable; ALTER SUBSCRIPTION test_sub=3D# alter subscription sub1 enable; WARNING: Logical replication is currently disabled HINT: "max_logical_replication_workers" is 0 ALTER SUBSCRIPTION test_sub=3D# ---------- IIUC, that seems to be giving the CREATE/ALTER warnings that you wanted. Thoughts? =3D=3D=3D=3D=3D=3D Kind Regards, Peter Smith. Fujitsu Australia --0000000000002b2438064a0ee2ef Content-Type: text/plain; charset="US-ASCII"; name="PS_warn_no_launcher.txt" Content-Disposition: attachment; filename="PS_warn_no_launcher.txt" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_ml95iv7v0 ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL3JlcGxpY2F0aW9uL2xvZ2ljYWwvbGF1bmNoZXIuYyBi L3NyYy9iYWNrZW5kL3JlcGxpY2F0aW9uL2xvZ2ljYWwvbGF1bmNoZXIuYwppbmRleCAzZWQ4NjQ4 MGJlMi4uZjg4MDM4MGNlNGUgMTAwNjQ0Ci0tLSBhL3NyYy9iYWNrZW5kL3JlcGxpY2F0aW9uL2xv Z2ljYWwvbGF1bmNoZXIuYworKysgYi9zcmMvYmFja2VuZC9yZXBsaWNhdGlvbi9sb2dpY2FsL2xh dW5jaGVyLmMKQEAgLTExOTUsNiArMTE5NSwxMyBAQCBBcHBseUxhdW5jaGVyV2FrZXVwKHZvaWQp CiB7CiAJaWYgKExvZ2ljYWxSZXBDdHgtPmxhdW5jaGVyX3BpZCAhPSAwKQogCQlraWxsKExvZ2lj YWxSZXBDdHgtPmxhdW5jaGVyX3BpZCwgU0lHVVNSMSk7CisJZWxzZQorCXsKKwkJaWYgKG1heF9s b2dpY2FsX3JlcGxpY2F0aW9uX3dvcmtlcnMgPT0gMCkKKwkJCWVyZXBvcnQoV0FSTklORywKKwkJ CQllcnJtc2coIkxvZ2ljYWwgcmVwbGljYXRpb24gaXMgY3VycmVudGx5IGRpc2FibGVkIiksCisJ CQkJZXJyaGludCgiXCIlc1wiIGlzIDAuIiwgIm1heF9sb2dpY2FsX3JlcGxpY2F0aW9uX3dvcmtl cnMiKSk7CisJfQogfQogCiAvKgo= --0000000000002b2438064a0ee2ef--