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 1whitE-000Nse-07 for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jul 2026 07:09:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1whitC-00BPtL-1e for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jul 2026 07:09:43 +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 1whitC-00BPtA-0b for pgsql-hackers@lists.postgresql.org; Thu, 09 Jul 2026 07:09:42 +0000 Received: from mail-yx1-xb133.google.com ([2607:f8b0:4864:20::b133]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1whitA-00000000HNW-3Slz for pgsql-hackers@postgresql.org; Thu, 09 Jul 2026 07:09:42 +0000 Received: by mail-yx1-xb133.google.com with SMTP id 956f58d0204a3-664ce3000e6so1502812d50.0 for ; Thu, 09 Jul 2026 00:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783580979; cv=none; d=google.com; s=arc-20260327; b=UhtoQsErnkaGykjyKUOlpI77EnR7koPJ4idcmDB/vDQXZ/vGQm0jKEXTbYpRpbA1Sn QfYx/55IP6ovjKjzYB+TXOYSFK0t7SBQ8RIEcKnyBIN8N0pT8LnubSwnesmQLJuMMi/Z ILEH798u8msimkcSycBbpuX5hOcbSyz3BF1EJmlB4JQ1rBnxQRukgOz5Fq92/gBNEoi5 k3CvZuHlciBjefswQgUXe33fJGJEsZOJ/5WGGMiY3gYXGI+Ox0gFkih7ALMcET3m+9DH FPkNBaBGBmlyQCfRbeXmeZ0Ftsd1qJ5lTNr7RBRKHeSkDGNke4q/vtJPZYCwiOJ4e0wb 3MRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=J7EjVmN6vNv5IUzh/frO6OIu4+ZdywA8s5QcksSnkHM=; fh=ub4oUt7BPcVWXX7HOfNuWEqH98ZZ+4TyDIddxmuFJKI=; b=bC0ppFB+0js2UNUT5yG2FaGsACdEP4JrQoYECJXYQ8c1SAFa7zD2BHdpjAkRC4o+cg kJxOmcqosc/J2oL7Dp54ElaO6HhDbSqWoPvD5PRPLtCb+WTyOOCScdWNhb4F5MCjHGYw Gk6J6AsC39HEqPHR/jZkZqx2wd+cBT1uZKymOWImgc+nng6i4FB01NQmhUoux8izeI6Z TSCwD6zXyds36beF+cjn4D5kzcgrn2KO1LsY12SUyQ2n3YIBmT99HuJvZgz6dczFStPe eLeNhnxeyrl0BztstFN3PfS+WZm27Iv4te7bzOI0fmUMNuyJklx+SIwnS1+HYpoKcKVF soGg==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; t=1783580979; x=1784185779; darn=postgresql.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=J7EjVmN6vNv5IUzh/frO6OIu4+ZdywA8s5QcksSnkHM=; b=bng+v/EPXvAVpXGVXD0FyOjTWkuvnKyo/E/yqFuU+tC+gAgGtgONhEJLMGS8UBxgRU L/+uFR5kGBYKHRJKb0Nqaw380141KHlejZOewTUVUYVxzbPZGEVjD6vmTY33ErYW9crJ 7zslYYlndENzku/dRgK632InxKOcg4/CosvyU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783580979; x=1784185779; h=content-transfer-encoding:content-type: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 :content-type; bh=J7EjVmN6vNv5IUzh/frO6OIu4+ZdywA8s5QcksSnkHM=; b=Uav0SLMsty7G1le0Ofg2oGNA6JY6CnFLQ8dh7EDf8z6J9F3zTp6hvV5r35kOSq33OZ CFI1iDawzzXiUIbK8vRo3udOAXjAwO2koj6hLeK3baovorwMcJP39k1MCSyo70PPZ8Dp 1u2SwiG+/4GKBH7d3o0CiUaIOT35vD2S0b52YfRoM+Cnd8V8mh83vlJce8t6mfr72HPO hdrvy64TDK6zP8BarV//KwltgcoFkkoTfqp2tN0in3xst2thrPNvc8iGtQ8bJ6cYFFsm rxfiTTIr527T7Ec42C2TCvLk7TANPXnLn/x+J2SStJPINSLsPIrjybKc5QucOMnUvtuB VkEg== X-Forwarded-Encrypted: i=1; AHgh+Rp5TonmajuSNKwJ12r/ezuWUZDzJg8Ua1Ywlt39PAsWDOcpkdaTRbAgB2m9NmrQ+zGH+ZzTycznX1lzweGL@postgresql.org X-Gm-Message-State: AOJu0Yyw9h4YRei6SYmb8Na/wxyHNfPGda2JDTwxE472jaHafxwehjQ/ NAP95NRdsomHHusTV6o8oqUS5WsQxBb20s+JCBLmk3GLbfRUuM7Kvh4UCnVS6w967UGXjHSF8s0 V7qCR0CcSAtFMJYCCy8SddCPmdi6SgXJ3FA37uw+HlA== X-Gm-Gg: AfdE7ckmkuoMAeKAjHXPWPR0zJ0v2+ZWFtxDEBRLeb91rE3PMO9vZ9n1mKvKq7ZsUm6 yRIAhDKPEbztLYHW+ipNhGodPqFDQih+nRRkTvQ57+VGrfuWfKi0K7/NtISNSZ/s+QHBag9+rdI ZO6pCplQH5LsBu0u/cKDIoSeaHOsacgQARSIc/oKV3AXSn23cTtK9VeHZYX5XkiOAOmAD3AOQba XLMJsy9YD0/RRY38ANCeHYXgxy2BuL/nRDDXitevjAHgzdmnulKhucI2g54gbkCCeeF3yg= X-Received: by 2002:a05:690e:4850:b0:667:b262:16c1 with SMTP id 956f58d0204a3-667b262358cmr2077609d50.9.1783580978844; Thu, 09 Jul 2026 00:09:38 -0700 (PDT) MIME-Version: 1.0 References: <20260708194951.34705f93@ardentperf.com> In-Reply-To: <20260708194951.34705f93@ardentperf.com> From: Anthonin Bonnefoy Date: Thu, 9 Jul 2026 09:09:25 +0200 X-Gm-Features: AVVi8CdJqtnu3FaKXdEShnScx9bzvmI66xcoYY-XWhdb-vTa4nbISPlmpvTelgg Message-ID: Subject: Re: hang during shutdown To: Jeremy Schneider Cc: Jakub Wartak , Srinath Reddy Sadipiralla , PostgreSQL mailing lists Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jul 9, 2026 at 4:49=E2=80=AFAM Jeremy Schneider wrote: > Between log messages and wal contents, it appears > PostmasterStateMachine transitioned into PM_WAIT_BACKENDS but never > progressed beyond this. I don't think walsenders are involved until it > transitions into PM_WAIT_XLOG_SHUTDOWN which doesn't start until after > the shutdown checkpoint (which never arrived in the wal). > > I remain pretty stumped :) The walsender logical bug happens when pmState is in PM_SHUTDOWN, after sending a SIGUSR2 to the checkpointer. The checkpointer then asks the walsender to stop through WalSndInitStopping() in ShutdownXLOG and wait for them to finish, before creating the shutdown checkpoint. If the walsender is stuck in an infinite loop, the shutdown sequence is stuck in this state. As you didn't have a shutdown checkpoint, the symptoms look very similar (though you didn't confirm whether you were using logical replication, so I'm gonna assume you do). Just looking at the logs won't tell you much, the most visible symptom would be the walsender process stuck at 100%. Another signal would be a OVERWRITE_CONTRECORD record written just after restart, as the last record would have been partially. Looking at the last WAL record when the instance was stuck could be interesting, though if it's a partial record, it won't be visible with pg_waldump. If you want to compare, you can reproduce the walsender bug with this query (you also need an active logical walsender): -- Start from a fresh segment SELECT pg_switch_wal(); BEGIN; -- A logical message record is: -- 24 bytes of record header -- 5 bytes fragment header -- 24 bytes xl_logical_message -- 2 bytes NULL for prefix + message -- x bytes message length -- Total size of a WAL logical message is 55 bytes + message length -- With WAL long header, the first page has 8152 bytes available -- With WAL short header, the second page has 8168 bytes available -- We need to write 16320 bytes (+/- 8 bytes of alignment) SELECT pg_logical_emit_message(false, '', repeat('a', 16294)); ROLLBACK; And immediately try to restart (this needs to be the last WAL record), the shutdown should hang. Regards, Anthonin Bonnefoy