fix(schema-compiler): include compilerId in template cache keys #10382
+108
−3
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.
Fixes #10383
Summary
Template caches (
compiledYamlCache,compiledJinjaCache,compiledScriptCache) used onlyMD5(file.content)as the cache key. WhenschemaVersionchanged and recompilation was triggered, templates were served from cache because file content hadn't changed.This broke the documented behavior of
schema_version, which states:The Fix
Include
compilerId(already available as an instance property) in the cache key hash:When
schemaVersionchanges → recompilation triggered → newcompilerId→ cache miss → templates re-rendered.Minimal Reproduction (before fix)
Expected:
compiled_atshows new timestamp on every request (sinceschema_versionchanges)Actual (before fix): Timestamp never changes—template served from cache despite "Recompiling schema" log
Current Workaround (and why it's problematic)
The only workaround is to include schema-affecting config in
app_id:This causes memory bloat and resource duplication because each
app_idcreates a newCompilerApiwith its own resources, including data model compile cache, SQL compile cache, query queues, in-memory result caching, etc. The multitenancy docs explicitly warn about this overhead:Side Effects
schema_versionchangesIn dev mode, when any file changes, a new
compilerIdis generated. This means all templates are re-rendered, not just the changed file. Previously, unchanged templates would hit the cache.Why this is acceptable:
devServerare unaffectedIf a more surgical fix is preferred,
compilerIdcould be conditionally included only for templates containing Jinja syntax (indicating dynamic content).Test Plan
compilerIdvaluesyarn test --testPathPattern="template-cache-invalidation"