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 1tsiSf-004xE4-7w for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Mar 2025 13:18:57 +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 1tsiSd-00DZtV-MK for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Mar 2025 13:18:55 +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 1tsiSd-00DZt0-7C for pgsql-hackers@lists.postgresql.org; Thu, 13 Mar 2025 13:18:55 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tsiSa-002cJo-2i for pgsql-hackers@lists.postgresql.org; Thu, 13 Mar 2025 13:18:54 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3913958ebf2so765327f8f.3 for ; Thu, 13 Mar 2025 06:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741871931; x=1742476731; 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=VbUx7QLJFeXiTzkaUdkSB4byiW03j41wHxwAALF6qV0=; b=GvasxZMBU/W2ZL1xr8PEhTPsOJkbae4YmKWhdYAPM40JofBBHrlOkrgim42RFDizWl uR5ysixdWSTQ43ccMN9p8Jrt9YZdG2R4DY60XF6lKvOjxWcGx9sT2dk9+/BEm7BCN9Up jpg4ZR+/IWpIJWjFakD2iyZVbQMiS9BnLdCvPK5UGyx0+Odx/GnaO96X2KMuBDAt3UYr 5tSyGg3lgtZK1DIAHeGrwjx4hIngGuGtKq5L5zG5NAmuYnM4RDk9g4ZPWSGEZDrIFdQv pgK8HdVHxjpVnpuYdjUjhakhtZUj6a+EqqdfPJ3dmQ+jH5LLz4SMYkyAYB4dKeoIk3t7 pOew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741871931; x=1742476731; 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=VbUx7QLJFeXiTzkaUdkSB4byiW03j41wHxwAALF6qV0=; b=RLAzApwTK7r5THZvLPal7aPkf/85i4l3/8YmN4Y5nQMaWJucpjqhVqQKMIa6LoLJne cxiZcvfFtbYjRIwaiQo/GVxcTdNKkUmPOh7L4RsAXHkD3BhJvTjx2A5KIyvBP2ScC2E3 XlxJeZav5aZwbLUE3clPdHHKKlyjuStI6TPW04UqqywoHlXJNOn68kNJ6JT5MDauV+gm RRhWN5hVnVRjZzj2zBin96brF3GLmIGa3D0jG9FK8nb6W/w8h6yD6J8tN0Vp0P9csY4X vmlR+ROSOx8b7A1GWahb9TM1wVkUquw7jbdS1mxhrJk9cc78PheqWwEoaJWciFZQyyZu 18Iw== X-Gm-Message-State: AOJu0YxvnOh063rckpIeOMnRECBtonQqGEBPg2u47txEiQYaDwbhWU7X Q8vSWt8dIWuDY+wyYtvRF3wmdh6reWiUfRuUFR4lkq/W9zBbvUEJ X-Gm-Gg: ASbGncskEmR/oOjHZIvVH/8zpOOpsN4Up/7eVqR4rToAMx41JWM+ol+sLh1RmDqMnCx QXV1iX9o+5AHoxJB5DDKD7Qc7egk8C/nYbOSmJrQPsGgmubYnfxOPDiNoMSRCaXSO+GzjRedsKz iSdyvkf/6TjtuK56KuV0qr2uS6ife7N9b5Xsy0TQU8lS1fzccXXYsN2kF8Dv8G8Drez/WwZbCZ1 81rdf2fOEngAOEqoDYv9HqypiWEsvh/btGOBmHaYbjwG6wiGVAtTlSoK4+Y5b5I98wo5FPI7+gy Ebmucv6It5Vo9ebQGL5vnIaXM2hAXQqH/GLuY9oEf8bwYhsr1ke953GPkdD2iNHcIg6mrHQRdnZ Klu6lLNPViHT4FjFSzM1qAlQhEDHH0tvmHFTn/Pq2Gvx50bQKjxsF7fZ0MUBHTjCghoimA25Cw4 X6 X-Google-Smtp-Source: AGHT+IF29l8zBlt02+5VYWONv2rFSo86zuZI00Cg1clR/IPZqbNGvWV/Bp1wQKY6WPxHu8dHmesdEQ== X-Received: by 2002:a05:6000:1863:b0:390:f902:f961 with SMTP id ffacd0b85a97d-3926c4afe6dmr12257016f8f.45.1741871931299; Thu, 13 Mar 2025 06:18:51 -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 ffacd0b85a97d-395c8e43244sm2150660f8f.60.2025.03.13.06.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 06:18:47 -0700 (PDT) Date: Thu, 13 Mar 2025 13:18:45 +0000 From: Bertrand Drouvot To: Xuneng Zhou Cc: pgsql-hackers@lists.postgresql.org, Michael Paquier , Andres Freund Subject: Re: Fwd: [BUG]: the walsender does not update its IO statistics until it exits Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="RYJlY3SbA0pOku46" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --RYJlY3SbA0pOku46 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Thu, Mar 13, 2025 at 07:33:24PM +0800, Xuneng Zhou wrote: > Regarding patch 0001, the optimization in pgstat_backend_have_pending_cb > looks good: Thanks for looking at it! > bool > pgstat_backend_have_pending_cb(void) > { > - return (!pg_memory_is_all_zeros(&PendingBackendStats, > - sizeof(struct PgStat_BackendPending))); > + return backend_has_iostats; > } > > Additionally, the function pgstat_flush_backend includes the check: > > + if (!pgstat_backend_have_pending_cb()) > return false; > > However, I think we might need to revise the comment (and possibly the > function name) for clarity: > > /* > * Check if there are any backend stats waiting to be flushed. > */ The comment is not exactly this one on the current HEAD, it looks like that you're looking at a previous version of the core code. > Originally, this function was intended to check multiple types of backend > statistics, which made sense when PendingBackendStats was the centralized > structure for various pending backend stats. However, since > PgStat_PendingWalStats was removed from PendingBackendStats earlier, and > now this patch introduces the backend_has_iostats variable, the scope of > this function appears even narrower. This narrowed functionality no longer > aligns closely with the original function name and its associated comment. I don't think so, as since 76def4cdd7c, a pgstat_backend_wal_have_pending() check has been added to pgstat_backend_have_pending_cb(). You're probably looking at a version prior to 76def4cdd7c. This particular sub-patch needs a rebase though, done in the attached. 0001 remains unchanged as compared to the v4 one just shared up-thread. If 0001 goes in, merging 0002 would be less beneficial (as compared to v3). Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com --RYJlY3SbA0pOku46 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0001-Flush-the-IO-statistics-of-active-walsenders.patch"