Repository navigation
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Apply cacheability checks packages/client/src/runtime/core/engines/client/ClientEngine.ts |
request uses isCacheableQuery for cache access. requestBatch accesses the batch cache only when every query is cacheable. The helper excludes createMany and createManyAndReturn. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Merge Risk: 
Minimal · previous review c7dc1
-
The change is intended to keep row-count-dependent bulk-write plans out of the batch cache. No actionable merge-blocking risk is evident from the supplied context.
Security architecture risk: 
Minimal · up to c7dc1
-
The change reduces memory retention for bulk writes without changing which operations can run or their transaction controls. No introduced or worsened security exposure was identified.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The directly affected resource is the ClientEngine instance's in-process plan cache. Database operations continue through existing execution and transaction inputs; no wider tenant, service, or environment exposure is established by the scoped change.
Trust Boundaries and Controls
- inferred — Caller-supplied query actions now determine whether a batch plan may be retained, but do not select a new execution sink or gain transaction authority. Bypassing the cache follows the same compilation path previously used on a cache miss, rather than bypassing an authorization control.
Resilience and Maintainability Implications
- inferred — Excluded batches publish no cache entry requiring cleanup on failure or repetition. Cache operations are synchronous, and request-local values remain separate from retained plans. The reviewed diff leaves execution failure handling and transaction recovery unchanged; interruption and concurrency conclusions are source-based, not runtime-tested.
-
🚥 Pre-merge checks | ✅ 4 | ❌ 1
-
❌ Failed checks (1 warning)
Check name Status Explanation Resolution Docstring Coverage ⚠️ WarningDocstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
-
Check name Status Explanation Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled. Title check ✅ Passed The title clearly summarizes the main change: batch query plans containing createMany are not cached. 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.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: prisma/orm/.coderabbit.yml
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
8e5e4400-604f-454b-a1c9-d8ad6521a191
📒 Files selected for processing (1)
-
packages/client/src/runtime/core/engines/client/ClientEngine.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: prisma/orm/.coderabbit.yml
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
8e5e4400-604f-454b-a1c9-d8ad6521a191
📒 Files selected for processing (1)
-
packages/client/src/runtime/core/engines/client/ClientEngine.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
|
Thank you for this, and sorry for the long wait. We want this change and are getting it ready to merge. One thing only you can do: the repository now requires a Developer Certificate of Origin sign-off on every commit (see CONTRIBUTING), and the commits on this branch have none. Please add it with |
The single query path does not cache createMany and createManyAndReturn plans, because their shape changes with the row count. The batch path cached them: a $transaction([deleteMany, createMany]) array got one new batch plan entry for each row count. These plans grow with the number of rows, so the batch cache can hold gigabytes of plans that are never used again. Use the same check in both paths. A batch that contains a createMany or createManyAndReturn query is compiled but not cached. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: luisopine <[email protected]>
c7dc141 to
c2986c1
Compare
|
Done! Thank you! |
The query plan cache does not store
createManyandcreateManyAndReturnplans in the single query path. Their shape changes with the row count, so they rarely get a cache hit and they bloat the cache.The batch path does not have this check. A batch is cached as one entry, keyed by the whole parameterized batch. So a
$transactionarray that contains acreateManygets a new batch entry for each row count:The plan grows with the number of rows. In our production workers, each entry was about 13 MB, and the batch cache held about 2.4–3.6 GB of heap per process, up to the 1,000-entry limit. The large heap made GC pauses long enough to block the event loop for several seconds.
This change moves the existing check into one function,
isCacheableQuery, and uses it in both paths. A batch that contains acreateManyorcreateManyAndReturnquery is compiled but not cached.Measured on 7.10.0 with the same change applied,
$transaction([deleteMany, createMany])for 1 to 200 rows:createMany)The results were the same. A repeated batch with the same row count now compiles each time (46 ms instead of 17 ms at 2,000 rows). That is the same cost that the two queries have today outside a batch.
Related: #29774, #29784, #29785. Those PRs limit the batch cache by plan count, which does not help when each plan is large.
🤖 Generated with Claude Code
Summary by CodeRabbit