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 1tSBEr-00Eevq-9p for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Dec 2024 08:35:01 +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 1tSBEq-00AkLS-Fv for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Dec 2024 08:35:00 +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 1tSBEq-00AkLJ-4k for pgsql-hackers@lists.postgresql.org; Mon, 30 Dec 2024 08:34:59 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tSBEo-001Dtt-15 for pgsql-hackers@lists.postgresql.org; Mon, 30 Dec 2024 08:34:58 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-385e27c75f4so6525748f8f.2 for ; Mon, 30 Dec 2024 00:34:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735547696; x=1736152496; 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=sWadvnFQ4gGmviiHDb2tXK0ehZiHG9Y2UstadV6UyNs=; b=lk0p6sVOOX6yD5Q+8K72FHMRQbBRPFzWRefbEo8I5tFwb8k+wB5L4vPzpcivSldMQb py9JeOLbIUztaIrk6X8vMOr99gF+gHXND4Q4N06uQrYDxUcSuvWCZAQktbv2m/Y/f9qK 8unSgTM//nNwYhZLGHplvyEHR8HOxgZRj0lB8Js2BdvltXqTz6vLhPRuWyxMIijkBR2N /zcLdGYdERXNigu2QosELb5VSXY9qb2Gkj6w7+ZpBcOrq6ccH4RMdGf6UalYt+W7louO R+vSQlMP9UqCiuNnAFYD36+NfBYoO6kdIiA1jOC3lRAM2ZZkVpUgbxwQcVHzbGr7h/Kb jjqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735547696; x=1736152496; 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=sWadvnFQ4gGmviiHDb2tXK0ehZiHG9Y2UstadV6UyNs=; b=EGbNcxJNKfqrj3ezKnI1RUpE/NyjiikPCpDrqah1PIMAF6OCoUfk7qtjY3CP7/j9zZ ucrmIL0dItRfHfCshF7n67NZ6IePHuY7vNFo6tdUUttY+I4dOqJLsx4AlQX3wyIZOtmE Lj6EsQDGs9HqdHyicpdd4hUrfgaGmf2A6s2bmOsc0vdeaYIyafI+iZfp3cn1pMEF5/+2 GsLxXpmcSEwT7VxAzFaFY6CM7Y3IdIWMMTzREr37SxCq002YiHN/j+26upFFP5ggiAXd BKKAP4m/1j7x1yxzB/QZPBJyfK5WVj9hMPaUefcukbuoI4YROyL/1ebG1SVJZvyeo2jj UpNw== X-Gm-Message-State: AOJu0YwRjkoMv29zJsJkjvT/NRZswvyvYsVEwNXrDc5wLbISTDGMdK6p scuLpbQe8CMQE4g9zSfHt7xMgcqs0scPf2IKzC/HuvKWLlHohj7N X-Gm-Gg: ASbGncvQMvrO6Ie0VyhTTkVrM5uSRGINXQOAehIqXrjdGsUJhS46ZWReBZKC0m0xwBY Ryh0zknvHxqncVH/YbInImFk6i/C2OoUeNy/8R8sWdBcHv8fOgAwqyr+yobF2AwJiXhQ3+Sqe3q hMBVWXHY2RC1cdnKtGhxTK0mKV4k1iWKAb0XQYnKCOdJom+cDPflxOdMvlSzFSB75DNOTrPl6og lS7U64GAz4bfizcdDR9PiUqRhBk1RxXN1yvpAYrbspFrIkrdVgPkM/BijsgrVNSOoc9HffqoZNB HBN6I59TgcR+gNCasIyJT32bL5oxQfvrbPdOiIhhZQ3TGij23i7VcLfQaUHBvW1A05IazQA+y1/ j+tCVqpk= X-Google-Smtp-Source: AGHT+IEC65TgGhLT8DYyO/CFteO27ia7UdvkvqEp2k4Xj/6UMCHLlb//r37X4pCVMB9HJe0COVc5JQ== X-Received: by 2002:adf:a30f:0:b0:38a:2658:bbc7 with SMTP id ffacd0b85a97d-38a2658bc1bmr19930593f8f.29.1735547695859; Mon, 30 Dec 2024 00:34:55 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8330e0sm28984357f8f.34.2024.12.30.00.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2024 00:34:55 -0800 (PST) Date: Mon, 30 Dec 2024 08:34:54 +0000 From: Bertrand Drouvot To: Michael Paquier Cc: Postgres hackers Subject: Re: Fix handling of injection_points regarding pending stats 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 Fri, Dec 27, 2024 at 09:23:12AM +0900, Michael Paquier wrote: > Hi all, > > While doing more stuff related to pgstats and WAL, I have bumped on > the fact that the module injection_points uses for its > variable-numbered stats a pending flush callback but it does not > handle its entries so as these would be handled locally first, with a > final flush timed by pgstat_report_stat() that would itself call the > pending flush callback. This is a less efficient practice, because it > requires to touch the pgstats dshash more often than necessary. > > This is caused by the use of pgstat_get_entry_ref_locked() rather than > pgstat_prep_pending_entry() which would make sure to time the flush of > any pending entries appropriately depending on pgstat_report_stat(). > I'd like to fix the module so as the flush timing is controlled like > all the other stats kinds, which is a better and more efficient > practice to have anyway as this code should stand as a template for > custom pgstats kinds. Agree that it makes sense to rewrite this part as done in this patch (as it reflects better how things "should" be done). > While doing so, I have also noticed that injection_stats_flush_cb() > missed a pgstat_unlock_entry() when entries get locked. Right. > All that is addressed in the patch attached. Feel free if you have > any comments. The patch is pretty straightforward and LGTM. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com