Repository navigation
feat: protect embedded Sirius TAE admission - #29211
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review (exact head e523f21).\n\nREQUEST_CHANGES.\n\nP1 — The feature/design gate is not closed. This PR adds a substantial embedded Sirius TAE admission contract, durable lease-consumer semantics, restart/reconciliation behavior, aggregate metadata budgeting, a bounded provider interface, and a deterministic parity campaign. The linked issue's approved implementation plan explicitly requires the versioned design artifact docs/design/sirius-embedded.md covering API, ownership, capacity, lifecycle, validation, and rollout contracts, and identifies the protection/harness stage as dependent on that approved contract. This PR body provides no approved design revision or alignment link; the linked issue still lists the MO contract/design stage as incomplete.\n\nPlease add and obtain approval for the exact design revision, then tie this implementation to it (or explicitly narrow this PR to an already-approved contract). Current CI and the added unit/Python tests do not close the missing design/rollout proof; no further implementation polishing is requested until that gate is closed.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
Reviewed git diff origin/main...HEAD (3 commits, 9 files) from first principles. The PR has no existing reviews, no inline review comments, and one issue comment (a paused-Qodo bot notice), so nothing was withdrawn as disproven and no finding duplicates another reviewer.
Live Flight path — no regression proved
manifestBuilder.addprojection changed fromemptySize - len("[]") + …toemptySize + …. The old form under-projected by exactly 2 bytes (the[]brackets remain when objects are appended), andfinish()was always the authoritative check, so the exact projection only moves the reject point 2 bytes earlier with the sameNotEligible(EligibilitySnapshot)outcome.finish()is unchanged for Flight becauseobjectDescriptorBytesstays 0;TestSnapshotProviderStopsObjectVisitationAtManifestBoundstill holds (I re-derived both new boundary tests by hand againstadd/finish).PendingExecutions()now filters onConsumer == ReadConsumerFlight. The only production admission caller (pkg/sql/compile/sirius_read.go:99) leavesConsumerat its zero value, andloadCertificateSPKIHash(pkg/cnservice/sirius_runtime.go:191) returnssha256(RawSubjectPublicKeyInfo)of a parsed PEM certificate, which cannot collide with the reserved all-zero marker. So no durable lease can be reclassified as embedded and silently dropped fromReconcileReplay.- Consumer inference in
journal.loadandvalidateLeasederives from the same 32-byte hash, so it is self-consistent;journalRecordkeeps its exact JSON field set and authority digest, asserted byTestFlightJournalSchemaAndAuthorityRemainConsumerNeutral. - Embedded budget accounting is internally consistent: the provider enforces
manifest + Σ(16+len(name)) ≤ remaining, andchargeReturnedTAEMetadatacharges exactly that quantity against the same remaining budget.prechargeQueryTAEMetadata'scolumns > remaining/128guard prevents128*columnsoverflow, and themetadataBytes == metadataLimitcheck keeps the provider'smaximum ≥ 1.chargeTAEMetadatacannot underflow (charged ≤ remainingis invariant). ReconcileRestartholdsmutationfor the whole sweep,releaseLeasedoes not re-acquire it (no deadlock), and a failedUnregisterleaves the lease inreleaseMarkedso a retry resumes — covered byTestRestartReconciliationRetainsFailedEmbeddedCleanup.AdmittedTAEReadaliases the published lease clone. Publication transfers a private clone viacloneLeaseand no lifecycle path mutates it, so the borrow is memory-safe; the "finish native preparation before releasing ReadRef" pin contract is documented.ResolveHandleris the only surface that serveslease.Manifest, and it now rejects embedded leases, so no second read path bypasses the consumer check.- The all-zero-SPKI rejection for Flight cannot fire in production for the reason above; the test runtimes that still use
make([]byte, 32)(pkg/sql/compile/sirius_runtime_test.go:70,:86) only reachValidate(), neverAdmitReads.
gofmt -l is clean for all touched Go packages, and no helper in the new test file collides with existing package symbols. I could not execute the Go tests locally: this worktree has no thirdparties/install and no lib/libmo, so go vet/go test fail in the CGo layer (xxhash.h, roaring.h, usearch.h, jemalloc.h) and CGO_ENABLED=0 excludes required packages. The Go conclusions above are static proofs, not test runs. The 7 Python harness tests do pass locally.
No blocking defect found. Remaining items are non-blocking: the resolver's fail-closed certificate gate moved behind body read and durable journal I/O (unreachable in production but unnecessary), the new optools parity harness is unreachable from any Makefile target or workflow, and that harness retains every typed result set for the whole campaign.
P1 - New parity harness and its unittest are unreachable from CI and outside the PR's stated scope (optools/sirius_parity.py:734)
The PR adds 756 lines of harness plus 311 lines of unittest, but nothing in the repository invokes either. Searching for sirius_parity outside these two files returns no hits: there is no Makefile target, no .github/workflows step or path filter, and optools/run_ut.sh runs only the Go UT schedule (it invokes other optools/*.py helpers by explicit name — summarize_ut_slow_cases.py, active_ut_incremental.py, summarize_ut_setup.py — never this one). Compare the existing precedent optools/iceberg_external_runner.py, which is called from optools/iceberg_ci.bash and listed as a trigger path in .github/workflows/iceberg-connector.yml:11.
Consequence: the "seven deterministic Python campaign tests" cited in the PR description give no ongoing protection. The module hardcodes a contract for a runtime that does not live in this repository (REQUIRED_EXECUTION_STATS, tae_work_limit == max(2, 2 * streams) at optools/sirius_parity.py:441, maximum_slice = (64 << 20) // expected_limit), so it will drift silently and the only check that would catch the drift never runs. It also widens the PR considerably beyond its stated scope of embedded TAE admission protection.
Non-blocking because it changes no production behavior. Suggested fix: add a Makefile target plus a workflow path filter so cd optools && python3 -m unittest sirius_parity_test runs on changes to these two files, or split the harness into its own PR.
P2 - ResolveHandler now performs budget, body-read and durable journal I/O before verifying the client certificate (pkg/sql/plan/substrait/admission.go:1244)
Before this PR the verified-client-certificate check was the first gate after the Content-Type check, so an unauthenticated request never touched resolver state. It now sits at pkg/sql/plan/substrait/admission.go:1244, after leases.resolveBytes.acquire (pkg/sql/plan/substrait/admission.go:1211), readResolveRequestBody (pkg/sql/plan/substrait/admission.go:1218), UnmarshalResolveRequest, UnmarshalTaeRead, and leases.resolve (pkg/sql/plan/substrait/admission.go:1233) — and for a journaled manager resolve performs a durable journal.Active() round-trip under a 5s timeout (pkg/sql/plan/substrait/admission.go:442). The new consumer check at pkg/sql/plan/substrait/admission.go:1238 also runs before the certificate check, which creates a response-code distinction: a certificate-less caller gets 404 for a readRef that maps to an embedded lease but 401 for any other readRef. TestResolverRejectsEmbeddedConsumerBeforeCertificateHandling asserts both halves, so the ordering is now locked in by test.
This is not reachable in production today — NewResolverServer rejects any TLS config whose ClientAuth != tls.RequireAndVerifyClientCert or whose ClientCAs is nil (pkg/sql/plan/substrait/server.go:46) and serves via tls.NewListener, so the handshake fails before the handler runs. That is why this is not a blocker.
But ResolveHandler is exported, and the reorder was not needed to reach the stated goal. The audit record is only constructed at pkg/sql/plan/substrait/admission.go:1262-1276, and an embedded lease's all-zero AuthorizedClientSPKIHash can never equal a real principalHash, so the existing comparison already returns 404 without auditing. Moving if ok && lease.Consumer != ReadConsumerFlight { 404 } to immediately after leases.resolve while leaving the certificate check in its original position achieves "an embedded marker can never enter Flight's authentication/audit path" without weakening the fail-closed ordering or introducing the 404/401 distinction. Suggest restoring the original gate order and adjusting the test to assert 401-first.
P2 - Parity campaign retains every typed result set for all 1,860 runs instead of validating per contiguous cell group (optools/sirius_parity.py:295)
execute_campaign (optools/sirius_parity.py:295-302) accumulates one record per schedule entry, each holding the runner's full output including result.rows. validate_runs then pins every output a second time in by_cell (optools/sirius_parity.py:500-516) and reads them only for the native-oracle comparison (optools/sirius_parity.py:530-535). Nothing is released until the process exits; write_artifacts drops rows only while serializing (optools/sirius_parity.py:697). Peak RSS therefore scales with the total answer-set volume of the entire campaign rather than with one cell, which for the SF10 leg of a 1,860-run serial schedule is the harness's dominant memory cost — in a tool that is deliberately serial everywhere else.
The schedule already makes this avoidable. build_schedule emits all five routes for a fixed (scale_factor, phase, streams, suite, repetition, query) contiguously in every phase (optools/sirius_parity.py:164-167, optools/sirius_parity.py:170-179, optools/sirius_parity.py:181-186), and the mo-native oracle for a cell is always inside that same group, while summarize needs only wall_seconds per run (optools/sirius_parity.py:552). Validating each 5-run group as it completes — compare against the group's native output, keep the timings, drop the rows — would bound retention to one group without changing any evidence semantics or artifact bytes.
Non-blocking: it is a resource-scaling property of an unwired tool, not a correctness defect, and TPC-H answer sets are small enough that a single SF1 leg may still fit.
aptend
left a comment
There was a problem hiding this comment.
P1 — The mandatory design-first gate is still open at exact head e523f21. This PR changes cross-owner storage admission and durable/restart contracts (pkg/sql/plan/substrait/admission.go, consumer.go, journal.go, and the disttae provider) and adds the parity/cutover evidence contract, so the feature-design gate applies independently of CI. The base document docs/design/sirius-embedded.md explicitly requires every implementation PR to link the reviewed revision, but this PR body only references #28966 and does not identify which exact design revision/approval governs these semantics or map this split protection/harness stage to that revision. This is material because the repository base contains design v1 while a later v2 revision is being cited by adjacent Sirius PRs; without a pinned revision, reviewers cannot determine which restart ownership, aggregate metadata budget, direct-TAE protection, and validation/cutover rules are authoritative or whether this delivery split is an approved deviation. Please link the exact approved design commit and record the section-by-section alignment (or update/review the design first). I reviewed the full review/comment history and confirmed there are no inline threads or an author response closing this gate; implementation approval remains blocked until the traceable design revision is present.
|
@XuPeng-SH @aptend Resolved the four new harness blockers at head
After merging current main, Python compile/tab checks, all nine campaign tests, and five repeated real descendant-cleanup runs pass. Re-review is requested only from reviewers with outstanding |
XuPeng-SH
left a comment
There was a problem hiding this comment.
GPT-6 high force review at exact head ff75946 (base 27ffab6): REQUEST_CHANGES.
[P2] Integer results still allow lossy float encoding in the parity validator. In optools/sirius_parity.py:409-435, decimal/floating checks were tightened but integer schema values still accept float. BIGINT values 9007199254740992 and 9007199254740993 both become 9007199254740992.0, yet the current validator accepts them; the full 1,860-record campaign can pass. Require lossless integer encoding, reject float/boolean representations for integer types, and add a 2^53 boundary negative test.
[P2] Descendants created in a new session can escape timeout cleanup and make timeout handling unbounded. optools/sirius_parity.py:338-346 kills only the runner process group and then calls communicate() without a timeout; killpg cannot reach a child that started a new session. This was reproduced both with a detached child surviving and with inherited pipes causing communicate() to wait until the child was killed. Define ownership/termination for all descendants and make cleanup waiting bounded.
The prior decimal-tolerance, 64/32/8 MiB capacity, and nested-schema allowlist findings are fixed. The Go ownership/Flight/reconciliation review found no new confirmed defect. Current shared-build CI is successful, but UT/SCA/BVT are still running and real GPU/TPC-H cutover was not claimed.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review at exact head ff759466d495dcde6535cf417b9337e5945d9189 (merge-base/base 27ffab65a0f1c98752bb2fa5e852810cc6e12900): APPROVE.
I re-read the complete review/comment/thread history, checked the incremental fix from e523f2189903d7b4471b78be04800ce1d0c6aa13, and re-audited the full diff against the pinned v2 design (24161f69ba1bfefbd159d120cecc1758d00f98ed). All four prior blockers are closed:
- tolerance is now schema-directed and applies only to explicit floating SQL types; decimal/integer cells remain exact and decimal encodings are checked;
- the evidence validator enforces the 8 MiB TAE slice, 32 MiB cached metadata, 64 MiB aggregate TAE staging, and 64 MiB result-window limits, including one-over-bound tests;
- each runner starts in a POSIX session/process group and timeout/cancellation/completed-parent paths kill and reap the group; the committed descendant timeout test and an additional real successful-parent descendant counterexample both passed;
- schema/cell shapes are exact allowlists and persisted artifacts are reconstructed, so nested runner-controlled fields and row contents are not emitted.
Lifecycle audit: process creation has one reap path on success, timeout, and cancellation (Q1); communicate is bounded by the configured timeout and group kill releases inherited pipes for the owned process group (Q2); the newly asserted TAE/result accumulations have explicit hard limits (Q3). Flight/embedded lease ownership, retryable restart reconciliation, resolver isolation, and bounded manifest construction remain coherent in the unchanged Go delta.
Local exact-head evidence: 9/9 Python campaign tests passed; both touched Go packages passed; focused lifecycle/admission/provider tests passed under -race -count=3; the changed compile recovery test passed; git diff --check passed. Exact-head shared build, coverage, and SCA checks are green; remaining broad UT/BVT jobs were still running at submission time.
|
@XuPeng-SH @aptend Resolved the two latest blockers at head
After merging current main, Python compile/tab checks and all twelve campaign tests pass. The real timeout and successful-parent detached-child cases also passed five repeated paired runs. No GPU/TPC-H result is claimed by this PR. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
GPT-6 high force review at exact head bcb178e (base 1634996): APPROVE.
The prior two blockers are closed: integer schema values now require lossless integer encoding with signed/unsigned range checks, rejecting float/bool/string representations including 2^53 boundary cases; descendant cleanup now uses subreaper/pidfd handling with bounded termination, reaping, and executor quarantine on persistent failure.
The full review found the design/rollout boundary, Flight/embedded isolation, journal compatibility, restart/reconciliation, capacity accounting, borrowed-view lifetime, parity schedule, schema-directed tolerances, and artifact checks sound. Current-head CI passed, and the local Python suite plus boundary checks passed. Linux/GPU/TPC-H/cutover deployment acceptance remains a later gate and is not claimed to close #28966.
What type of PR is this?
Which issue(s) this PR fixes:
Refs #28966. This protection/harness PR does not close the migration issue.
What this PR does / why we need it:
Adds the storage-agnostic protection contract and evidence harness needed by embedded direct-TAE execution, without yet enabling that execution mode in CN configuration.
Protected read ownership
Deterministic parity campaign
Adds a command-injected, serial five-route campaign for MO native, Flight+TAE, Flight+MO, embedded+TAE, and embedded+MO:
The harness defines and validates evidence; this PR does not run or claim TPC-H results.
Approved design alignment
Exact reviewed design revision: Embedded Sirius migration design v2 at
24161f69ba1bfefbd159d120cecc1758d00f98ed. The document records approval of the ten-PR delivery plan and requires every implementation PR to identify and map itself to that revision. This PR is the protected direct-TAE admission and evidence-harness portion of delivery-map PR 8; it does not enable embedded execution or alter the rollout selector.Contract mapping:
Validation on the exact branch: