pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ERROR: catalog is missing 3 attribute(s) for relid 150243
5+ messages / 3 participants
[nested] [flat]

* ERROR: catalog is missing 3 attribute(s) for relid 150243
@ 2022-08-18 10:33 milist ujang <ujang.milist@gmail.com>
  2022-08-18 22:55 ` Re: ERROR: catalog is missing 3 attribute(s) for relid 150243 milist ujang <ujang.milist@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: milist ujang @ 2022-08-18 10:33 UTC (permalink / raw)
  To: pgsql-general

Hi lists,

I have an index anomaly on a table; getting the error as subject.

dumping queries behind \dS+ of a table, got 4 queries (see detail below)
1st query --> OK
2nd query --> OK
3rd query ERROR same as subject (ERROR:  catalog is missing 3 attribute(s)
for relid 150243)

comment on 3rd query line --pg_catalog.pg_get_indexdef looks good.
so my assumption we have an issue when call pg_catalog.pg_get_indexdef
function.

select pg_catalog.pg_get_indexdef ( 150243, 0, TRUE );
return blank.

any ideas?


1st query:
========
SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules,
c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, false AS
relhasoids, c.relispartition, pg_catalog.array_to_string(c.reloptions ||
array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')
        , c.reltablespace, CASE WHEN c.reloftype = 0 THEN '' ELSE
c.reloftype::pg_catalog.regtype::pg_catalog.text END, c.relpersistence,
c.relreplident, am.amname
        FROM pg_catalog.pg_class c
         LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)
        LEFT JOIN pg_catalog.pg_am am ON (c.relam = am.oid)
        WHERE c.oid = '150243';

2nd query:
========
SELECT a.attname,
          pg_catalog.format_type(a.atttypid, a.atttypmod),
          (SELECT pg_catalog.pg_get_expr(d.adbin, d.adrelid, true)
           FROM pg_catalog.pg_attrdef d
           WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND
a.atthasdef),
          a.attnotnull,
          (SELECT c.collname FROM pg_catalog.pg_collation c,
pg_catalog.pg_type t
           WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND
a.attcollation <> t.typcollation) AS attcollation,
          a.attidentity,
          a.attgenerated,
          a.attstorage,
          CASE WHEN a.attstattarget=-1 THEN NULL ELSE a.attstattarget END
AS attstattarget,
          pg_catalog.col_description(a.attrelid, a.attnum)
        FROM pg_catalog.pg_attribute a
        WHERE a.attrelid = '150243' AND a.attnum > 0 AND NOT a.attisdropped
        ORDER BY a.attnum;

3rd query:
========
SELECT
c2.relname,
i.indisprimary,
i.indisunique,
i.indisclustered,
i.indisvalid,
pg_catalog.pg_get_indexdef ( i.indexrelid, 0, TRUE ),
pg_catalog.pg_get_constraintdef ( con.oid, TRUE ),
contype,
condeferrable,
condeferred,
i.indisreplident,
c2.reltablespace
FROM
pg_catalog.pg_class C,
pg_catalog.pg_class c2,
pg_catalog.pg_index i
LEFT JOIN pg_catalog.pg_constraint con ON ( conrelid = i.indrelid AND
conindid = i.indexrelid AND contype IN ( 'p', 'u', 'x' ) )
WHERE
C.oid = '150243'
AND C.oid = i.indrelid
AND i.indexrelid = c2.oid
ORDER BY
i.indisprimary DESC,
i.indisunique DESC,
c2.relname;

4th query:
========
SELECT
c2.relname,
i.indisprimary,
i.indisunique,
i.indisclustered,
i.indisvalid,
pg_catalog.pg_get_indexdef ( i.indexrelid, 0, TRUE ),
pg_catalog.pg_get_constraintdef ( con.oid, TRUE ),
contype,
condeferrable,
condeferred,
i.indisreplident,
c2.reltablespace
FROM
pg_catalog.pg_class C,
pg_catalog.pg_class c2,
pg_catalog.pg_index i
LEFT JOIN pg_catalog.pg_constraint con ON ( conrelid = i.indrelid AND
conindid = i.indexrelid AND contype IN ( 'p', 'u', 'x' ) )
WHERE
C.oid = '150243'
AND C.oid = i.indrelid
AND i.indexrelid = c2.oid
ORDER BY
i.indisprimary DESC,
i.indisunique DESC,
c2.relname;


-- 
regards

ujang jaenudin | DBA Consultant (Freelancer)
http://ora62.wordpress.com
http://id.linkedin.com/pub/ujang-jaenudin/12/64/bab

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: ERROR: catalog is missing 3 attribute(s) for relid 150243
  2022-08-18 10:33 ERROR: catalog is missing 3 attribute(s) for relid 150243 milist ujang <ujang.milist@gmail.com>
@ 2022-08-18 22:55 ` milist ujang <ujang.milist@gmail.com>
  2022-08-19 04:02   ` Re: ERROR: catalog is missing 3 attribute(s) for relid 150243 Julien Rouhaud <rjuju123@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: milist ujang @ 2022-08-18 22:55 UTC (permalink / raw)
  To: pgsql-general

my version is 12.9 on x86_64.

reading source code, got the message form RelationBuildTupleDesc() function:

/*
      * end the scan and close the attribute relation
      */
     systable_endscan(pg_attribute_scan);
     table_close(pg_attribute_desc, AccessShareLock);

     if (need != 0)
         elog(ERROR, "pg_attribute catalog is missing %d attribute(s) for
relation OID %u",
              need, RelationGetRelid(relation));

I'm not sure whether this function will compare the mentioned relation
attribute in pg_attribute and physical table (header) file?



On Thu, Aug 18, 2022 at 5:33 PM milist ujang <ujang.milist@gmail.com> wrote:

> Hi lists,
>
> I have an index anomaly on a table; getting the error as subject.
>
> dumping queries behind \dS+ of a table, got 4 queries (see detail below)
> 1st query --> OK
> 2nd query --> OK
> 3rd query ERROR same as subject (ERROR:  catalog is missing 3 attribute(s)
> for relid 150243)
>
> comment on 3rd query line --pg_catalog.pg_get_indexdef looks good.
> so my assumption we have an issue when call pg_catalog.pg_get_indexdef
> function.
>
> select pg_catalog.pg_get_indexdef ( 150243, 0, TRUE );
> return blank.
>
> any ideas?
>
>
> 1st query:
> ========
> SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules,
> c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, false AS
> relhasoids, c.relispartition, pg_catalog.array_to_string(c.reloptions ||
> array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')
>         , c.reltablespace, CASE WHEN c.reloftype = 0 THEN '' ELSE
> c.reloftype::pg_catalog.regtype::pg_catalog.text END, c.relpersistence,
> c.relreplident, am.amname
>         FROM pg_catalog.pg_class c
>          LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)
>         LEFT JOIN pg_catalog.pg_am am ON (c.relam = am.oid)
>         WHERE c.oid = '150243';
>
> 2nd query:
> ========
> SELECT a.attname,
>           pg_catalog.format_type(a.atttypid, a.atttypmod),
>           (SELECT pg_catalog.pg_get_expr(d.adbin, d.adrelid, true)
>            FROM pg_catalog.pg_attrdef d
>            WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND
> a.atthasdef),
>           a.attnotnull,
>           (SELECT c.collname FROM pg_catalog.pg_collation c,
> pg_catalog.pg_type t
>            WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND
> a.attcollation <> t.typcollation) AS attcollation,
>           a.attidentity,
>           a.attgenerated,
>           a.attstorage,
>           CASE WHEN a.attstattarget=-1 THEN NULL ELSE a.attstattarget END
> AS attstattarget,
>           pg_catalog.col_description(a.attrelid, a.attnum)
>         FROM pg_catalog.pg_attribute a
>         WHERE a.attrelid = '150243' AND a.attnum > 0 AND NOT a.attisdropped
>         ORDER BY a.attnum;
>
> 3rd query:
> ========
> SELECT
> c2.relname,
> i.indisprimary,
> i.indisunique,
> i.indisclustered,
> i.indisvalid,
> pg_catalog.pg_get_indexdef ( i.indexrelid, 0, TRUE ),
> pg_catalog.pg_get_constraintdef ( con.oid, TRUE ),
> contype,
> condeferrable,
> condeferred,
> i.indisreplident,
> c2.reltablespace
> FROM
> pg_catalog.pg_class C,
> pg_catalog.pg_class c2,
> pg_catalog.pg_index i
> LEFT JOIN pg_catalog.pg_constraint con ON ( conrelid = i.indrelid AND
> conindid = i.indexrelid AND contype IN ( 'p', 'u', 'x' ) )
> WHERE
> C.oid = '150243'
> AND C.oid = i.indrelid
> AND i.indexrelid = c2.oid
> ORDER BY
> i.indisprimary DESC,
> i.indisunique DESC,
> c2.relname;
>
> 4th query:
> ========
> SELECT
> c2.relname,
> i.indisprimary,
> i.indisunique,
> i.indisclustered,
> i.indisvalid,
> pg_catalog.pg_get_indexdef ( i.indexrelid, 0, TRUE ),
> pg_catalog.pg_get_constraintdef ( con.oid, TRUE ),
> contype,
> condeferrable,
> condeferred,
> i.indisreplident,
> c2.reltablespace
> FROM
> pg_catalog.pg_class C,
> pg_catalog.pg_class c2,
> pg_catalog.pg_index i
> LEFT JOIN pg_catalog.pg_constraint con ON ( conrelid = i.indrelid AND
> conindid = i.indexrelid AND contype IN ( 'p', 'u', 'x' ) )
> WHERE
> C.oid = '150243'
> AND C.oid = i.indrelid
> AND i.indexrelid = c2.oid
> ORDER BY
> i.indisprimary DESC,
> i.indisunique DESC,
> c2.relname;
>
>
> --
> regards
>
> ujang jaenudin | DBA Consultant (Freelancer)
> http://ora62.wordpress.com
> http://id.linkedin.com/pub/ujang-jaenudin/12/64/bab
>


-- 
regards

ujang jaenudin | DBA Consultant (Freelancer)
http://ora62.wordpress.com
http://id.linkedin.com/pub/ujang-jaenudin/12/64/bab

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: ERROR: catalog is missing 3 attribute(s) for relid 150243
  2022-08-18 10:33 ERROR: catalog is missing 3 attribute(s) for relid 150243 milist ujang <ujang.milist@gmail.com>
  2022-08-18 22:55 ` Re: ERROR: catalog is missing 3 attribute(s) for relid 150243 milist ujang <ujang.milist@gmail.com>
@ 2022-08-19 04:02   ` Julien Rouhaud <rjuju123@gmail.com>
  2022-08-19 04:27     ` Re: ERROR: catalog is missing 3 attribute(s) for relid 150243 milist ujang <ujang.milist@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Julien Rouhaud @ 2022-08-19 04:02 UTC (permalink / raw)
  To: milist ujang <ujang.milist@gmail.com>; +Cc: pgsql-general

Hi,

Please don't top-post on this list (and please trim quoted messages too).

On Fri, Aug 19, 2022 at 05:55:03AM +0700, milist ujang wrote:
> On Thu, Aug 18, 2022 at 5:33 PM milist ujang <ujang.milist@gmail.com> wrote:
> >
> > 3rd query ERROR same as subject (ERROR:  catalog is missing 3 attribute(s)
> > for relid 150243)
>
> my version is 12.9 on x86_64.
>
> reading source code, got the message form RelationBuildTupleDesc() function:
>
> /*
>       * end the scan and close the attribute relation
>       */
>      systable_endscan(pg_attribute_scan);
>      table_close(pg_attribute_desc, AccessShareLock);
>
>      if (need != 0)
>          elog(ERROR, "pg_attribute catalog is missing %d attribute(s) for
> relation OID %u",
>               need, RelationGetRelid(relation));
>
> I'm not sure whether this function will compare the mentioned relation
> attribute in pg_attribute and physical table (header) file?

No, this function is comparing pg_class.relnatts to rows fetched querying
pg_attribute for the given relation.

What it means is that you likely have data corruption.  You could try to
reindex pg_attribute and see if that fixes that specific problems, but even if
it does you will have to investigate how data got corrupted, fix that root
problem, and then try to check for other corrupted data or restore from a sane
backup.





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: ERROR: catalog is missing 3 attribute(s) for relid 150243
  2022-08-18 10:33 ERROR: catalog is missing 3 attribute(s) for relid 150243 milist ujang <ujang.milist@gmail.com>
  2022-08-18 22:55 ` Re: ERROR: catalog is missing 3 attribute(s) for relid 150243 milist ujang <ujang.milist@gmail.com>
  2022-08-19 04:02   ` Re: ERROR: catalog is missing 3 attribute(s) for relid 150243 Julien Rouhaud <rjuju123@gmail.com>
@ 2022-08-19 04:27     ` milist ujang <ujang.milist@gmail.com>
  2022-08-19 04:42       ` Re: ERROR: catalog is missing 3 attribute(s) for relid 150243 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: milist ujang @ 2022-08-19 04:27 UTC (permalink / raw)
  To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: pgsql-general

On Fri, Aug 19, 2022 at 11:02 AM Julien Rouhaud <rjuju123@gmail.com> wrote:

> Hi,
>
> Please don't top-post on this list (and please trim quoted messages too).
>
>
>
> No, this function is comparing pg_class.relnatts to rows fetched querying
> pg_attribute for the given relation.
>
> any concern if I update pg_class.natts and or pg_attribute to let it match?



> What it means is that you likely have data corruption.  You could try to
> reindex pg_attribute and see if that fixes that specific problems, but
> even if
> it does you will have to investigate how data got corrupted, fix that root
> problem, and then try to check for other corrupted data or restore from a
> sane
> backup.
>

yes we have a problem with vm; suddenly restart without reason....

I've done recovery by creating empty files under pg_xact , cluster can
bring up
then a file under pg_multixact due to error on a table.

I've done reinding pg_class, pg_attribute, pg_constraint without luck.


-- 
regards

ujang jaenudin | DBA Consultant (Freelancer)
http://ora62.wordpress.com
http://id.linkedin.com/pub/ujang-jaenudin/12/64/bab

[image: width=]
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&...;
Virus-free.www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&...;
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: ERROR: catalog is missing 3 attribute(s) for relid 150243
  2022-08-18 10:33 ERROR: catalog is missing 3 attribute(s) for relid 150243 milist ujang <ujang.milist@gmail.com>
  2022-08-18 22:55 ` Re: ERROR: catalog is missing 3 attribute(s) for relid 150243 milist ujang <ujang.milist@gmail.com>
  2022-08-19 04:02   ` Re: ERROR: catalog is missing 3 attribute(s) for relid 150243 Julien Rouhaud <rjuju123@gmail.com>
  2022-08-19 04:27     ` Re: ERROR: catalog is missing 3 attribute(s) for relid 150243 milist ujang <ujang.milist@gmail.com>
@ 2022-08-19 04:42       ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2022-08-19 04:42 UTC (permalink / raw)
  To: milist ujang <ujang.milist@gmail.com>; +Cc: Julien Rouhaud <rjuju123@gmail.com>; pgsql-general

milist ujang <ujang.milist@gmail.com> writes:
> On Fri, Aug 19, 2022 at 11:02 AM Julien Rouhaud <rjuju123@gmail.com> wrote:
>> What it means is that you likely have data corruption.  You could try
>> to reindex pg_attribute and see if that fixes that specific problems,
>> but even if it does you will have to investigate how data got
>> corrupted, fix that root problem, and then try to check for other
>> corrupted data or restore from a sane backup.

> yes we have a problem with vm; suddenly restart without reason....

Ugh.

> I've done reinding pg_class, pg_attribute, pg_constraint without luck.

That was your only chance of an easy way out :-(.  At this point you
clearly have data corruption in one or more system catalogs, and there's
no particular reason to think that the damage is only in the catalogs
and not also in your user-data tables.

If the data is worth a substantial amount of money to you, I'd recommend
hiring a professional Postgres support company with experience in data
recovery.  You can find some links here:
https://www.postgresql.org/support/professional_support/

Otherwise, restore from your latest backup, and resolve to get better
at keeping backups, and ask some hard questions about the reliability
of the storage stack you're sitting on.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2022-08-19 04:42 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18 10:33 ERROR: catalog is missing 3 attribute(s) for relid 150243 milist ujang <ujang.milist@gmail.com>
2022-08-18 22:55 ` milist ujang <ujang.milist@gmail.com>
2022-08-19 04:02   ` Julien Rouhaud <rjuju123@gmail.com>
2022-08-19 04:27     ` milist ujang <ujang.milist@gmail.com>
2022-08-19 04:42       ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox