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 1s79dB-003z1q-UE for pgsql-hackers@arkaria.postgresql.org; Wed, 15 May 2024 08:04:59 +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 1s79dB-00Bdi7-2B for pgsql-hackers@arkaria.postgresql.org; Wed, 15 May 2024 08:04:57 +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.94.2) (envelope-from ) id 1s79dA-00Bdhz-OS for pgsql-hackers@lists.postgresql.org; Wed, 15 May 2024 08:04:56 +0000 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s79d5-000KZQ-Ag for pgsql-hackers@lists.postgresql.org; Wed, 15 May 2024 08:04:56 +0000 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2dcc8d10d39so76387821fa.3 for ; Wed, 15 May 2024 01:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715760290; x=1716365090; 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=VMWijc7djNEPpuq8K4W/ACygaZklI8PIY14yozRJ1Rc=; b=MkK/YdEP+e2gMYKFAlFGndh818iTZVORvktmwg1t4qvhrLde257gg72vbVoszPJMxq hkOemvbSQR04gPVBInB3px3/Mf2+GPG+D613EFqIkEsmKyNKENp0O28AAA8RMETKqkty NwWrBWbSznsaCnpujbAqgKXeDONYvEg4OGC/vIe5hrbcHY4MZTbv0yfyy+/gVA9c1ELg eBLAXLRpIEUMG3mRkIgEr7A23MljoBdVEJdFPhmaPBWZWOkcBTG3iLZwt2cL9pFWiMqf UOF1fktMAugeDnfNXYU7vQTZcw0GeORwJ1eedpqhFKC8xjQMRGfav/4ADwRE9f4Lmnt/ vogg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715760290; x=1716365090; 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=VMWijc7djNEPpuq8K4W/ACygaZklI8PIY14yozRJ1Rc=; b=ba89KzeIl9rQzUjp5oJ1hn9mOZyUFqhGqt0VQAKOYdjOmIj54SotUZBDVp/1KoZqPG p1rn3LNrDsp2SlvHidAbDgVhf1QOQj0fQfm1WlKPC7TFb4xXy9LcdyuwLZlETa0C/WuD ikKT2nw+pv9nhA1I8dzdgWS64p9AYFhdZZxh592b6LKakWXdLR045DOGeUQnu85I13bi NBdveXM6dKQx/dr1RiJ746g1anSV/VzdYT/xEhkiRUAKqJlk17gEtlbBzNyD9r9E0VKV pF6kH0MU8Kprq/p9Z6ECZJIimty2K4/+WRqFLAMd5IO4aWiKCd7+WN3fezVA/tR7WZmU 2rhQ== X-Gm-Message-State: AOJu0YzarIpMxyEQeTrTAtHheIJdXKuLpIyzZmrQvvPMNgfov1b7uEuS kxaL3l3zwR8hD7MAq+tZhjw299omAy7PB5NFKvqPO2p3nCst29tD X-Google-Smtp-Source: AGHT+IFF76qs0fOoeCpf5WOVgXo5TxqsvkPeKkv4TTifZBzJBxHeFOLZ3im1LV+ryUDEjXy4sE7/HA== X-Received: by 2002:a2e:4c0a:0:b0:2e6:cbe9:daf8 with SMTP id 38308e7fff4ca-2e6cbe9dc49mr30231011fa.6.1715760290191; Wed, 15 May 2024 01:04:50 -0700 (PDT) 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-3502b896a5bsm15631032f8f.36.2024.05.15.01.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 01:04:49 -0700 (PDT) Date: Wed, 15 May 2024 08:04:48 +0000 From: Bertrand Drouvot To: Michael Paquier Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Log details for stats dropped more than once Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="/8qMM0nayze5naH5" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --/8qMM0nayze5naH5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Wed, May 15, 2024 at 02:47:29PM +0900, Michael Paquier wrote: > On Tue, May 14, 2024 at 10:07:14AM +0000, Bertrand Drouvot wrote: > > While resuming the work on refilenode stats (mentioned in [1] but did not share > > the patch yet), I realized that my current POC patch is buggy enough to produce > > things like: > > > > 024-05-14 09:51:14.783 UTC [1788714] FATAL: can only drop stats once > > > > While the CONTEXT provides the list of dropped stats: > > > > 2024-05-14 09:51:14.783 UTC [1788714] CONTEXT: WAL redo at 0/D75F478 for Transaction/ABORT: 2024-05-14 09:51:14.782223+00; dropped stats: 2/16384/27512/0 2/16384/27515/0 2/16384/27516/0 > > Can refcount be useful to know in this errcontext? Thanks for looking at it! Do you mean as part of the added errdetail_internal()? If so, yeah I think it's a good idea (done that way in v2 attached). > > Attached a tiny patch to report the stat that generates the error. The patch uses > > errdetail_internal() as the extra details don't seem to be useful to average > > users. > > I think that's fine. Overall that looks like useful information for > debugging, so no objections from here. Thanks! BTW, I just realized that adding more details for this error has already been mentioned in [1] (and Andres did propose a slightly different version). [1]: https://www.postgresql.org/message-id/20240505160915.6boysum4f34siqct%40awork3.anarazel.de Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com --/8qMM0nayze5naH5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-Log-details-for-stats-dropped-more-than-once.patch" From 0866e8252f2038f3fdbd9cfabb214461689210df Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot Date: Tue, 14 May 2024 09:10:50 +0000 Subject: [PATCH v2] Log details for stats dropped more than once Adding errdetail_internal() in pgstat_drop_entry_internal() to display the PgStat_HashKey and the entry's refcount when the "can only drop stats once" error is reported. --- src/backend/utils/activity/pgstat_shmem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index 91591da395..0595c08d6e 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -785,7 +785,12 @@ pgstat_drop_entry_internal(PgStatShared_HashEntry *shent, * backends to release their references. */ if (shent->dropped) - elog(ERROR, "can only drop stats once"); + ereport(ERROR, + errmsg("can only drop stats once"), + errdetail_internal("Stats kind=%s dboid=%u objoid=%u refcount=%u.", + pgstat_get_kind_info(shent->key.kind)->name, + shent->key.dboid, shent->key.objoid, + pg_atomic_read_u32(&shent->refcount))); shent->dropped = true; /* release refcount marking entry as not dropped */ -- 2.34.1 --/8qMM0nayze5naH5--