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 1x3q5L-006hOi-1Z for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Sep 2026 07:17:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x3q5K-005BQk-0g for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Sep 2026 07:17: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.96) (envelope-from ) id 1x3q5J-005BQc-2l for pgsql-hackers@lists.postgresql.org; Tue, 08 Sep 2026 07:17:37 +0000 Received: from mail-wr2-x10.google.com ([2a00:1450:4864:30::10]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x3q5H-00000003XDn-1GNG for pgsql-hackers@postgresql.org; Tue, 08 Sep 2026 07:17:37 +0000 Received: by mail-wr2-x10.google.com with SMTP id ffacd0b85a97d-482f6356257so344369f8f.0 for ; Tue, 08 Sep 2026 00:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1788851852; x=1789456652; darn=postgresql.org; h=message-id:date:content-transfer-encoding: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=piZ2Cc84Ny8nWwRbsorw/hxPWTCsxgRJbsQGmotlI5U=; b=IpqZFRXv9vUKHw6XX3TlJVOgvIwG1+Z5jCwEB4Cr6n0mzcGqXRgKC1avsbxfKvc8Vu MzbZx04iN1W7um5L0/dXfLgQQ90qckngj4jQhOYdOWV535xy4b72i2ZI+aVeuo0W8LD+ p4zX8ssPLEKp8R1Tej+9u+JMl09d6vz1QgpID37JSmj1abbytt0UEnG20yWnb3TR+o6g ogbsE1ZGlwZletpwTv45jZHSgca5gSRAGOQePq+s4yyWDJsG6S4oJXiEgt7XB392pW3L vhGIvy411RwM5NanasZIkN/oTMWBmrzNKDy/qs0IrCtmVGNTGxTjHZctHNa1MPZezi8d Ih5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788851852; x=1789456652; h=message-id:date:content-transfer-encoding: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=piZ2Cc84Ny8nWwRbsorw/hxPWTCsxgRJbsQGmotlI5U=; b=fxHHB9GiF7KN1i1buM6/YpLaH027U/lS+QNmQ1wft/h0EpkFfEq0OH4nOu76jC+U+b 7v76XTz66OdoveWl6E7v5+yDOY0rU05dG8YuZ3UWufG9vN9UdU7ljwbl3Mn5lhzULSb6 q2nDvWAfOX06MqqmJ10BY0101pdTp1/9XAkbUpjwKzRve5kTo3PRtJcijtAZK7jvEUQW cbh1ZsMxmeepAZisWRdZF95LxZgeD4lDB6LgFEKUiZi/9g3SQ3t4X/eXzVqOR4M/4INO rqxgZowvn0/9PmnkS813ZyzreemBXjJaSx5FiDXloSdeEEDb7pxaYtLN9NA1ftBuPQQA QdqQ== X-Forwarded-Encrypted: i=1; AKwUvBwcaY5vDLHC3aaizBiCRC2Nmj56QHKQrgnTz33WxFhWPd5LczCRDaS27CNFHs3HaXmzRi8UkUj/syoomslT@postgresql.org X-Gm-Message-State: AFuF++kvCa6Ks1tluf61E1Q9LYRUDrRjndtErbZ0bIMpWN/xhi+WeXuY dqtlQWZdfH1QfRSP+Y+QXqc3KNd/ppTyJ/WeKfDVf+FhsZZnkvCdjMUWTzkGd6wyMDU= X-Gm-Gg: AYBFou1eufpwe7zRIj6uLL3Z4RWq8Qb6Dto9G5ACOhObuh0M+t6jTytblBlHe/CWR/1 V84MxZAIg2KlE9r4z2gqmvN5HHHIDoW/2WaICwryNGhxUxjFv2mMSC18T72b3G4ZWDFJwDFZPR2 Q7V3CK3RYguPJZ63Qv/ekhVxtpLrb+Q/x3Y0x3IQ70o/y5OxvjbKGiLGBT0xs9bi2465HVB+5VK wXH1c5JpIxOUHqQJpycSIhKMplz4lWtUfPBoA/r7SXn+sT7qhpWAkBh0+nDRCc6q31xg1fxKwc+ RppILDy/35l96f/r8JpOAw6KemDtADXR0hcmqduWDfAG6cg1DhxuezyvMR/OwFcnMQjOJCsLQD1 Hv5okJ3KKm7RmoTEs1wcvbyqIEiCkssH94K+q2EvUQDoc+ft6HJ1gGs7KdwcFfZ4DsliCYQapdw jQhqFqsbkvFXcFFUaCGfCkAtKb61uBkZwAE0wyE59kVawRJziG1AM8agtnqlH0fFKRZZfxKE5zg mvZaHcJd4Z3 X-Received: by 2002:a05:600c:4455:b0:493:f783:c46a with SMTP id 5b1f17b1804b1-49d1754fdf6mr51686845e9.6.1788851852394; Tue, 08 Sep 2026 00:17:32 -0700 (PDT) Received: from localhost (109-81-170-190.rct.o2.cz. [109.81.170.190]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49cee6024a8sm476603765e9.6.2026.09.08.00.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2026 00:17:32 -0700 (PDT) From: Antonin Houska To: Bharath Rupireddy cc: Masahiko Sawada , 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 Bharath Rupireddy message dated "Mon, 07 Sep 2026 12:15:00 -0700." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 08 Sep 2026 09:17:31 +0200 Message-ID: <7564.1788851851@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bharath Rupireddy wrote: > On Fri, Sep 4, 2026 at 5:11=E2=80=AFPM Masahiko Sawada wrote: > > After thinking more about this, I simplified the handling. There are two = things the backend needs to wait for. First, for the worker to come up > and attach to the error message queue. Second, for the worker to set up t= he logical decoding machinery before it waits for snapshot export. > The first wait catches fork failures and worker startup issues. I used si= milar logic to what parallel.c uses for this. The second wait catches > failures that happen after the worker starts up and attaches to the error= queue but before it finishes setting up the logical decoding > machinery. I kept the shared memory initialized flag with the CV wait as-= is for this. >=20 > Although the initialized flag wait may seem redundant with the snapshot e= xport wait in get_initial_snapshot(), I would still keep it because it > ensures the worker has fully set up the decoding before the backend proce= eds. >=20 > Dividing this into two separate waits (waiting for the worker to come up = and attach to the error message queue, and then waiting for it to > finish setup) makes the logic simpler, lets us reuse most of parallel.c's= code, is easier to reason about, and fixes the hang issue without letting > the backend reach the snapshot export wait with the worker not fully read= y. Another reason for two separate waits is that two separate event types make sense: WAIT_EVENT_BGWORKER_STARTUP and WAIT_EVENT_REPACK_WORKER_EXPORT. > Please find the attached v3 patch. Just two comments: * wait_for_repack_worker_to_attach() - as the decoding_worker variable is declared static, this function does not necessarily need the argument. * Regarding comment: when the following is reached, the error message queue has already been detached, so no implicit detaching should happen. Also, there are no "other shared memory queues". + /* + * If we have allocated a shared memory segment, detach it. This wi= ll + * implicitly detach the error message queue, and any other shared = memory + * queues, stored there. + */ + if (decoding_worker->seg !=3D NULL) + { + dsm_detach(decoding_worker->seg); + decoding_worker->seg =3D NULL; + } --=20 Antonin Houska Web: https://www.cybertec-postgresql.com