Skip to content

test: give truncate FK identity statements individual operation budgets - #30383

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
ck89119:issue-30351-main
Oct 16, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
ck89119:issue-30351-main

Conversation

@ck89119

@ck89119 ck89119 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #30351

What this PR does / why we need it:

TestTruncatePreservesMaterializedForeignKeyIdentity executed ~38 SQL statements under one 60s aggregate context. On the saturated Ubuntu race runner from issue #30351 (cluster-wide heartbeat deadlines, heavy CPU throttling, a 240s-class sibling case running concurrently), that aggregate budget ran out mid-test and the deadline fired at an arbitrary in-flight statement. The CI report therefore blamed the initial self-referencing FK INSERT, although the earlier ~32 statements had already consumed the budget — the reported statement had no causal connection to the slowness.

This is a test budgeting defect, not a product failure: the same case passes on clean main locally and remotely, and the failure window shows every embedded subsystem timing out together.

Change (test-only, in pkg/tests/issues/issue_29852_test.go):

  • Keep every SQL statement, positive/negative assertion and assertion message unchanged.
  • Each statement now owns a separate 30s operation context (small local exec/queryRow helpers over an interface satisfied by both *sql.DB and *sql.Conn), derived from a 4min umbrella budget — the budget class already used by multi-statement sibling cases in this package (e.g. TestIssue29399).
  • Failure attribution: a saturated runner no longer fails an innocent later statement; a genuinely slow statement fails with its own SQL text in the failure message.

No shared test helper signatures, production code, fixture topology, retries, sleeps or skips are changed.

Local validation (race, -short, tags matrixone_test)

  • Focused case on the final code: pass (14.8s).
  • Probe reproducing the incident class: 60s umbrella plus 2s injected per-statement latency fails at ~71s (the CI run failed at 71.8s), and the victim statement differs from the CI one — proving the arbitrary-victim property of a shared aggregate deadline.
  • Same latency with the 4min umbrella: pass (~87s).
  • One statement slowed past its 30s budget (all others normal): everything before it passes and the failure message is exactly exec failed: insert into truncate_fk_identity.self values(1,1) — the attribution the original CI failure should have produced.
  • gofmt, go vet -tags matrixone_test, and incremental golangci-lint on the changed package: clean.

TestTruncatePreservesMaterializedForeignKeyIdentity executed ~38 SQL
statements under one 60s aggregate context. On the saturated Ubuntu
race runner from issue matrixorigin#30351 (cluster-wide heartbeat deadlines, heavy
CPU throttling), that aggregate budget ran out mid-test and the
deadline fired at an arbitrary in-flight statement, so the CI report
blamed the initial self-referencing FK INSERT although earlier
statements had already consumed the budget.

Keep every SQL statement and assertion unchanged. Each statement now
owns a separate 30s operation context derived from a 4min umbrella
budget, matching the multi-statement sibling cases in this package. A
saturated runner no longer fails an innocent later statement, and a
genuinely slow statement fails with its own SQL text in the failure
message.

Local evidence (race, -short, tags matrixone_test):
- focused case on the final code: pass (14.8s)
- 60s umbrella plus 2s injected per-statement latency reproduces the
  incident class (fail at ~71s; the victim statement differs from the
  CI one, proving the arbitrary-victim property)
- 4min umbrella with the same latency: pass (~87s)
- one statement slowed past 30s fails with
  "exec failed: insert into truncate_fk_identity.self values(1,1)"

Fixes matrixorigin#30351
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Oct 16, 2026
@mergify mergify Bot added kind/bug Something isn't working kind/test-ci labels Oct 16, 2026
Review follow-up on PR matrixorigin#30383: with per-statement contexts, a negative
assertion could satisfy itself with context.DeadlineExceeded when the
rejected statement exceeded its 30s budget. require.Error accepts any
error, the umbrella context stayed alive, the pool reconnected, and the
case could pass without ever observing the expected FK rejection.

Promote the bounded exec/query closures to named helpers that treat a
dead operation context as an immediate test failure carrying the
statement text, and route the six negative statements through
requireSQLRejection, which requires a server-side *mysql.MySQLError
(the pattern already used by issue_25753/issue_25408 tests). A timeout,
cancellation or transport failure can no longer satisfy any assertion,
positive or negative.

Local evidence (race, -short, tags matrixone_test):
- injecting a 35s delay into the rejected child FK INSERT: the previous
  commit passed silently in 56.6s; this commit fails immediately with
  "statement budget exhausted, exec failed: insert into ...child
  values(1,999) (context deadline exceeded)"
- 2s per-statement incident-class latency still passes under the 4min
  umbrella (88.4s), preserving the issue matrixorigin#30351 fix property
- clean focused case: pass (12.2s); gofmt, vet and incremental lint clean
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: ab8bbf4b146c88fb45cd8df5eb1b239730842a90

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: ab8bbf4b146c88fb45cd8df5eb1b239730842a90

Assessment: approve

Reviewed the complete test-only delta and affected callers. Per-statement deadlines belong in these local helpers, preserve existing SQL and catalog assertions, and strengthen rejection checks against client failures. Cleanup remains intact, with no production-path cost or actionable findings.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • The changed embedded-cluster regression passed under -race -short -tags matrixone_test: once initially, then three repetitions in one process.

  • Race-enabled probes of byte-identical extracted helpers passed: fresh deadlines, cancellation, transport-error rejection, scan-before-cancel, resource release and an actual 30-second statement timeout.

  • Verified native provenance through the repository build owner. Isolation preflight, formatting and scope/oracle checks passed; source remains unchanged.

  • Reconciled command, source and exit receipts with retained logs in /home/xupeng/.local/state/mo-bot/jobs/54e9fbc0beb0a181ad207f39/attempt-1/review-evidence.json. The initial diagnostic-harness failure is preserved and distinguished from candidate results.

  • Frozen evidence reports successful exact-head Ubuntu UT and Linux/arm64 SCA; skipped jobs were not counted as passes.

Limitations:

  • No local full-package rerun; local execution targeted the changed regression and helper contracts.

  • The original CPU-throttling incident and author-reported latency experiments were not independently reproduced. Helper probes used controlled runners and mocked rows alongside the real cluster regression.

@mergify mergify Bot added the queued label Oct 16, 2026
@mergify

mergify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-16 10:07 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-16 11:00 UTC · at f148dcef4c91c6d8bfa43834bbbc0c1ad91703c8

This pull request spent 53 minutes 21 seconds in the queue, with no time running CI.

Reason

Pull request #30383 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
ci — f148dcef Deployed Oct 16, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Ubuntu race UT self-referencing FK INSERT exceeds deadline in truncate identity test

3 participants