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.94.2) (envelope-from ) id 1v3Uak-00H7Jk-J5 for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Sep 2025 07:16:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v3Uai-0073TS-Iy for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Sep 2025 07:16:05 +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.94.2) (envelope-from ) id 1v3Uai-0073TJ-9q for pgsql-hackers@lists.postgresql.org; Tue, 30 Sep 2025 07:16:04 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v3Uag-000ePR-1H for pgsql-hackers@lists.postgresql.org; Tue, 30 Sep 2025 07:16:04 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-46e30ef74b0so38445005e9.0 for ; Tue, 30 Sep 2025 00:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759216562; x=1759821362; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=gVr/FCo7OAOTngzit3UJ7QtpEWGQd3iyOoWOgUEumRU=; b=fZSgrJFzfKoW6M5EqSjHlgm9xFPFPXakwUqiInAxNCux3NqUl4sZlCTqwTDxQjLNhD 5XWgD37aKYOO/frdsTv5BHpq9aj0uTj7iBpAqx65D/TiDY6M4vD6COCHWjEbu9D+pEa1 Aw403R5vqFEm94I2p45YxBE9RZW2uIMgkF6lTsPAWn9ZEkI7Z2AcEciAK4+1UfIwxsvC 9W8B/nPR15sBZpJqPAd9bG8fTLxJ68sOSxe3HxGSMgG3QWzWrbXQ68+tVPUzETwS/Uax 74eSwqpbWdZBoEzu90czODFpqsCLa8mr7MHzgt44tII/2dQVaqplUCSFu8bwFBi07aKP Bwdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759216562; x=1759821362; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gVr/FCo7OAOTngzit3UJ7QtpEWGQd3iyOoWOgUEumRU=; b=bGrntKgW0LV1qbHNRXtumv4nTw24cbfGZWdxB2Auisv7W7fa2OVSWXnetEh1kEtyXp tXUbuLW+zKLm3eg+6DsLiGTOaux4SGxnGV4ADIOAJ5QgN8ESUpEHAOhlAfOFaSt9Bd40 rvUK4M2oiH9bD4jv9sWsPVnqSjeHJghpblmMxQSqs1l6CvxU8Wqc3UT56oZlbdnYe/Nk ZnFWVjWGe7864rYcCjVrvpvM6RCb+Xt8G/PRW+BpdPYTokcKH+/FZzPiybVuifkbh9FR SRABd3Ny73R05LjtrAAmTeO0Bth/4dyH7gwppSJpE7WGLnNHoh5tnCQtEQSPxO7vjnas OH0A== X-Forwarded-Encrypted: i=1; AJvYcCWo6oyL4XJJfn9FMPhi6rUU4dJ8rLK2OCXVYoMx90v1KZUVyUJVoMLpXUWTCmtXioI0WUMz11GfJeNipIMV@lists.postgresql.org X-Gm-Message-State: AOJu0Yzlo54bGyGoiQgfcfLJogSZCBRQjRU++v9mtIOngjcHeZAXaHZM NuqSNBvQhJI8yXBcIwHPDeuD5bmjnf5HdRITjk2w05gXYb6r+nfHqpsh X-Gm-Gg: ASbGncsU6JhH5IM5S3zMCHpTzUqRSqKY0P5ANz2Rd2i4k6zVXDN2H7BXj9iF/oE/56P RzKkSwxka/ZfJe0IiN8U4qtldkv6+zc8jGwubBcVTgSx+MEQ06izdrr3bQMKLlq9uuw5Zt+O2Bs aZS5QMlZR+IRVr+XkQ+D+6OTobunu7xgq61fZFzv8sHp0Uwpgj1gA5HzwFTMxmVjWhHK/y3cs4+ pVtro4NFo+OmnB9IP8AwH4OI2DS0S0MNF5shJpgj3xyMFmUJ8XW8DRzKHUTA0s4j6nj2YgIjSli B4M/6/de2Ry6Vt0AjwahYfvDopTze5Wsh5MNsw/skZ7P6BrWgIpl/vRiywtZGWQdM1IEi0v9iTB sSetkvc9uUvIFIjuLhvKG3snKvT78AbqYr4dvYd6XYOjpq9Vjbs9gyWiABjHKG+ZfjSef6R6q8n z8idY7c6lsHif8HY6V5/QVv8Hs0kDOQ+F71d8AnLTn92yvaCLBakcuJkEZ1aqQzBQZDdNQq8Hlo rHRTjLLoi7ayTDk X-Google-Smtp-Source: AGHT+IEPsE/XSS8Bc54OodN9aRPyZYWZq3Yl68JgKKeK4dF2ZxS4WrzeJI5cqIYqRyrcyOpyvQD5oA== X-Received: by 2002:a05:600c:1e1c:b0:46e:3193:fecb with SMTP id 5b1f17b1804b1-46e32a03529mr154892095e9.27.1759216561728; Tue, 30 Sep 2025 00:16:01 -0700 (PDT) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-181-182.eu-west-3.compute.amazonaws.com. [15.237.181.182]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e2a9ac5basm290655285e9.7.2025.09.30.00.16.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Sep 2025 00:16:01 -0700 (PDT) Date: Tue, 30 Sep 2025 07:16:00 +0000 From: Bertrand Drouvot To: Andres Freund Cc: Michael Paquier , pgsql-hackers@lists.postgresql.org Subject: Re: [BUG]: the walsender does not update its IO statistics until it exits Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Wed, Feb 26, 2025 at 05:08:17AM -0500, Andres Freund wrote: > Hi, > > On 2025-02-26 15:37:10 +0900, Michael Paquier wrote: > > That's bad, worse for a logical WAL sender, because it means that we > > have no idea what kind of I/O happens in this process until it exits, > > and logical WAL senders could loop forever, since v16 where we've > > begun tracking I/O. > > FWIW, I think medium term we need to work on splitting stats flushing into two > separate kinds of flushes: > 1) non-transactional stats, which should be flushed at a regular interval, > unless a process is completely idle > 2) transaction stats, which can only be flushed at transaction boundaries, > because before the transaction boundary we don't know if e.g. newly > inserted rows should be counted as live or dead > > So far we have some timer logic for 2), but we have basically no support for > 1). Which means we have weird ad-hoc logic in various kinds of > non-plain-connection processes. And that will often have holes, as Bertrand > noticed here. > > I think it's also bad that we don't have a solution for 1), even just for > normal connections. If a backend causes a lot of IO we might want to know > about that long before the longrunning transaction commits. > > I suspect the right design here would be to have a generalized form of the > timeout mechanism we have for 2). > > For that we'd need to make sure that pgstat_report_stat() can be safely called > inside a transaction. I can see an issue with GetCurrentTransactionStopTimestamp(), any other issue /concern you have in mind? Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com