futurewei-cloud / chogori-opengauss

Other
2 stars 7 forks source link

generate possibly-non-unique OID for some system tables/relations #113

Open dlifw opened 1 year ago

dlifw commented 1 year ago

Symptom

During the initdb process, it may generate possibly-non-unique OID for system table entries. (Table and relation are used to mean the same thing in the following discussion.) The first location where this happens is the “Setup auth …” step, where it needs to generate a new entry in the pg_auth_history system table when it processes the “ALTER USER omm WITH PASSWORD E'Test3456';” statement.

The message we get is like: [BACKEND] WARNING: generating possibly-non-unique Oid for "pg_auth_history".

Findings

Cause of the issue

In the RelationGetIndexList() function in relcache.cpp, there is a complex logic to determine whether an index is the oid index. It only updates the oidIndex after it identifies the oid index. In vanilla opengauss, the if condition will evaluate to true when an index is the oid index. However, in k2 opengauss, the if condition will evaluate to false even when an index is the oid index. Thus, the oidIndex of a relation is always the InvalidOid (0) in k2 opengauss. This will trigger the GetNewOid() method to generate the warning for many system tables.

Potential directions to resolve the issue