Track QueryBuilder reads for AutoRefresh - #2760
Draft
mpscholten wants to merge 2 commits into
Draft
Conversation
Core Size & Compile Allocations Benchmark
HTTP Latency (GET /, 5000 reqs, 10 concurrent)
Top 10 modules (this PR)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ModelContext.trackTableReadCallbackandwithTableReadTrackerAPIs through an internal metadata bridgeWhy
This is a QueryBuilder-focused foundation for improving the approach discussed in #2305.
AutoRefresh currently records only a
Set Textof table names. That is not enough to determine whether an INSERT, UPDATE, or DELETE can affect an action's rendered result. The previous smart-filtering prototype extracted row IDs and WHERE conditions into separate maps, which lost query semantics such as ordering, limits, offsets, counts, and existence checks.This change retains the compiled
SQLQueryand the canonical keys actually returned by row queries. It does not change notification filtering yet; current table-level refresh behavior remains in place while the data needed for safe relevance checks is introduced.Impact
The public
autoRefresh do ...,ModelContext.trackTableReadCallback, andwithTableReadTrackerAPIs remain unchanged. The originalAutoRefreshSessionconstructor also remains available for compatibility.Normal QueryBuilder fetches are tracked automatically. Outside AutoRefresh they continue to use the existing statements. Inside AutoRefresh, row queries are wrapped in a CTE that preserves their filtering, ordering, distinctness, limit, and offset while also returning primary-key values as JSON.
Manual
trackTableReadcalls, tables without usable primary keys, oversized result sets, and unknown structured reads remain conservative whole-table dependencies. Tracking retains at most 64 queries per table and 1024 returned keys per query.Trigger registration is serialized and only committed to server state after both trigger installation and PGListener subscription succeed. A failed rerender registration leaves the previous dependency snapshot intact, and development rerenders reinstall idempotent trigger SQL after
make dbrecreates the database.Follow-up work
SQLQueryand returned keysValidation
-Werror=unused-importsgit diff --check