Skip to content

2.27.0.0-b493

@myang2021 myang2021 tagged this 26 Aug 22:51
Summary:
When a database is dropped, we delete its row from pg_yb_catalog_version table. However currently we
do not delete the invalidation messages associated with the dropped database from the table
pg_yb_invalidation_messages. This causes garbage invalidation messages left over in the table
pg_yb_invalidation_messages table. Overtime it can cause reading the table to become slower and
slower after creating and dropped many databases.

Note that if there is a global-impact DDL that increments the catalog version, then as part of the
execution of the function `yb_increment_all_db_catalog_versions_with_inval_messages` we do
have a chance to delete old messages irrespective of db_oid.

```
      DELETE FROM pg_yb_invalidation_messages WHERE
        message_time < extract(epoch FROM now())::BIGINT - expiration_sec;
```

I made a change to delete the invalidation messages associated with db_oid for a dropped database.
A new unit test is added that would fail before the fix.
Jira: DB-18033

Test Plan: ./yb_build.sh release --cxx-test pg_catalog_version-test --gtest_filter PgCatalogVersionTest.InvalMessageDropDatabase

Reviewers: kfranz, sanketh, #db-approvers

Reviewed By: kfranz, #db-approvers

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D46258
Assets 2
Loading