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 1x3eMO-006ZQ5-27 for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Sep 2026 18:46: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 1x3eMN-002lAO-1v for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Sep 2026 18:46:27 +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.96) (envelope-from ) id 1x3eMN-002lAF-0o for pgsql-hackers@lists.postgresql.org; Mon, 07 Sep 2026 18:46:27 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x3eMK-00000003RzM-1FBh for pgsql-hackers@postgresql.org; Mon, 07 Sep 2026 18:46:26 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-49cf4f81d86so30259885e9.2 for ; Mon, 07 Sep 2026 11:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1788806782; x=1789411582; darn=postgresql.org; h=message-id:date:content-transfer-encoding:content-id:content-type :mime-version:comments:references:in-reply-to:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to:content-type; bh=G5B/cTWcHtI4Q/56lHF+c6Obxhu8f2dU/z0XbN3hpNg=; b=gNPcnfMiLOOukn6ybcfwVZHlCOv7wo4i3tdJxMsZuwLiSB2B3vhcgWGJMytb9F7hEL +K6ciiDYLcXIH33+RwG0r9/+mXaEewo7FFuyHiBqAV6VDOoWzjYDkbFV9mbSQx43MIUv dx8ayN1d7tm8FaE9QeWK0486BwhKfFKesVo3xleCGovz2OC2ULPMjkisa+wHhXjmLbAg 2XytcdmVtgslT25qJ/umRszBgGqhdXQORqQ7ERCvGinewyALmUM0tnCo89eWV93BwFQq 1KR1HVRNwYNEeDFfy5T/qapmuaq5E7bgVNgwarM5MPK0jQEFrzkmWQDyIcZDi9+DxroU LLGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788806782; x=1789411582; h=message-id:date:content-transfer-encoding:content-id:content-type :mime-version:comments:references:in-reply-to:subject:cc:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=G5B/cTWcHtI4Q/56lHF+c6Obxhu8f2dU/z0XbN3hpNg=; b=DXm0ps2Gf6pg022xboiMe3Oi3poT03H+2IUZPa7jdm/3F+5eg5n8aiVXOgJq/n6d/9 fzQQbCVp6ipSg8JfHm1U5a95sVYnnIlKwpV03ozne27gxVFcPs3Ew3g88YZBA8ybfe36 Ro/uN3XzqB0bBDWrIQ9J7jzZQmix/+hKiJizTq/GZGHBGl+T5TXlXXgKJ9XtfOgeqQhw cL58HBbv+MbE7wow5qy7iCNYvlc2T2ek8owG4m2kGIIYw5yf04QJ0yqEqw5DFyv3qbLm NzN1Q9KcnCc8MIhkteVw1Sh1f+wbMYNkXU8gYJGM+hnDp3fgnK+IQJR4ML3i5NoruxfY zu5w== X-Forwarded-Encrypted: i=1; AKwUvBw54gpXyFWCyEl7yC/LwkFHv3S6g7M22kfngxThris9KVoXoduX4Z4fbrPegVC5CfR2MY8Y8c0fTaL0QDMC@postgresql.org X-Gm-Message-State: AFuF++lA+8tpt/iWOh76ROg7gWZ/Y6OBKc8nLQLKUA2otWCwIyU91ifA ekvY4iJ3+96WTGx122dDxiPnPayxwT2qkEEgufcJ9SBKG7R6SaB4oPfOXL0YyLNCDCM= X-Gm-Gg: AYBFou3Cdq7eimCHzZFSpoDzz2LvSSNuLrEXN3cnTEPZt0VSuNO3yEcC491CgcOhjDD SGygTyiU2Q/2V2UI0eNRF5T6rEc8m8+xVbgphH/iIU7USwtyhnaSemheWjIpFYelDkgQZZrP+eR JjLd+1opGbIwsGbAc4zCPbqCYNH+STVzlOvIHJHfdpC79B+yI+Vg5pAD1JSJ5F7C9dYtdlIR7eQ 8L5eQsJij5HytqG+C+5zmvEYkY9WQ1L6d4cevc+2xtEUb20LQ5RzwfHe13uEk/aBFh6PXZPId8z cpxQN2iPVp3ERBKVhnz9ct1xoVNgMcbdPIV65Mp7RQ2wJDiBo/Q71P7bdyDSfrE+RKSJYHR4eiP 4ylRgujjKUn5KqV1oHdUxZlOxJvJ6Mo8RVd9TqTXc/AwlSUqYAMNeD8tjEmEeUlkPUfUodzTWJC QQhcNUsgn+qIu1ZmC33+aN43d4DIz+rT39iNcg6DEok5jmr84N5d6OBRX+88MBodP4hCMT6P+U+ 8i8T6yycS/m X-Received: by 2002:a05:600c:8b88:b0:49c:db20:da13 with SMTP id 5b1f17b1804b1-49cf822a707mr260622095e9.5.1788806781942; Mon, 07 Sep 2026 11:46:21 -0700 (PDT) Received: from localhost (109-81-170-190.rct.o2.cz. [109.81.170.190]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-485883c81c3sm30661169f8f.26.2026.09.07.11.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 11:46:21 -0700 (PDT) From: Antonin Houska To: Masahiko Sawada cc: Bharath Rupireddy , Nathan Bossart , PostgreSQL-development , alvherre@kurilemu.de Subject: Re: REPACK (CONCURRENTLY) backend waits indefinitely when decoding worker fails to start In-reply-to: References: <27780.1788172295@localhost> Comments: In-reply-to Masahiko Sawada message dated "Fri, 04 Sep 2026 17:11:07 -0700." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <32122.1788806780.1@localhost> Content-Transfer-Encoding: quoted-printable Date: Mon, 07 Sep 2026 20:46:20 +0200 Message-ID: <32123.1788806780@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Masahiko Sawada wrote: > + /* > + * Associate the worker's handle with the error queue, just as if it= had > + * been passed to shm_mq_attach(); we passed NULL there because the = worke > + * did not exist yet. This lets ProcessRepackMessages() notice the w= orker > + * is gone instead of blocking on the queue. > + */ > + shm_mq_set_handle(decoding_worker->error_mqh, decoding_worker->handl= e); > + > = > The second sentence starting with "This lets ..." is unclear to me. > ProcessRepackMessage() receives the message with nowait, no? Although it probably does not break anything if we pass the handle to shm_mq_set_handle() unnecessarily, I'm thinking if it's necessary for an e= rror queue. AFAIU the purpose of the handle is to realize that it makes no sense to wa= it for the background worker to attach to the queue. Once the worker has attached, the worker's handle is no longer needed to detect that the worke= r detached: the already-attached worker itself is supposed to call shm_mq_detach(). If I use the parallel worker for reference, I think the leader should not = be asked (via the PROCSIG_PARALLEL_MESSAGE signal) to read from the error que= ue until the worker has attached and redirected its messages to the queue - s= ee in ParallelWorkerMain(): mqh =3D shm_mq_attach(mq, seg, NULL); pq_redirect_to_shm_mq(seg, mqh); Therefore, the leader should not need the worker's handle. I also thought about the other source of the PROCSIG_PARALLEL_MESSAGE sign= al, a few lines above the call to shm_mq_attach(): before_shmem_exit(ParallelWorkerShutdown, PointerGetDatum(seg)); If the worker called proc_exit() after this, but before the call of shm_mq_attach(), the worker handle might be useful for the leader to concl= ude that the worker hasn't detached yet. However, the coding of ProcessParallelMessages() is such that shm_mq_receive() can return SHM_MQ_WOULD_BLOCK in such a case, so the ERROR "lost connection to parall= el worker" is not raised anyway. While thinking about that ERROR, I realize that I might have misunderstood= its purpose, and therefore it's not present in ProcessRepackMessage(). Nevertheless, I'm still not sure I understand when exactly should that ERROR be raised. Per commit 2badb5afb8, the function ParallelWorkerShutdown() is related. However, AFAICS, when the worker code calls proc_exit(), the ParallelWorkerShutdown() callback can send the PROCSIG_PARALLEL_MESSAGE signal while the worker is still attached to the error queue. In that case, the ERROR is not raised. I'm probably missing something. Thanks in advance for any hint. -- = Antonin Houska Web: https://www.cybertec-postgresql.com