Add ability to ignore tables in the schema cache #43075
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In cases where an application uses pt-osc or lhm they may have
temporary tables being used for migrations. Those tables shouldn't be
included by the schema cache because it makes the cache bigger and those
tables shouldn't ever be queried by the application. This feature allows
applications to configure a list of or regex of tables to ignore. The
behavior for ignored tables for each method in the schema cache
(
columns
,columns_hash
,primary_keys
, andindexes
) matches thebehavior of a non-existent table.
To use in an application configure
config.active_record.schema_cache_ignored_tables
to an array of tables or regex's. Those tables will not be included in
the schema cache dump.
cc/ @rafaelfranca @casperisfine @tenderlove - I think this will work for your schema cache. Note that in our app I found we actually weren't ensuring that
primary_keys
,columns
,columns_hash
andindexes
were behaving the same as a non-existent table which meant that if these tables were ever queried then they'd populate the cache in-memory. Since these tables are not supposed to be queried this technically shouldn't change behavior when your app opts into this.