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 1vixoR-002ZHe-0B for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 16:45: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 1vixoQ-00DlCd-0W for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 16:45: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 1vixoP-00DlCV-2X for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 16:45:38 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vixoN-001vsp-2h for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 16:45:37 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-b872f1c31f1so162616266b.0 for ; Thu, 22 Jan 2026 08:45:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769100333; x=1769705133; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=jQsc80TM8zpn6ZczTn6BoXZpzwPC+/bKFRmhZCGNUME=; b=l63qEu5PtrGG+CppKMEfea7EINchWA00KKZoAGre6SdjAZ6ht+gdkAYKZXNfOK3y7d BEEJB9qTg23QxDzlZS8FSeXTRhN9FLHZb5RfuXQR9xhe2IVz6EwYlbmrOfYh6G7h53yv do4Qp6WJm/Qa3oJkP8ZPQXjxKMTGvzkbskc0yPz2EDpAVS77m5PXx77m1luxuL9H3kBq tbM6LvNrWXibTo0GouEoOt1F/gv/uCjD6AYWDxq63p1Hu8LRF09StChu3UGDFzigZ/Et fiNpb14aNkzoOJaR7jinpvf8Xncu8uowZb4hvgkthK9NcOl1nY++GcwJiLaw4Es5wcB0 q4eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769100333; x=1769705133; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jQsc80TM8zpn6ZczTn6BoXZpzwPC+/bKFRmhZCGNUME=; b=fbqxFM6STioaSM6+zKwIL/zl59ZETyNAuZgHbFWVzVPIR+q56TnPYBw296k/nTcvux z9oPvozrxcEdSI8M8zoNBYOysg6pEl+GYBQFZEz/PBBwOobMRVAuMLLTAya6nOVWuCfZ OlHESnQiwdG7kMTggTxdBI6vTwR/TH6XnLcCFyndZdpYT4G7aE3Lr0f5IPQkD44QoQnm ra39XfL+4AzWpNBKo6dNGoZaaENFX6EJB17en4du2F/+ZgFuLDgqtWqRm6Z/V4rSav2w 3+2We7b/JHDVOeOJ1t3l45HpAyW7ZtMA5+zmRMxDc6NPs/UeoP74CIsiObcKpCGXXPSP OfBQ== X-Forwarded-Encrypted: i=1; AJvYcCWLrKxLgRAJ0zAaqDe/ldt/4b9ktep7ptWsFMxy2cdXqPkaTUDQQhWVsXLbCSi3MaCNynXbkv3nJ1t+/cHE@lists.postgresql.org X-Gm-Message-State: AOJu0YzoYp3lrynM9hzCAXOfOZEFTJOsf89ILpA5rZkoN1xqSiIywLQN HWVVG2HDMUBtq374Caf8yG/OIvnCAzjaaoda5bbYD+4PphSSjLbr23Wx X-Gm-Gg: AZuq6aLTJ9FW9G0aIXL200rwMRKhRGXR0G+P3/3dMVa6H0LmHOSrrfQz9GsY/sDB9d1 7aTE7R3GcZuN3anVbxdUiN8V6ZdH5ZpVA7527ghJ8MmuX6htwD6z/ihr8jHkSvFfBtQWY3wuMhW WWfcBwlzFO5BG2qPvwyZt/l6kvXpul+ZjEWsofutAKvVRzAHvIyYxWHv1R24ph6t3AUGrwadwyk rVyFETmEVGNM4cEOo9HaPX6BRDFQvKf1cUn6egYVz3lYj8na0OkQppp5i0OOQMXUfln9XYHj/Xv XikcRqXggwKrNqEgivol4QKYFJs+QfzSo9uFougHw/DkgQP/DEaBDNcaFVRISj2wO+4hkJnBZck azd89pJxzWKxq2BdXIr38L1IJXnCHC3Y8ZFBX55lUlOomrDKXsEE6REcKLm24hzarzpClqr/Dpx 1tY0TMq0UFU8p3unwAtgezZV4FLLka4NNUjYcLJZvf0ijVU0vNrDVsvYg4LZhBhwKVL0owAU7ua /a0KIFPZhkzWrpqTbGYdQSfD4ltyekKyJjCmk9FIR9fXk/DQILKTPGl X-Received: by 2002:a17:907:9286:b0:b87:322d:a8bd with SMTP id a640c23a62f3a-b8800427d72mr672074566b.24.1769100332889; Thu, 22 Jan 2026 08:45:32 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8795a31bffsm1714440666b.68.2026.01.22.08.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jan 2026 08:45:32 -0800 (PST) Date: Thu, 22 Jan 2026 16:45:31 +0000 From: Bertrand Drouvot To: Fujii Masao Cc: Sami Imseih , Michael Paquier , pgsql-hackers@lists.postgresql.org, Zsolt Parragi Subject: Re: Flush some statistics within running transactions Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Thu, Jan 22, 2026 at 09:12:18PM +0900, Fujii Masao wrote: > On Thu, Jan 22, 2026 at 4:43 PM Bertrand Drouvot > wrote: > > > > pgstat_report_anytime_stat() is called with the force parameter set to false, > > means that the flushes are done with nowait = true means that LWLockConditionalAcquire() > > is used. In that case, do you still see cases where log_lock_waits messages could > > be triggered due to the new flush? > > I haven't read the patch in detail yet, but after applying patch 0001 and > causing a lock wait (for example, using the steps below), I observed that > log_lock_waits messages are emitted every second. > > [session 1] > create table tbl as select id from generate_series(1, 10) id; > begin; > select * from tbl where id = 1 for update; > > [session 2] > begin; > select * from tbl where id = 1 for update; > > With this setup, the following messages were logged once per second: > > LOG: process 72199 still waiting for ShareLock on transaction 771 > after 63034.119 ms > DETAIL: Process holding the lock: 72190. Wait queue: 72199. > Thanks! I see, the WaitLatch() in ProcSleep() is "woken up" every 1s due to the enable_timeout_after(ANYTIME_STATS_UPDATE_TIMEOUT,...) being set unconditionally in ProcessInterrupts(). We need to be more restrictive as to when to enable the timeout, I'll fix in the next version. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com