pg_upgrade: Sequence-Check fails After pg_upgrade one check fails.

This SQL gets executed to list tables and their sequences. In comments to this question it is called "above sql".

SELECT S.relname, T.relname, C.attname
FROM pg_class AS S,
     pg_depend AS D,
     pg_class AS T,
     pg_attribute AS C,
     pg_tables AS PGT
WHERE S.relkind = 'S'
    AND S.oid = D.objid
    AND D.refobjid = T.oid
    AND D.refobjid = C.attrelid
    AND D.refobjsubid = C.attnum
    AND T.relname = PGT.tablename
ORDER BY S.relname;


Source: https://wiki.postgresql.org/wiki/Fixing_Sequences

This check gets used to see of there are sequences which next-value is too low.

This check gets executed daily since several years and it did not fail since several years. This was the first time that we used pg_upgrade and not dump+restore.

Now I am a bit nervous, that some internal references are broken.

The output for auth_user_groups_id_seq is broken:

psql -f above.sql| grep auth_user_groups_id_seq
 auth_user_groups_id_seq    | auth_user_groups        | id
 auth_user_groups_id_seq    | modwork_emailsender     | id


The first line is correct, the second seems broken.

The table modwork_emailsender does not have the sequence auth_user_groups_id_seq.

Has someome an idea why above sql outputs strange values after pg_upgrade?

Versions: We upgraded from 9.3 to 10.2.

Update

We found a different SQL to get all sequences:

select s.relname as seq, n.nspname as sch, t.relname as tab, a.attname as col
from pg_class s
  join pg_depend d on d.objid=s.oid and d.classid='pg_class'::regclass and d.refclassid='pg_class'::regclass
  join pg_class t on t.oid=d.refobjid
  join pg_namespace n on n.oid=t.relnamespace
  join pg_attribute a on a.attrelid=t.oid and a.attnum=d.refobjsubid
where s.relkind='S' and d.deptype='a'


Source: https://stackoverflow.com/questions/6941043/get-table-and-column-owning-a-sequence/6945493#6945493

The first query returns 140 rows (including strange results), the second 120 (without strange results).
we face the same problem. Apparently this issue is fixed in version 10.16. I tested 10.9,10.13,10.14,10.5 and all have the same issue.
But with 10.16 it's ok.
I don't see in release note any information on it.