fix(db): increase connection pool size and timeout to handle concurrent verifications

This commit is contained in:
Michael committed 2026-01-13 16:54:26 +01:00
1 parent 03cb562866
commit 16ef17957d
1 file changed
+11 -11
+11 -11
View File
@@ -4,9 +4,9 @@ import * as schema from "@shared/schema";
const isProduction = process.env.NODE_ENV === 'production'; const isProduction = process.env.NODE_ENV === 'production';
const dbUrl = process.env.DATABASE_URL; const dbUrl = process.env.DATABASE_URL;
console.log('🔗 Database initialization:', { console.log('🔗 Database initialization:', {
NODE_ENV: process.env.NODE_ENV, NODE_ENV: process.env.NODE_ENV,
isProduction, isProduction,
hasDbUrl: !!dbUrl, hasDbUrl: !!dbUrl,
dbHost: dbUrl ? new URL(dbUrl).hostname : 'none' dbHost: dbUrl ? new URL(dbUrl).hostname : 'none'
}); });
@@ -19,17 +19,17 @@ if (isProduction && dbUrl && (dbUrl.includes('logiflow-db') || dbUrl.includes('l
console.log('🐳 PRODUCTION: Using standard PostgreSQL'); console.log('🐳 PRODUCTION: Using standard PostgreSQL');
const { Pool } = await import('pg'); const { Pool } = await import('pg');
const { drizzle } = await import('drizzle-orm/node-postgres'); const { drizzle } = await import('drizzle-orm/node-postgres');
pool = new Pool({ pool = new Pool({
connectionString: dbUrl, connectionString: dbUrl,
ssl: false, ssl: false,
max: 10, max: 25, // Increased from 10 to handle concurrent verifications
idleTimeoutMillis: 30000, idleTimeoutMillis: 30000,
connectionTimeoutMillis: 5000, connectionTimeoutMillis: 15000, // Increased from 5000 to 15000
}); });
db = drizzle({ client: pool, schema }); db = drizzle({ client: pool, schema });
// Test connection // Test connection
try { try {
await pool.connect().then((client: any) => { await pool.connect().then((client: any) => {
@@ -45,9 +45,9 @@ if (isProduction && dbUrl && (dbUrl.includes('logiflow-db') || dbUrl.includes('l
const { Pool, neonConfig } = await import('@neondatabase/serverless'); const { Pool, neonConfig } = await import('@neondatabase/serverless');
const { drizzle } = await import('drizzle-orm/neon-serverless'); const { drizzle } = await import('drizzle-orm/neon-serverless');
const ws = await import('ws'); const ws = await import('ws');
neonConfig.webSocketConstructor = ws.default; neonConfig.webSocketConstructor = ws.default;
if (dbUrl) { if (dbUrl) {
pool = new Pool({ connectionString: dbUrl }); pool = new Pool({ connectionString: dbUrl });
db = drizzle({ client: pool, schema }); db = drizzle({ client: pool, schema });