Repository navigation
Closed
Labels
Description
Bug description
When using @prisma/adapter-mariadb with Prisma 7, the idleTimeout configuration is completely ignored. Connections are created but never returned to the pool - they remain in MySQL "Sleep" state for 50-60+ seconds instead of being released after the configured idle timeout.
This causes connection pool exhaustion under normal load.
How to reproduce
- Configure Prisma 7 with MariaDB adapter:
import { PrismaClient } from '@prisma/client';
import { PrismaMariaDB } from '@prisma/adapter-mariadb';
import mariadb from 'mariadb';
const pool = mariadb.createPool({
host: 'localhost',
user: 'user',
password: 'password',
database: 'mydb',
connectionLimit: 30,
idleTimeout: 5000, // 5 seconds - IGNORED
minimumIdle: 2,
acquireTimeout: 10000,
});
const adapter = new PrismaMariaDB(pool);
const prisma = new PrismaClient({ adapter });
2. Run any query:
await prisma.user.findMany();
3. Check MySQL connections:
SHOW PROCESSLIST;
-- or
SELECT * FROM information_schema.PROCESSLIST WHERE COMMAND = 'Sleep' AND USER = 'user';
4. Expected: Connection should be released after 5 seconds idle
5. Actual: Connection stays in Sleep state for 50-60+ seconds, accumulating with each query
Expected behavior
Connections should be returned to the pool and released according to idleTimeout configuration (5 seconds in the example above).
Prisma information
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
Environment & setup
- OS: Ubuntu 24.04 LTS
- Database: MariaDB 10.11.15
- Node.js: v20.x
- Prisma: 7.2.1
- @prisma/adapter-mariadb: 7.2.1
- mariadb (driver): 3.4.0
Impact
Severity: High - Production systems experience connection exhaustion
In our production environment (2 API instances × 30 connections = 60 pool limit), we observed:
- Connections accumulating to 41/40 (102% of original limit) within hours
- Queries timing out with "Connection pool timeout"
- Users experiencing 500 errors
Current Workaround
We implemented a cron-based workaround that kills leaked connections every 30 seconds:
#!/bin/bash
# Kill connections idle > 10 seconds
mysql -e "SELECT CONCAT('KILL ', ID, ';') FROM information_schema.PROCESSLIST
WHERE COMMAND = 'Sleep' AND USER = 'app_user' AND TIME > 10;" | mysql
This is not ideal but keeps the system operational.
Additional context
- The same configuration worked correctly with Prisma 5.x (without driver adapters)
- The mariadb npm package's idleTimeout works correctly when used directly (without Prisma adapter)
- This suggests the adapter is not properly propagating pool management to the underlying driver
Logs
Connection cleanup log showing ~15-20 leaked connections every 30 seconds:
2025-12-26 20:08:01 KILLED=20 idle connections (>10s)
2025-12-26 20:08:31 KILLED=14 idle connections (>10s)
2025-12-26 20:09:01 KILLED=20 idle connections (>10s)
2025-12-26 20:09:31 KILLED=18 idle connections (>10s)
2025-12-26 20:10:01 KILLED=16 idle connections (>10s)
### Severity
🚨 Critical: Data loss, app crash, security issue
### Reproduction
<!-- Link to CodeSandbox, GitHub repo, or step-by-step instructions -->
### Expected vs. Actual Behavior
Connections should be returned to the pool and released according to idleTimeout configuration (5 seconds in the example above).
Prisma information
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
### Frequency
Consistently reproducible
### Does this occur in development or production?
Both development and production
### Is this a regression?
Yes it worked in Prisma 5,X and it doesn't in Prisma 7
### Workaround
We implemented a cron-based workaround that kills leaked connections every 30 seconds:
#!/bin/bash
# Kill connections idle > 10 seconds
mysql -e "SELECT CONCAT('KILL ', ID, ';') FROM information_schema.PROCESSLIST
WHERE COMMAND = 'Sleep' AND USER = 'app_user' AND TIME > 10;" | mysql
This is not ideal but keeps the system operational.
### Prisma Schema & Queries
```prisma
// Add relevant schema.prisma snippet// Add relevant Prisma Client queryPrisma Config
// Add your `prisma.config.ts`Logs & Debug Info
// Debug logs here
Environment & Setup
- OS:
- Database:
- Node.js version:
Prisma Version
// Prisma version output
Reacted by coderabbitai, azhezzzz and StefanAtzlinger
Activity
coderabbitai commentedon Dec 27, 2025
📝 CodeRabbit Plan Mode
Generate an implementation plan and prompts that you can use with your favorite coding agent.
Examples
🔗 Similar Issues
Related Issues
🔗 Related PRs
#28771 - fix(cli): studio mishandles remote "prisma+postgres:" connection strings. [merged]
#28831 - fix: don't leak connections in timed out transactions [merged]
#28883 - fix: remove pool param for studio ppg connections [merged]
#28909 - feat(adapter-mariadb): Improve MariaDB adapter error reporting by surfacing underlying error causes [merged]
👤 Suggested Assignees
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
Mimmox81 commentedon Jan 1, 2026
Additional Details
Complete Adapter Configuration
peterwake commentedon Jan 21, 2026
@Mimmox81 I've had a similar issue but looking this and #29053 .. are you saying in 29053 that this issue is now (kind-of) fixed? Is it because you upgraded to a later version of something? Thanks.
peterwake commentedon Jan 21, 2026
Actually @Mimmox81 I did some more work on this this afternoon, and my issue was because I have 3 processes that were creating 10 connections each. So perhaps you have something like this where you have multiple threads of your app creating more connections than you'd expect.
Mimmox81 commentedon Feb 1, 2026
@peterwake you're right — we can confirm this is amplified by multi-process setups.
Our setup:
What we observe (still, as of today Feb 1 2026):
We run a cron cleanup script every 20 minutes that kills idle MySQL connections exceeding 35s. The data is very consistent:
The configured idleTimeout: 10 is clearly being ignored by the adapter — connections sit in MySQL Sleep state for 46-59 seconds instead of being released after 10s. This happens consistently 24/7, not just under load.
The workaround (cron killing idle connections from MySQL side) keeps the system stable, but it shouldn't be necessary. The underlying mariadb npm driver handles idleTimeout correctly when used directly — the issue is in how
@prisma/adapter-mariadb propagates pool settings to the driver.
Happy to provide additional diagnostics if helpful.
idleTimeoutconfiguration in@prisma/adapter-mariadbhas a variable delay of 3-4x the configured value. #29053 as a duplicate of this issuefix(adapter-mariadb): release pooled connections and harden transacti…
fix(adapter-mariadb): release pooled connections and harden transacti…
fix(adapter-mariadb): release pooled connections and harden transacti…
fix(adapter-mariadb): release pooled connections and harden transacti…