Skip to content

idleTimeout configuration in @prisma/adapter-mariadb has a variable delay of 3-4x the configured value. #29053

Closed as duplicate

Description

@Mimmox81

Bug description

Environment

  • Prisma: 7.3.0-dev.16
  • @prisma/adapter-mariadb: 7.3.0-dev.16
  • mariadb driver: 3.4.0
  • Node.js: 20.x
  • Database: MariaDB 10.11
  • Platform: Ubuntu 24.04, PM2 cluster (2 instances)

Configuration

const adapter = new PrismaMariaDb({                                                                                                                                                                                                
  host: config.host,                                                                                                                                                                                                               
  port: config.port,                                                                                                                                                                                                               
  user: config.user,                                                                                                                                                                                                               
  password: config.password,                                                                                                                                                                                                       
  database: config.database,                                                                                                                                                                                                       
  connectionLimit: 30,                                                                                                                                                                                                             
  connectTimeout: 10000,                                                                                                                                                                                                           
  idleTimeout: 10,      // 10 seconds                                                                                                                                                                                              
  minimumIdle: 2,                                                                                                                                                                                                                  
});                                                                                                                                                                                                                                
                                                                                                                                                                                                                                   
Expected behavior                                                                                                                                                                                                                  
                                                                                                                                                                                                                                   
Idle connections should be cleaned up ~10-15 seconds after becoming idle.                                                                                                                                                          
                                                                                                                                                                                                                                   
Actual behavior                                                                                                                                                                                                                    
                                                                                                                                                                                                                                   
Idle connections are cleaned up after 30-50 seconds (3-4x delay).                                                                                                                                                                  
                                                                                                                                                                                                                                   
Proof that mariadb driver works correctly                                                                                                                                                                                          
                                                                                                                                                                                                                                   
Direct test with mariadb driver (WITHOUT Prisma):                                                                                                                                                                                  
                                                                                                                                                                                                                                   
const pool = mariadb.createPool({                                                                                                                                                                                                  
  host: '...',                                                                                                                                                                                                                     
  connectionLimit: 5,                                                                                                                                                                                                              
  idleTimeout: 10,                                                                                                                                                                                                                 
  minimumIdle: 1,                                                                                                                                                                                                                  
});                                                                                                                                                                                                                                
                                                                                                                                                                                                                                   
// Result:                                                                                                                                                                                                                         
// +5s:  idle=2                                                                                                                                                                                                                    
// +10s: idle=2                                                                                                                                                                                                                    
// +15s: idle=1  ✅ Cleanup worked!                                                                                                                                                                                                
                                                                                                                                                                                                                                   
Proof of delay through Prisma adapter                                                                                                                                                                                              
                                                                                                                                                                                                                                   
Same config through PrismaMariaDb adapter:                                                                                                                                                                                         
                                                                                                                                                                                                                                   
+2s after burst:  4 idle connections                                                                                                                                                                                               
+27s:             4 idle connections (no cleanup!)                                                                                                                                                                                 
+47s:             2 idle connections (cleanup finally happened)                                                                                                                                                                    
                                                                                                                                                                                                                                   
The cleanup happened at ~40-45s instead of ~10-15s.                                                                                                                                                                                
                                                                                                                                                                                                                                   
Impact                                                                                                                                                                                                                             
                                                                                                                                                                                                                                   
- Connections stay idle longer than expected                                                                                                                                                                                       
- Server wait_timeout (60s) can interfere with pool management                                                                                                                                                                     
- Requires external cron job as workaround to kill stale connections                                                                                                                                                               
                                                                                                                                                                                                                                   
Workaround                                                                                                                                                                                                                         
                                                                                                                                                                                                                                   
We run a cron job every 30 seconds that kills connections idle > 35 seconds:                                                                                                                                                       
                                                                                                                                                                                                                                   
mysql -e "SELECT CONCAT('KILL ', ID) FROM information_schema.PROCESSLIST                                                                                                                                                           
  WHERE COMMAND='Sleep' AND USER='app_user' AND TIME > 35;" | mysql                                                                                                                                                                
                                                                                                                                                                                                                                   
Additional context                                                                                                                                                                                                                 
                                                                                                                                                                                                                                   
This is NOT related to issue #19215 (mobc idle cleanup) since we're using driver adapters which bypass mobc entirely.                                                                                                              
                                                                                                                                                                                                                                   
The mariadb driver handles idleTimeout correctly - the delay appears to be introduced by the Prisma adapter layer.     

### Severity

🔹 Minor: Unexpected behavior, but does not block development

### Reproduction

                                                                                                                                                                                                
                                                                                                                                                                                                                                   
- Prisma: 7.3.0-dev.16                                                                                                                                                                                                             
- @prisma/adapter-mariadb: 7.3.0-dev.16                                                                                                                                                                                            
- mariadb driver: 3.4.0                                                                                                                                                                                                            
- Node.js: 20.x                                                                                                                                                                                                                    
- Database: MariaDB 10.11                                                                                                                                                                                                          
- Platform: Ubuntu 24.04, PM2 cluster (2 instances)                                                                                                                                                                                
                                                                                                                                                                                                                                   
### Configuration                                                                                                                                                                                                                  
                                                                                                                                                                                                                                   
```typescript                                                                                                                                                                                                                      
const adapter = new PrismaMariaDb({                                                                                                                                                                                                
  host: config.host,                                                                                                                                                                                                               
  port: config.port,                                                                                                                                                                                                               
  user: config.user,                                                                                                                                                                                                               
  password: config.password,                                                                                                                                                                                                       
  database: config.database,                                                                                                                                                                                                       
  connectionLimit: 30,                                                                                                                                                                                                             
  connectTimeout: 10000,                                                                                                                                                                                                           
  idleTimeout: 10,      // 10 seconds                                                                                                                                                                                              
  minimumIdle: 2,                                                                                                                                                                                                                  
});                                 


### Expected vs. Actual Behavior

Idle connections should be cleaned up ~10-15 seconds after becoming idle.                                                                                                                                                          
                                                                                                                                                                                                                                   
Actual behavior                                                                                                                                                                                                                    
                                                                                                                                                                                                                                   
Idle connections are cleaned up after 30-50 seconds (3-4x delay).                                                                                                                                                                  
                                                                                                                                                                                                                                   
Proof that mariadb driver works correctly                                                                                                                                                                                          
                                                                                                                                                                                                                                   
Direct test with mariadb driver (WITHOUT Prisma):                                                                                                                                                                                  
                                                                                                                                                                                                                                   
const pool = mariadb.createPool({                                                                                                                                                                                                  
  host: '...',                                                                                                                                                                                                                     
  connectionLimit: 5,                                                                                                                                                                                                              
  idleTimeout: 10,                                                                                                                                                                                                                 
  minimumIdle: 1,                                                                                                                                                                                                                  
});                                                                                                                                                                                                                                
                                                                                                                                                                                                                                   
// Result:                                                                                                                                                                                                                         
// +5s:  idle=2                                                                                                                                                                                                                    
// +10s: idle=2                                                                                                                                                                                                                    
// +15s: idle=1  ✅ Cleanup worked!                                                                                                                                                                                                
                                                                                                                                                                                                                                   
Proof of delay through Prisma adapter                                                                                                                                                                                              
                                                                                                                                                                                                                                   
Same config through PrismaMariaDb adapter:                                                                                                                                                                                         
                                                                                                                                                                                                                                   
+2s after burst:  4 idle connections                                                                                                                                                                                               
+27s:             4 idle connections (no cleanup!)                                                                                                                                                                                 
+47s:             2 idle connections (cleanup finally happened)                                                                                                                                                                    
                                                                                                                                                                                                                                   
The cleanup happened at ~40-45s instead of ~10-15s.                                                                                                                                                                                
                                                                                                                                                                                                                                   
Impact                                                                                                                                                                                                                             
                                                                                                                                                                                                                                   
- Connections stay idle longer than expected                                                                                                                                                                                       
- Server wait_timeout (60s) can interfere with pool management                                                                                                                                                                     
- Requires external cron job as workaround to kill stale connections                                                                                                                                                               
                                                                                                                                                                                                                                   
Workaround                                                                                                                                                                                                                         
                                                                                                                                                                                                                                   
We run a cron job every 30 seconds that kills connections idle > 35 seconds:                                                                                                                                                       
                                                                                                                                                                                                                                   
mysql -e "SELECT CONCAT('KILL ', ID) FROM information_schema.PROCESSLIST                                                                                                                                                           
  WHERE COMMAND='Sleep' AND USER='app_user' AND TIME > 35;" | mysql   

### Frequency

Consistently reproducible

### Does this occur in development or production?

Both development and production

### Is this a regression?

Yes, last worked in Prisma 5.2.0 and broke in Prisma 7.

### Workaround

We run a cron job every 30 seconds that kills connections idle > 35 seconds:                                                                                                                                                       
                                                                                                                                                                                                                                   
mysql -e "SELECT CONCAT('KILL ', ID) FROM information_schema.PROCESSLIST                                                                                                                                                           
  WHERE COMMAND='Sleep' AND USER='app_user' AND TIME > 35;" | mysql  


### Prisma Schema & Queries

```prisma
// Add relevant schema.prisma snippet
// Add relevant Prisma Client query

Prisma Config

// Add your `prisma.config.ts`

Logs & Debug Info

// Debug logs here

Environment & Setup

  • Prisma: 7.3.0-dev.16
  • @prisma/adapter-mariadb: 7.3.0-dev.16
  • mariadb driver: 3.4.0
  • Node.js: 20.x
  • Database: MariaDB 10.11
  • Platform: Ubuntu 24.04, PM2 cluster (2 instances)

Prisma Version

  • Prisma: 7.3.0-dev.16

Activity

  1. added
    kind/bug
    on Jan 20, 2026
  2. jacek-prisma commented on Feb 4, 2026

    @jacek-prisma
    Contributor

    I think this discussion should move to the existing issue, because it looks like it's the same underlying problem

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions