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.96) (envelope-from ) id 1whPuc-000D0B-2u for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jul 2026 10:53:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1whPua-006hST-35 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jul 2026 10:53:53 +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.96) (envelope-from ) id 1whPua-006hSK-2B for pgsql-hackers@lists.postgresql.org; Wed, 08 Jul 2026 10:53:53 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1whPuZ-000000008l4-0PI9 for pgsql-hackers@lists.postgresql.org; Wed, 08 Jul 2026 10:53:52 +0000 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-47de0093c42so529775f8f.3 for ; Wed, 08 Jul 2026 03:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783508029; x=1784112829; darn=lists.postgresql.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=MJU945FSPHb7pskVBQLZS4zWxcDN4T3tehshLbDRMBI=; b=ijmYoU+CEjp+5TrQgEw+/YWSOYmp7lTsxbWaoeU+C3HwrrRwMuamzacEoGXoONOvWX NPpnlQUWZrbaBb09/oPtQMD7LRjTaIvJTEg6qCeYNZX+AmprNKQvL6xvBFtuC7Huc0e6 noIj/tO0H4kO+nXwURenP6mhDXj6grN3EIAmlg6yKUYe6iHZbAsXbQGlckgPX8nmXuEa 9PUHeTbLeso4W2g9mRLeGbJ77id0BKvrzjUo2GRfgSm0vwgLJc5sbCO0K3BCigpeFPHH L4MLrKZdAxVRIVwc7T3aDy+kWQztOf1BMg/biD1eNn5YKqU+GzCpqOSNBnhj1Vc+OWGp aMfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783508029; x=1784112829; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MJU945FSPHb7pskVBQLZS4zWxcDN4T3tehshLbDRMBI=; b=cKrKmHUcTfVRGR8A0IhguwhbGqZ0FWJnqEtUOHI8KAIKY+NSBMTg1mlmhuhj3aWe3y yUaGrXwX2vJ0v0GZrNZOh+zJ2uQzMes7obFDMp9B48o8b7zl/k8bR5qi8EVORY3tgpoi +kZnBXuBS8o5jFyFVxtyb4HsMOqrEkfrKt/uBHzjFSIO2f5AxIzqM5jfDDe8mOyzbnIA th+4+/k20PnKtU9qBMnhwDq3uUj9JVpMT9YPdcgpFovuMggN6y8qk2QGfqHweTeB/cwY AGeMFQ9gfggIGawSaSreeUHgaIU94eAfFspbcuiG5+WgvgcMjRpkqAnCtLQbs7PjyLUc N1Kg== X-Forwarded-Encrypted: i=1; AHgh+RpHA1AjnEOyiXrsCTwoBUcxochcIWaEvmrFISfyu528x4bwgLCHkj7/SF6AwrOcISW7iTExQTmZN4WBP4RB@lists.postgresql.org X-Gm-Message-State: AOJu0YwJY+ecytCafMI+wCNf7Jo+Vm3PLuLPecaeNXoPCp5oPtEs5zHm M5te0sD7S1rGgGSaz+MfAfl3hDkidsu5RGr4OiVbAAgUedHyn5+A6Jl6 X-Gm-Gg: AfdE7ckfyMT4laEO4aOoCB7ocoGyqyUpW6p6lW1KuhPy4ypRVu3OCmlYeY2MeScdZN0 BOK3/6r2U9IeuB5aDuDj9crKvJkSnZN2MG+/A+eqp69ZwLNAor5oDiuNUh400zbw1jcwUg1xrPO r1Q7+xS6+LCcai+FxXb+755cCoHTOLHVhPW5WK9lCXqVRfmYEe6s2y19pNYueoPhx5Qq4Atzj+x wPwmJnm3MebmgFnKB0SV4JApzlD4/f3bRnHstIZa9EQpVUW/J6Pn7ssUM4ZGf0u9qAiC4g6fgiF 9DuI/Gck+5NyTMdnbD/yiySyaf/+Mt8KjeNmeuTwejv0ZtaYnWAY6fU/sjwXtFkvRR6b8ODHD1Q SAw5rYNwqO2hb0p+iCgjmWxAnuRmja7zRfmB1kpAxWnn9LFwXyQ8/0AvCrW9lwSMFWqq0W59rbu 1hfmMqgMlcH0HxVUONzMjq+irLRsN4nY843onnqDS8cvsQlHeHFsAjdNWGTBEVy6Y6LpKi295q X-Received: by 2002:a05:6000:24c6:b0:474:9991:60d9 with SMTP id ffacd0b85a97d-47df073b0c4mr2217207f8f.10.1783508028590; Wed, 08 Jul 2026 03:53:48 -0700 (PDT) Received: from bdtpg (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47a9e4d8410sm42245010f8f.15.2026.07.08.03.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 03:53:48 -0700 (PDT) Date: Wed, 8 Jul 2026 10:53:47 +0000 From: Bertrand Drouvot To: Michael Paquier Cc: Kouber Saparev , pgsql-hackers@lists.postgresql.org Subject: Re: BF mamba failure 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, Jul 08, 2026 at 08:59:35AM +0900, Michael Paquier wrote: > On Tue, Jul 07, 2026 at 01:13:59PM +0300, Kouber Saparev wrote: > > We had this issue again, the database just stopped - PostgreSQL 17.6. > > > > FATAL,XX000,"trying to drop stats entry already dropped: kind=relation > > dboid=16420 objoid=3885511363 refcount=1 generation=0" > > > > There is no such object present in the database. > > > > Do you think the issue might be fixed in PostgreSQL 18.4?... Or PostgreSQL > > 19 eventually? > > Well, honestly, hard to say. That's a case where a reproducible > scenario would be useful, as it seems to ve very workload dependent in > terms of handling of the relation entries.. (Aka I have not dug in > details how to do that.) > > As one example, the buildfarm seems to be quite silent, but it would > help if we need something like a wraparound for better > reproducibility. So given that Kouber said that "we have around 150 entries added and deleted per second in pg_class, and around 800 in pg_attribute. So something is actively creating and dropping tables all the time.", OID reused is likely the culprit ( doable in months at this rate). To try to simulate an OID reuse, I created an extension to manually set the next OID and was able to reproduce the issue on 17.6, that way: Primary: create table popo (a int); Standby: select count(*) from popo; (keep this session open) Primary: SELECT oid FROM pg_class WHERE relname = 'popo'; (17044 here) Primary: drop table popo; Primary: checkpoint; Primary: vacuum; Primary: SELECT set_next_oid(17044::oid); Primary: create table popo2 (a int); Primary: SELECT oid FROM pg_class WHERE relname = 'popo2'; (verify it reused 17044) Primary: drop table popo2; Produces: 2026-07-08 10:30:22.566 UTC [2096038] FATAL: trying to drop stats entry already dropped: kind=relation dboid=5 objoid=17044 refcount=1 generation=0 So, the standby backend holds a local reference to the pgstat entry. When the first DROP is replayed on the standby, the entry is marked dropped=true and refcount goes from 2 to 1 so it can't be freed. Then when the second DROP (for popo2, same OID) is replayed, pgstat_drop_entry_internal() finds the entry with dropped=true and errors out. The good news is that it does not reproduce on the 17 STABLE branch, I guess it's due to 850b9218c8e being backpatched to stable branches. So a fix will be in the next minor versions. Michael, I wonder if that would make sense to add this "set_next_oid" kind of thing to a contrib module to test this kind of OID reuse issue. Same idea as xid_wraparound. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com