Repository navigation
fix(client): prevent caching of createMany queries to avoid cache bloat and possible node.js crashes - #29382
Conversation
…at and possible node.js crashes `createMany` operations inherently have unstable cache keys due to varying row counts and parameter de-duplication. `createMany` operations are characterized by large cache keys and very large query plans. In large batches, the cache will consume several GB of memory that will not be evicted by the GC even after the query is complete because the plans are still referenced by the cache itself. This fix opts out of caching such queries with the following rationale: 1. Such queries will most likely create cache-misses and so caching them is ineffective 2. When running batch load/update workloads, these query plans will evict valid queries from the cache thus creating an advert effect on performance Closes prisma#29331
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughExclude Changes
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@packages/client/tests/functional/issues/29331-query-plan-cache-bloat/tests.ts`:
- Around line 20-51: The test hooks are declared out of lifecycle order:
afterEach is above beforeEach; swap their positions so beforeEach (containing
prisma.contact.createMany and prisma.contactAnalytics.createMany) comes before
afterEach (containing prisma.contactAnalytics.deleteMany and
prisma.contact.deleteMany) to follow conventional setup → teardown ordering and
improve readability.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 37127c63-e2d9-47bf-ad55-ca8f64bcade9
📒 Files selected for processing (4)
packages/client/src/runtime/core/engines/client/ClientEngine.tspackages/client/tests/functional/issues/29331-query-plan-cache-bloat/_matrix.tspackages/client/tests/functional/issues/29331-query-plan-cache-bloat/prisma/_schema.tspackages/client/tests/functional/issues/29331-query-plan-cache-bloat/tests.ts
Merging this PR will not alter performance
Comparing Footnotes
|
Co-authored-by: jacek-prisma <[email protected]>
createManyoperations inherently have unstable cache keys due to varying row counts and parameter de-duplication.createManyoperations are characterized by large cache keys and very large query plans. In large batches, the cache will consume several GB of memory that will not be evicted by the GC even after the query is complete because the plans are still referenced by the cache itself.This fix opts out of caching such queries with the following rationale:
Fixes: #29331
Summary by CodeRabbit
Bug Fixes
Tests