ERROR: could not find tuple for statistics object - is there a way to clean this up? - Mailing list pgsql-general

From Morris de Oryx
Subject ERROR: could not find tuple for statistics object - is there a way to clean this up?
Date
Msg-id CAKqnccgZyxr4geb5zodnm2-gTtLx5QWPeA-VKHw2cm=YQQvOdw@mail.gmail.com
Whole thread Raw
Responses Re: ERROR: could not find tuple for statistics object - is there a way to clean this up?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
I've been experimenting with CREATE STATISTICS to declare some functionally dependent columns. Right now, I'm working with a local copy of Postgres running on this version:

PostgreSQL 12.5 on x86_64-apple-darwin16.7.0, compiled by Apple LLVM version 8.1.0 (clang-802.0.42), 64-bit

We deploy on RDS, also in the 12.x line.

Here's an example of the DROP:
DROP TABLE data.samples CASCADE;And

And here's the error that I get back:

ERROR:  could not find tuple for statistics object 147574.

I'm out of my depth here. pg_statistic_ext does not have any row with an oid or stxrelid of 147574. I've hunted around some in pg_class and pg_statitic, but can't find any column with a reference to this value.

I tried upgrading (I was on 12.3), shutting down and restarting the server a few times, and running ANALYZE to see if anything would change. It hasn't.

Any idea how this problem can be created, avoided, or resolved? Many thanks.

For those of you familiar with the source, I've Googled for this error, and have not seen it discussed. It comes up on pg-hackers about 12 years ago, and it's located in the source at:


Here's a snippet where the error is thrown, when HeapTupleIsValid returns false.

case OCLASS_STATISTIC_EXT:

 {
HeapTuple   stxTup;
Form_pg_statistic_ext stxForm;
char       *nspname;

stxTup = SearchSysCache1(STATEXTOID,
 ObjectIdGetDatum(object->objectId));
if (!HeapTupleIsValid(stxTup))
{
if (!missing_ok)
elog(ERROR, "could not find tuple for statistics object %u",
 object->objectId);
break;
}

stxForm = (Form_pg_statistic_ext) GETSTRUCT(stxTup);

/* Qualify the name if not visible in search path */
if (StatisticsObjIsVisible(object->objectId))
nspname = NULL;
else
nspname = get_namespace_name(stxForm->stxnamespace);

appendStringInfo(&buffer, _("statistics object %s"),
 quote_qualified_identifier(nspname,
NameStr(stxForm->stxname)));

ReleaseSysCache(stxTup);
break;
 }


pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Range partitioning and overlap
Next
From: Tom Lane
Date:
Subject: Re: ERROR: could not find tuple for statistics object - is there a way to clean this up?