yugabyte / yugabyte-db

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.
https://www.yugabyte.com
Other
8.96k stars 1.07k forks source link

[YSQL][Upgrade] Inserts to pg_depend should update YB pinned object cache #12307

Open frozenspider opened 2 years ago

frozenspider commented 2 years ago

Jira Link: DB-2456 In #3503 we introduced a dedicated cache to speedup lookups for pinned objects. It assumed that pinned object set is immutable.

However, YSQL upgrade changed that invariant, now we do direct pg_depend inserts as part of various migrations (e.g. new system functions definition). However, YSQL upgrade didn't update that cache properly, leading to a system catalog content mismatch when a new system function was defined in the same session as creating a view using that (pinned) function, given that cache was initialized already. We didn't define such system views before, so we didn't encounter the described behaviour in practice.

frozenspider commented 1 year ago

This is partially fixed in da68239b350550c76658d9ebc08a69acd4a805ad: after this commit, local cache will be updated. Other sessions won't know a new object is pinned though. This is a minor issue because at worst it could cause unnecessary dependencies to be recorded.