Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1prMsR-0003Cm-Hj for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Apr 2023 17:54:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1prMsP-0000c5-IP for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Apr 2023 17:54:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1prMsP-0000bG-8K for pgsql-hackers@lists.postgresql.org; Tue, 25 Apr 2023 17:54:53 +0000 Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1prMsI-001r40-Ma for pgsql-hackers@postgresql.org; Tue, 25 Apr 2023 17:54:52 +0000 Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-5ef465a52e8so59187746d6.0 for ; Tue, 25 Apr 2023 10:54:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682445286; x=1685037286; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=hb+eMT3jmAviQdYbcEO9v7DmrQtaRsePjmgVy4HcfP0=; b=itvwBpGcVlKFotZXxK10TiXz2oVJvgeszZEznTX2XLtIubWWQRo2RZH5G0uQgrgAi7 F1Xp5j/y0DzDrfmwzSYnJ2j7/i7mJghIhpcXlpPPdAc+FrZvcsQ1ILcTYlJU3MoE/TXM poGnYjOkxz1XTFEYNzGksZaKRwj/nm1jN+LefJYklBHbBP6rgRz7oXcrxglNYQL21A6s /f6zph0hhO8VLUate+etx5c9pbBhDXRN4tSywkvea+i/mCwlPkFoz+gJS1D6V76VVmlp oRV0CDlA83NaltANAfxjvuX2bogjmFyT1LwujIzH7FTJktCqK2yeTCgpQ3txY0VlMfem CHJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682445286; x=1685037286; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hb+eMT3jmAviQdYbcEO9v7DmrQtaRsePjmgVy4HcfP0=; b=CuYvORrTRFcfeZ8UsD5zGdHEJUlhq8XSIOVWg+VQVOcDobYF/8w4BHU1THejPxyGvl qRDcoPe9vp5wHjIVy/gw3ERvglL9+rObKYpK+JOgeinbqccJv27lXis6sVDBSNSMm3ws Xj9PBXPIrGni8XGXcaS6PAEXSQEB5AN+w2lI8LEB5e/J5aPerGnNXe5/LNPf8veKkvBL wxyzocE4aofM7FcT70nVHYx3E0+D4KtJklGfj0KW2hAQsY1OYCVVQfre4udD05EQ/88v c8LAOPWhPVH8Sq12FiCHHLVoOu6JGtDFfnNZIRXV/u6eODZ2tmi75EFzvJuHt4B4o2cQ TG2g== X-Gm-Message-State: AAQBX9eJbiH96K2p/taBHwbR02SJPuSF8AMk9NCOaGzzJhRroqU0ymvj Zs6H7Aq7oW+nqpuot1ijZJY= X-Google-Smtp-Source: AKy350Zw8Cz6bcROL1EUenFsgGl9pPZw8OeiB0sEYwYPZMghVo1u4tnld9Fnb2dyuv3ateVLxDva6w== X-Received: by 2002:a05:6214:411a:b0:5ef:4ae4:4da6 with SMTP id kc26-20020a056214411a00b005ef4ae44da6mr30707140qvb.31.1682445285741; Tue, 25 Apr 2023 10:54:45 -0700 (PDT) Received: from liskov ([2600:4040:7eef:cc01:81f0:26e5:92c3:6e41]) by smtp.gmail.com with ESMTPSA id x15-20020a0cda0f000000b005ea7e861d3bsm4200242qvj.145.2023.04.25.10.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Apr 2023 10:54:45 -0700 (PDT) Date: Tue, 25 Apr 2023 13:54:43 -0400 From: Melanie Plageman To: Fujii Masao Cc: pgsql-hackers@postgresql.org, mmelihmutlu@gmail.com, andres@anarazel.de Subject: Re: pg_stat_io for the startup process Message-ID: <20230425175443.j6b3xd5yeh6l3cwk@liskov> Mail-Followup-To: Fujii Masao , pgsql-hackers@postgresql.org, mmelihmutlu@gmail.com, andres@anarazel.de References: <5315aedc-fbca-1556-c5de-dc2e00b23a14@oss.nttdata.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5315aedc-fbca-1556-c5de-dc2e00b23a14@oss.nttdata.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Apr 25, 2023 at 10:51:14PM +0900, Fujii Masao wrote: > Hi, > > Regarding pg_stat_io for the startup process, I noticed that the counters > are only incremented after the startup process exits, not during WAL replay > in standby mode. This is because pgstat_flush_io() is only called when > the startup process exits. Shouldn't it be called during WAL replay as well > to report IO statistics by the startup process even in standby mode? Yes, we definitely want stats from the startup process on the standby. Elsewhere on the internet where you originally raised this, I mentioned that I hacked a pgstat_flush_io() into the redo apply loop in PerformWalRecovery() but that I wasn't sure that this was affordable. Andres Freund replied saying that it would be too expensive and suggested that the set up a regular timeout which sets a flag that's checked by HandleStartupProcInterrupts(). I'm wondering if this is something we consider a bug and thus would be under consideration for 16. > Also, the pg_stat_io view includes a row with backend_type=startup and > context=vacuum, but it seems that the startup process doesn't perform > any I/O operations with BAS_VACUUM. If this understanding is right, > shouldn't we omit this row from the view? Additionally, I noticed that > the view also includes a row with backend_type=startup and > context=bulkread / bulkwrite. Do these operations actually occur > during startup process? Hmm. Yes, I remember posing this question on the thread and not getting an answer. I read some code and did some testing and can't see a way we would end up with the startup process doing IO in a non-normal context. Certainly I can't see how startup process would ever use a BAS_VACUUM context given that it executes heap_xlog_vacuum(). I thought at some point I had encountered an assertion failure when I banned the startup process from tracking io operations in bulkread and bulkwrite contexts. But, I'm not seeing how that could happen. - Melanie