Repository navigation
[4.2-dev] fix(frontend): enforce max_execution_time - #33388
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? |
|
This pull request is merged. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 2b283651f9af7b1db1c2a80ab1e54beb96b2b155
Assessment: request_changes
The per-statement timer appropriately reuses the existing cancellation and transaction owners, but it misses transaction admission and incorrectly times out nested locking reads. The new integration test also fails non-Linux test-file selection, and the required SQL BVT is absent.
Model: gpt-6.1-terra / max
Session: 01a21c27-ec8a-7140-b4c2-bd78dda344f9 · slot 1 · generation 26
-
P2
pkg/frontend/mysql_cmd_executor.go:4224: An eligible SELECT starts while the CN's active-user-transaction limit is full.
Impact: The statement remains queued after max_execution_time expires, potentially until a slot opens or the separate transaction-creation timeout expires. Pass a context bounded by the statement deadline through transaction admission while retaining the longer-lived transaction context for the transaction itself.
Evidence: TxnHandler.createTxnOpUnsafe passes a context derived from th.txnCtx to TxnClient.New. In the exact-head TCP probe, a SELECT with a 250 ms limit remained in the admission queue after 810 ms and returned error 3024 only after another transaction released a slot; see attempt-2/timeout-boundary-probe.log and checks/1795769236270255060-5.json. -
P2
pkg/frontend/max_execution_time.go:106: A SELECT contains FOR UPDATE inside a derived table, CTE, or other nested SELECT rather than on the outer SELECT.
Impact: The classifier treats the statement as read-only and interrupts its locking read, although equivalent top-level locking reads are exempt. Inspect nested SELECTs for locking intent, or otherwise use an authoritative classification that preserves the locking-read exclusion.
Evidence: The classifier only traverses SELECT, parenthesized SELECT, and union nodes; the planner binds nested locking SELECTs and emits lock operators. The TCP probe held the same row lock for both forms: the top-level FOR UPDATE waited beyond 250 ms and succeeded after release, while the nested form returned error 3024 after 251 ms. -
P2
pkg/tests/issues/issue_33378_test.go:116: Building the issues test package on a supported non-Linux platform such as macOS.
Impact: The new test references issue32362QueryVisible, but its only definition is in a Linux-only test file, leaving the symbol undefined. Move the platform-independent helper to a shared test file or align the new test's build constraint.
Evidence: The GOOS=darwin GOARCH=arm64 selection includes issue_33378_test.go and ignores issue_32362_test.go; see attempt-2/darwin-selection.json and checks/1795769234679830894-5.json. -
P2
pkg/tests/issues/issue_33378_test.go:30: The PR changes a SQL-visible timeout and error contract.
Impact: The required mo-tester BVT suite has no maintained regression for this behavior. Add a focused SQL BVT covering the timeout and an applicable zero or reuse control, and validate it in comparison mode.
Evidence: The pinned testing-contract.md requires public-path BVT for SQL-visible errors and defines BVT under test/distributed/cases. The existing func_sleep case does not set max_execution_time, and this PR adds only the related embedded Go client test.
Validation:
-
Preflight passed; receipt checks/1795768999563354725-3.json.
-
The exact-head TestIssue33378MaxExecutionTime passed against the authenticated embedded cluster, including ordinary and prepared SELECTs, session reuse, and KILL QUERY; attempt-2/issue-33378-test.log and checks/1795769077433207847-5.json.
-
The exact-head frontend TestMaxExecutionTime tests passed in attempt 1; attempt-1/frontend-timer-final.log and checks/1795768512228718747-3.json.
-
The exact-head diagnostic TCP probe completed and reproduced the admission and nested-lock defects; attempt-2/timeout-boundary-probe.log and checks/1795769236270255060-5.json.
-
Darwin Go file selection confirmed that the new test is selected while its helper's Linux-only file is excluded; attempt-2/darwin-selection.json and checks/1795769234679830894-5.json.
Limitations:
-
A full Darwin build, race suite, and mo-tester BVT run were not performed. The Darwin finding is based on Go's file selection and the helper's sole definition.
-
The preflight receipt was created from the diagnostic directory and has no source fingerprint; the subsequent test and selection receipts identify the assigned head.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 18b9502dc6e924c781120c24770fa709e4e00220
Assessment: request_changes
The timer reuses the existing cancellation and transaction-admission mechanisms, and the four previously reported triggers are addressed. Three classification defects remain: a valid read-only expression can bypass the timer, while locking views and SELECTs with external writes can be timed despite the intended read-only scope.
Model: gpt-6.1-terra / max
Session: 01a21c25-08ff-7481-8807-238741372da4 · slot 2 · generation 9
-
P2
pkg/sql/parsers/dialect/mysql/mysql_lexer.go:265: A read-only SELECT uses a valid expression such as SUBSTRING('abc' FROM 1 FOR share), where share is a column name.
Impact: The lexer interprets FOR SHARE as a locking clause and disables max_execution_time for the whole statement, allowing an eligible query to run beyond its configured limit.
Evidence: The exact-head TCP probe returned the expression and SLEEP(1) successfully after about one second with a 250 ms limit; the equivalent expression using a literal length timed out. See attempt-1/public-regression.log and checks/1795772151211020762-5.json. Classify locking clauses from their parsed meaning rather than adjacent tokens. -
P2
pkg/frontend/max_execution_time.go:101: A SELECT reads a view defined with FOR UPDATE while another transaction holds the underlying row lock.
Impact: The outer AST has no locking marker, so the timer interrupts the locking read even though equivalent inline and top-level locking reads are exempt. Existing locking workflows can receive error 3024 while waiting for the lock.
Evidence: The exact-head TCP probe created a locking view, observed its SELECT waiting in mo_catalog.mo_locks, and received error 3024 while the holder still owned the lock; see attempt-1/public-regression.log and checks/1795772151211020762-5.json. The planner expands stored view definitions later in pkg/sql/plan/query_builder.go. Account for locking intent in expanded views while preserving the deadline for eligible reads and admission. -
P2
pkg/frontend/max_execution_time.go:91: An authorized client executes a SELECT containing the side-effecting SAVE_FILE function with a nonzero max_execution_time.
Impact: The statement is treated as read-only and can return a timeout after an external file has already been written. A client may consequently retry a failed-looking operation despite its durable external effect.
Evidence: In the current-head TCP probe, SELECT SLEEP(SAVE_FILE(..., 'ok')) returned error 3024 after 251 ms while the output file already contained 'ok'; see attempt-2/save-file-probe.log and checks/1795773079534139963-2.json. SAVE_FILE closes its writer in pkg/sql/plan/function/func_unary.go. Exclude side-effecting expressions from the read-only timer or otherwise preserve their required effect semantics.
Validation:
-
Preflight passed on the assigned checkout: attempt-2/checks/1795772825636939935-2.json.
-
The retained exact-head public TCP tests passed for ordinary and prepared SELECTs, cancellation, session reuse, transaction admission, and inline nested locking reads. Their diagnostic boundary probe reproduced the first two findings: attempt-1/public-regression.log and checks/1795772151211020762-5.json.
-
The current-head public TCP side-effect probe completed and reproduced the third finding: attempt-2/save-file-probe.log and checks/1795773079534139963-2.json.
-
Darwin Go file selection included the regression test and shared helper: attempt-1/darwin-selection.json and checks/1795771980838282094-5.json.
-
The saved discussion assessment covers all five discussion keys exactly once: attempt-2/discussion-coverage.log and checks/1795773093982969604-2.json.
Limitations:
-
The author reports two passing mo-tester BVT comparison runs; their logs were not supplied and the runs were not repeated locally.
-
A native Darwin build and a full race suite were not run.
18b9502 to
d10314f
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: e18b3b1d4b5d4d58c1656402010908a0d3db0a6b
Assessment: request_changes
The timeout reuses the existing request and transaction contexts, and the bounded workers address cancellation of blocking I/O and native initialization. One local-read isolation defect remains: a single stalled source can retain every local-read permit after its queries return, blocking unrelated reads, including those with the statement limit disabled. The earlier subscription-context finding is resolved in the current code.
Model: gpt-6.1-terra / max
Session: 01a22aff-bb68-7e31-ae71-ee4ab48ad9d0 · slot 0 · generation 45
- P2
pkg/datalink/read_budget.go:127: A single local source blocks 2 × the initial GOMAXPROCS reads, and those requests are canceled or reach max_execution_time before the underlying reads return.
Impact: The abandoned reads retain every process-wide local-read permit. An unrelated healthy local LOAD_FILE or LOAD_TEXT query cannot start and can time out; with max_execution_time=0 it can wait until the session or client deadline. This is distinct from the documented limit in which two independent blocking providers exhaust the remote-I/O budget.
Evidence: The local semaphore has no per-source reservation, and the worker releases its permit only after the underlying read finishes; LocalETLFS.Close does not interrupt the reader. On the assigned head with GOMAXPROCS=1, an embedded MySQL probe timed out two reads of one FIFO, then an independent regular-file read returned error 3024 after 301 ms. A zero-limit session also remained blocked until its client deadline, and the healthy read recovered after the FIFO was released. A race-enabled component probe reproduced the same behavior with a direct-reader control. Make canceled local reads interruptible or prevent one local source from monopolizing the budget while retaining a bound on late work.
Validation:
-
Current artifacts are under /mnt/nvme/mo-bot-55-live/state/jobs/50a64aa4b8a3c0d68be107e1/attempt-1. Isolation preflight passed, and the retained native build matched 171 current source inputs and 44 artifacts; see preflight.log, native-reuse-audit.log, and checks/1796023046981413696-3.json and checks/1796023076182445512-4.json.
-
Current-head subscription-context, statistics fallback, and ONNX constructor-handoff tests passed: final-focused-tests.log and checks/1796023401960546727-3.json.
-
The public MySQL diagnostic reproduced the local starvation and recovery. The maintained max_execution_time SQL case passed mo-tester comparison twice, 8/8 each, on the same embedded cluster: public-bvt-probes.log, bvt-run-1.log, bvt-run-2.log, bvt-report-1.txt, bvt-report-2.txt, and checks/1796024016366011100-3.json.
-
The local-read diagnostic and neighboring cancellation and isolation tests passed under the race detector; the diagnostic asserts the erroneous starvation outcome: local-saturation-race.log and checks/1796024473075306154-3.json.
-
The MySQL parser regenerated from the changed grammar matches the checked-in output, and git diff --check passed. The comparison and diff receipts are checks/1796024132863692431-3.json and checks/1796024494642834983-3.json.
-
Prior same-PR public timeout/admission tests and 100 race repetitions of the document-input budget were reused for unchanged paths. review-audit.log and checks/1796024562143926740-5.json reconcile their earlier-head receipts, current source differences, logs, and all 39 discussion entries.
Limitations:
-
The current subscription-context fix was independently checked at the component boundary. The PR also reports a public MySQL subscription probe, but its raw log was not supplied.
-
A full race suite, forced remote execution on multiple CNs, and a live HDFS or NFS deployment were not run for this head.
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed e18b3b1d4b5d4d58c1656402010908a0d3db0a6b against 4.2-dev (47e43f24a51ca72f6ecc8bf7a3655fce418b3bb8) for the SELECT timeout and zero-limit behavior in #33378.
- [P1]
pkg/datalink/read_budget.go:127A stalled local source can block unrelated local file reads after the original statements have already returned. The local budget has2 × GOMAXPROCSprocess-wide permits, and each worker holds its permit until I/O completes.LocalETLFS.Readcan block inos.Open, andLocalETLFS.Closedoes not unblock it. The exact-head MySQL probe atGOMAXPROCS=1reported that two reads of a stalled FIFO returned 3024 while their workers kept both permits. A subsequentLOAD_FILEof a healthy regular file returned 3024, and the zero-limit control waited until the client deadline. The frontend session deadline routes the zero-limit request through the same semaphore. The base read path opened each file directly, so the stalled source could not cause this shared admission failure. Make stalled local I/O interruptible or preserve progress for independent local sources while keeping outstanding work bounded. Exact-head probe report
The three findings from the previous review are resolved at this head, and the author replied directly to each thread.
- Unused locking CTEs are timed during admission and execution. Parser effects now follow CTE references, and the bound plan determines whether execution takes locks. The author reported a race-enabled MySQL test with both unused and reachable locking controls. Author reply
- HDFS scalar plugin acquisition now goes through the deadline-aware datalink path before compiler admission. The author reported 3024 for both scalar forms during a stalled HDFS open and a healthy HTTP initialization while the fetch was pending. Author reply
- ONNX runtime initialization and native session construction now let the caller return on expiry. The constructor owns late cleanup and releases capacity after handoff. The author reported race-enabled cancellation, handoff, inference and lifecycle tests. Author reply
The subscription catalog lookup now inherits the statement context and retains its system identity and one-minute cap. The component regression checks cancellation propagation and identity.
All 46 checks completed. Of those, 28 succeeded, 16 were skipped, and 2 were neutral. There were no failures, and CI Required succeeded. CI Required
git diff --check and the PR artifact check passed against the dispatched base and head. I verified the finding through the pinned source and the supplied exact-head probe report. I skipped local SQL and race reruns because that evidence establishes the failure path and its recovery control.
| var releaseIO func() | ||
| switch mode { | ||
| case fileservice.SQLReadLocal: | ||
| err = localReadSlots.Acquire(ctx, 1) |
There was a problem hiding this comment.
[P1] A stalled local source can exhaust the process-wide read budget after its queries have returned. At GOMAXPROCS=1, the exact-head MySQL probe reported two timed-out reads of one FIFO whose workers still held both permits. An unrelated LOAD_FILE of a regular file then returned 3024. With max_execution_time=0, the healthy read still waited until the client deadline because the frontend session deadline also routes through this semaphore. The base opens each file directly. Make stalled local I/O interruptible or preserve capacity for independent local sources while keeping outstanding work bounded.
|
mo-bot review · Commit: confirmed findings require request_changes; other decisions need no findings |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: ab188e88cdcb4c1ac0f14f84233f0c6e37fc95c7
Assessment: request_changes
The timeout reuses existing request and transaction cancellation, while separate bounded I/O and conversion admission addresses late work and the earlier single-source starvation concern. The new stalled-read regression test has an order-dependent fixture failure that prevents isolated and focused race runs.
Model: gpt-6.1-terra / max
Session: 01a22aff-bb68-7e31-ae71-ee4ab48ad9d0 · slot 0 · generation 45
- P2
pkg/datalink/read_budget_test.go:60: Run TestStalledLocalReadsLeaveOtherFilesAvailable in a fresh test process before another test initializes the shared auto-increment service.
Impact: The test panics during synctest teardown, so isolated regression runs and focused race checks fail even though the assertions completed. Full-package runs can hide the defect through test order.
Evidence: readTestProcess calls testutil.NewProc, which initializes a runtime-wide auto-increment service and starts long-lived goroutines inside the synctest bubble. Both the isolated normal run and the focused race run failed with 'main bubble goroutine has exited but blocked goroutines remain' (isolated-test.log and race-test.log). A diagnostic overlay that initializes the shared fixture before entering the bubble passed the focused race run (race-control.log). Initialize the service or process outside the bubble, or use a fixture that does not start persistent workers there.
Validation:
-
Private /tmp and loopback preflight passed; native prerequisites matched 171 tracked inputs and 44 artifact hashes.
-
The public SQL tests passed for ordinary and prepared SELECTs, admission, locking reads, HDFS cancellation, session reuse, and a FIFO isolation probe covering timed and zero-limit sessions (public-test.log; checks/1796044340808603272-3.json).
-
Focused datalink, file-service, frontend, plan, process-codec, and AWS endpoint tests passed (focused-test.log and remaining-tests.log).
-
The unmodified focused race run and isolated normal test failed as described in the finding. The focused race control passed with a diagnostic fixture overlay; function-constructor race checks passed with a separate overlay exercising the statement-timeout WASM path.
-
Reused the earlier same-PR BVT comparison: the unchanged timeout case passed twice on one instance, 8/8 each. The earlier parser regeneration comparison also matches the current generated parser.
-
Review audit matched the reported checks to their receipts and logs and accounted for all 44 discussion keys (review-audit.log).
Limitations:
-
Real ONNX Runtime inference and a forced remote multi-CN pipeline were not independently exercised in this review.
-
The passing race control changes the test fixture through an overlay and is not a pass of the unmodified isolated test.
Honor the statement deadline during transaction admission and retain the workspace transaction context. Exempt nested locking reads, share the protocol helper across platforms, and add SQL BVT coverage for #33378.
Classify reachable locking reads after binding, carry deadlines through file reads and native initialization, and retain admission through disposal. Limit live ONNX sessions per CN and return promptly when that capacity is occupied.
Signed-off-by: XuPeng-SH <[email protected]>
Signed-off-by: XuPeng-SH <[email protected]>
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 75d83440185387df56b54c8f4799cb6fdf2f4db9
Assessment: approve
The prior test-fixture finding is resolved, and no new actionable issue was found. The timeout continues to reuse request and transaction cancellation, with bounded I/O and conversion admission to manage work that can outlive a canceled query.
Model: gpt-6.1-terra / max
Session: 01a22aff-bb68-7e31-ae71-ee4ab48ad9d0 · slot 0 · generation 45
Validation:
-
The formerly failing stalled-local-read test passed alone on the current head without an overlay: normal mode at GOMAXPROCS=1 and race mode at GOMAXPROCS=4.
-
The affected datalink fixture consumers passed together under shuffled race selection.
-
Current-head SQL tests passed for ordinary and prepared SELECTs, transaction admission, nested locking reads, HDFS cancellation, zero-limit behavior, and session reuse. Remote process codec and plan-classification tests also passed.
-
Reused the earlier same-PR SQL BVT evidence: the timeout case passed twice, 8/8 each, on one instance. The case and selected timeout owners remain unchanged.
-
Preflight and native-input provenance checks passed. The review audit matched test logs to receipts and accounted for all 46 discussion entries.
Limitations:
-
Real ONNX Runtime inference and forced remote multi-CN execution were not independently rerun on this head.
-
CI was still in progress in the supplied snapshot; no full CI pass is claimed.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #33378. Backports #27020, which addressed #26678, to
4.2-dev.What this PR does / why we need it:
Honor session
max_execution_timefor read-only SELECT and both prepared protocols. Expiry returns MySQL 3024 (HY000) and the connection remains usable. Zero disables the statement limit.Two stalled keys can fill a pool. Relative and absolute spellings, links, and mount aliases may have distinct lexical keys. A PDF or DOCX conversion can continue after its query returns and retains both permits until it finishes.
Testing
MO_TABLE_ROWSandMO_TABLE_SIZEreturned 3024/HY000 at about 1.002 seconds, down from 3.012 seconds. The same connection executedSELECT 42, and a zero limit let the lookup finish. Ordinary, prepared, locking, and admission controls passed in the same run.744bd3e37cand passed under race at parallelism 1 and 4. At GOMAXPROCS=1, a MySQL TCP probe with local SDK transport returned the expected DOCX from us-west-2 in 4.7 ms while the us-east-1 request was stalled. The east request returned 3024/HY000 and its connection remained usable. SDK presigning verified the configured authority for profile regions, endpoint overrides, the China partition, FIPS, and dual stack.999c0feedfand returned the expected text in 2.8 ms at744bd3e37c, while all four HDFS reads were still stalled. Each stalled statement later returned 3024/HY000 and its connection executedSELECT 42.GOMAXPROCS=1and4on75d8344018. Its fixture supplies only the request context, file service, and SQL identity. Channel barriers verify that canceled readers retain admission, independent local files and DOCX documents remain readable, and all permits recover when I/O completes. Path tests cover raw, named, and dynamic disk targets, and cache fallback preserves range results.4.2-dev@0e4db02ddd, the shuffled datalink and full fileservice suites and three selected MySQL TCP tests for [Bug]: Backport enforcement of max_execution_time to 4.2 #33378 and [Performance]: 4.2.8 delays disconnected-query cancellation by 30–35 seconds #32362 passed under race. Incremental gofmt, vet, molint, and golangci-lint passed across 17 Go packages with no new diagnostics.4.2-dev@47e43f24a5.Earlier revisions also passed the scalar WASM, Starlark and jq BVT suites (17/17, 7/7 and 65/65) and the cache and provider isolation probes.