Repository navigation
perf(sql): fewer PostgreSQL round trips per delegated /invoke (TC-3739 5+1) - #695
Merged
Merged
Conversation
…walk per delegated /invoke - invoke_impl's pre-check fence and resolve are the request's only ones; handle_sql_invoke takes its db_name (the handler's second check held no lock and closed no race). - resolve_sql_profile reads the statements profile from the ability rows the authorization graph already loaded (TransactResult.proof_abilities); it walks the chain only when authorization returned none (writes). - Kept on purpose: the chain closure for lock ids (TC-324 ordering), proof_roots, the policy_v3 load_signed_delegation. - Warm 1-hop SELECT 1: 16 -> 9 sequential statements; 2-hop 18 -> 9; cold 18/20 -> 11. test-ruling: TC-3739 tinycloud-node-server/src/routes/mod.rs new test only (2026-11-22) Details: TC-3739
…ound-trips # Conflicts: # CHANGELOG.md
… part 5) - Re-pin canonical fields.json to tinycloud-dev 29ee97f9 (#364): pool_wait_ms, query_time_ms (number 0..86400000), query_count (integer 0..2^53-1). - sanitize.vrl copies the three fields only on node_request with status < 400, type- and bound-guarded; anything else is dropped and the event still ships (Naomi ruling A, 05:22Z). - budget: node (status 399 + DB fields) sizes the request allocation (774 B pair, 14.36 rpm); nodeCapped (no DB fields) sizes the capped classes, reserve unchanged at 585.4 MB. - Vector cases: valid, maxima, mistyped, out-of-bounds, and statuses 399..599 (4xx/5xx carry none). Compose embed regeneration follows after #682 and T3.
…TC-3739) - Byte-identical to ops/logging/fields.json at 29ee97f9 (sha256 100f5294…); brings the 10 canonical commits since 4fc32a2f plus #364.
…ound-trips # Conflicts: # CHANGELOG.md
…ing fields
- VECTOR_CONFIG_JSON regenerated from scripts/tc959-logship.mjs buildConfig({runtimeProfile:true}); tc959-check parity passes. The TC-959 N0 fixture stays byte-identical to the compose.
- N0 pin follows once T3 (#696) is on main.
…ound-trips # Conflicts: # CHANGELOG.md
N0 template c6d05e1e -> cc219eb5 (raw 02d90755): main's compose (caveats + T3) plus the regenerated Vector embed. docker.yml pin + comment, docs/releasing.md (both places), CHANGELOG entry. Details: TC-3739
samgbafa
marked this pull request as ready for review
November 22, 2026 07:36
…ound-trips # Conflicts: # CHANGELOG.md
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.
TC-3739 "5+1". Part 1 removes the duplicate PostgreSQL round trips on a delegated SQL
/invoke. Part 5 ships thenode_requestfields the node already logs,pool_wait_ms,query_time_msandquery_count, through the log shipper.Round trips, sequential statements per request, measured on local PG 14 through a wire-counting proxy with 43 requests per case. Every request in a case gave the same count.
Removed duplicates:
invoke_implalready checks the fence beforeinvoked_abilitiesis persisted. The handler's check held no lock, so it closed no race.handle_sql_invokenow takesdb_namefrominvoke_impl.SELECTs per level.resolve_sql_profilenow reads profiles from the ability rows that authorization'sproof_rootsgraph already loaded, under the chain guards (TransactResult.proof_abilities). That set is the same closure the walk visited: the roots plus every ancestor overparent_delegation.derive_chain_sql_profiles_with_conn) remains for paths that return no graph, such as SQL mixed with a KV write.Kept on purpose:
proof_rootsitself.load_signed_delegation. Nothing earlier in the request has loaded that row.Tests:
routes::tests::tc3739_ancestor_profile_from_authorization_graph_governs_raw_invocation.postgres_round_trip_budgetpasses 9/9; it uses ceilings, so fewer round trips pass.--libtc3739, w1_, sql and policy_v3, 227 tests at--test-threads=2.Part 5, the log shipper:
ops/logging/fields.json(samgbafa/tinycloud-dev#364) addspool_wait_msandquery_time_msas numbers (0 to 86,400,000) andquery_countas an integer. It is vendored intolog-shipper/fields.json, andcanonical.jsonis re-pinned to revision29ee97f9…(sha100f5294…).sanitize.vrlcopies the three fields only onnode_requestlines with status < 400 (Naomi's ruling A, 05:22Z), and only as plain numbers within the bounds. Anything else is dropped and the event still ships. The capped 4xx and 5xx classes carry none of them, andcases.mjsadds Vector cases for status 399 and for 599.budget.mjs:nodeis the status-399 line with the DB fields, 551 B;nodeCappedis the status-599 line without them, and it sizes the capped node classes;VECTOR_CONFIG_JSONand thetc959-n0-compose.yamlfixture are regenerated withscripts/tc959-logship.mjson main 291c6ad (caveats + T3).c6d05e1e…→cc219eb5a05deda365a9683b6c6dc407eb872cb77d9f3954a819d1805ddd2249(raw02d907552b74066b0d49f1088cc0b7ba9ca3e842eb9c1444b3cd778474498eb9). This updates the docker.yml pin and comment,docs/releasing.mdin both places, and the CHANGELOG.tc959-check.native-check(5 request events and 1 db_failure, wire-safe, 6 positive controls) andcap-checkwith the local Vector binary.scripts/ci/test-deploy-recovery.py.cargo check -p tinycloud-node --testsafter merging main.log-shipper/budget.test.mjs:nodeCappedinstead ofnode, because a capped (status ≥ 400) line no longer has the same shape as the status < 400 representative.nodeCappedcarries none of the three DB fields. Two places prove this:Object.hasOwn(nodeCapped, key) === falseforpool_wait_ms,query_time_msandquery_count(log-shipper/budget.test.mjs:37).log-shipper/cases.mjsrun the real sanitizer for statuses 399, 400, 404, 499, 500, 503 and 599. The fields ship at 399, and for every status ≥ 400 the case requires!exists(.pool_wait_ms) && !exists(.query_time_ms) && !exists(.query_count). CI runs them withvector teston the output ofscripts/tc959-logship.mjs render-tests(logship.yml:52-55). Locally all 7 status cases pass in both profiles (errors_slow, all_requests), and so does every other case.test-ruling: TC-3739
Details: TC-3739