Skip to content

test(drizzle): stress SQL prefixes across garbage collection - #9948

Closed
jdalton wants to merge 3 commits into
PerryTS:mainfrom
jdalton:codex/9935-sql-prefix-stress
Closed

test(drizzle): stress SQL prefixes across garbage collection#9948
jdalton wants to merge 3 commits into
PerryTS:mainfrom
jdalton:codex/9935-sql-prefix-stress

Conversation

@jdalton

@jdalton jdalton commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Issue #9935 reports a Drizzle SELECT arriving at MySQL with its SQL and parameter prefixes missing while the later ORDER BY/LIMIT survives. Add a database-free stress fixture at the query-construction boundary using the exact reported drizzle-orm 0.44.7 version.

The fixture checks the full SQL and each parameter for the original four-predicate query and a wider variant that repeatedly grows chunk/parameter arrays. It varies values per iteration, retains previous results, and collects before appending the tail and after materializing SQL. The release fixture harness discovers it automatically; the README documents longer and scheduled-GC runs.

Refs #9935. This is an investigation PR, not a confirmed reproduction or fix. Keep the issue open: the original failure is rare and Linux-specific, and this probe does not exercise mysql2, transactions, or async scheduling.

Validation on macOS arm64: compiler and static runtimes rebuilt together at PR head f8a33e212145acfd970624a031cebe51ea2bbc80 with pinned nightly-2026-08-20 in perry-dev; probe compiled with --no-auto-optimize. Normal, forced, and small scheduled runs repeated successfully at this final head:

  • Node 26.5.1: 1,000 iterations, 3,999 exact query/result checks, 126 explicit GC calls; expected output matches.

  • Perry normal collection: same output, exit 0.

  • Perry forced evacuation with verification: same output, exit 0; 126 [gc-copy-minor] ran records.

  • Negative controls that remove the SQL prefix or parameter prefix are both rejected by the assertions.

  • Test-registration audit, Node-version consistency, shell syntax, and whitespace checks pass.

  • Dense scheduled GC (seed 9935, rate 0.05, allocation pacing disabled, protected fromspace): 10 iterations pass with 3,590 copying minors and 3,590 protected-fromspace records. The README uses this bounded example.

  • The 1,000-iteration dense scheduled attempt timed out after 60 seconds and 20,719 copying minors. It is incomplete, not a pass.

  • All 64 runnable script/format lint gates pass; two CI-only expressions and the workspace-wide compiler check/clippy tier were skipped. The compiler and static runtimes were built for executing this probe.

The original production failure remains unconfirmed locally.

Summary by CodeRabbit

  • Tests

    • Added database-free release-test coverage for SQL prefix generation and parameter handling.
    • Validates both standard and wider queries across repeated iterations, including behavior during garbage collection.
    • Added checks for generated SQL, parameters, result retention, and expected test counts.
  • Documentation

    • Added setup, execution, scaling, diagnostic, and limitation guidance for the stress probe.
    • Added a changelog entry documenting the investigation coverage.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 5102690f-480b-41f4-853f-03e4c4e6ef2b

📥 Commits

Reviewing files that changed from the base of the PR and between 616a2cb and f8a33e2.

⛔ Files ignored due to path filters (1)
  • tests/release/packages/drizzle-sql-prefix/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • changelog.d/9948-drizzle-sql-prefix-probe.md
  • tests/release/packages/drizzle-sql-prefix/README.md
  • tests/release/packages/drizzle-sql-prefix/entry.ts
  • tests/release/packages/drizzle-sql-prefix/expected.txt
  • tests/release/packages/drizzle-sql-prefix/fixture.sh
  • tests/release/packages/drizzle-sql-prefix/package.json

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

This change adds a database-free Drizzle SQL-prefix stress probe. The probe validates narrow and wide SQL queries, parameters, retained results, and explicit GC activity. Release-fixture wiring, expected output, documentation, and a changelog entry are included.

Changes

Drizzle SQL-prefix stress probe

Layer / File(s) Summary
Probe construction and verification
tests/release/packages/drizzle-sql-prefix/entry.ts
Builds narrow and wide Drizzle queries, validates SQL and parameters, retains previous results, and runs explicit GC checks.
Release fixture integration
tests/release/packages/drizzle-sql-prefix/package.json, tests/release/packages/drizzle-sql-prefix/fixture.sh, tests/release/packages/drizzle-sql-prefix/expected.txt
Configures Drizzle compilation, runs 1,000 iterations through the fixture harness, and records the expected metrics.
Probe documentation and changelog
tests/release/packages/drizzle-sql-prefix/README.md, changelog.d/9948-drizzle-sql-prefix-probe.md
Documents execution modes, diagnostics, scaling guidance, and the investigation scope.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to f8a33

This adds a database-free Drizzle SQL-prefix stress fixture and release-test coverage without changing production behavior. The fixture exercises narrow and wide query generation across garbage collection and is ready to merge.

Sequence Diagram(s)

sequenceDiagram
  participant Fixture as fixture.sh
  participant Probe as entry.ts
  participant Builder as QueryBuilder
  participant GC as Explicit GC
  participant Checks as SQL and parameter checks
  Fixture->>Probe: Run compiled probe
  Probe->>Builder: Build narrow and wide queries
  Probe->>GC: Collect every 16th iteration
  Probe->>Checks: Validate SQL and parameters
  Checks-->>Probe: Return validation results
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (4 skipped: 4 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: a Drizzle SQL-prefix stress test across garbage collection.
Description check ✅ Passed The description provides a clear summary, concrete changes, related issue, detailed validation results, limitations, and test evidence. It does not reproduce the template headings or checklist, but th…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (4 skipped: 4 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jdalton
jdalton marked this pull request as ready for review September 7, 2026 04:59
@proggeramlug

Copy link
Copy Markdown
Contributor

Landed on main via merge train #9959. Validated as a tree: 67/67 lint gates, and perry-runtime/codegen/hir/stdlib all green (5,968 tests, 0 failures). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants