fix: critical database connection pool exhaustion issues
- Disabled duplicate email service (emailService.js) that was creating redundant connections - Increased connection pool size from 10 to 25 for production environment - Extended session timeout cache from 5 to 30 minutes to reduce DB queries - Added connection retry logic with exponential backoff for transient failures - Fixed password validation to use retry wrapper and correct setting key - Updated public settings and gallery middleware to handle connection failures gracefully These changes address the "Connection terminated unexpectedly" errors in production by: 1. Reducing unnecessary database connections 2. Increasing available connection pool capacity 3. Implementing automatic retry for transient connection failures 4. Caching frequently accessed data for longer periods 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@ const DEFAULT_SESSION_TIMEOUT = 60 * 60 * 1000;
|
||||
// Cache for session timeout setting
|
||||
let cachedTimeout = null;
|
||||
let cacheExpiry = 0;
|
||||
const CACHE_DURATION = 5 * 60 * 1000; // 5 minutes
|
||||
const CACHE_DURATION = 30 * 60 * 1000; // 30 minutes - reduced DB queries
|
||||
|
||||
// Clean up expired sessions every 5 minutes
|
||||
setInterval(() => {
|
||||
|
||||
Reference in New Issue
Block a user