fix: increase DB pool size and fix connection leak in permissions route
- connectionLimit 10 -> 50, queueLimit 0 -> 100 to prevent pool exhaustion - Add missing db.release() in GET /permissions/:id finally block
This commit is contained in:
@@ -826,6 +826,8 @@ export default function () {
|
||||
res
|
||||
.status(500)
|
||||
.json({ message: 'Database error fetching manager permissions.', details: error.message })
|
||||
} finally {
|
||||
db.release()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@ const db = mysql.createPool({
|
||||
database: process.env.DB_NAME,
|
||||
port: process.env.DB_PORT,
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0,
|
||||
connectionLimit: 50,
|
||||
queueLimit: 100,
|
||||
// timezone: '+08:00',
|
||||
dateStrings: true,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { getConnection } from './pool.js'
|
||||
// import mysql from 'mysql2/promise'
|
||||
//
|
||||
//
|
||||
//
|
||||
// export const db = mysql.createPool({
|
||||
// host: '47.254.195.2',
|
||||
// user: 'nilai_clock_indo',
|
||||
// password: '5jHy8ZsfeEjPAhYS',
|
||||
// database: 'nilai_clock_indo',
|
||||
// port: 3306,
|
||||
// waitForConnections: true,
|
||||
// connectionLimit: 10,
|
||||
// queueLimit: 0,
|
||||
// dateStrings: true,
|
||||
// // 不在这里设置timezone,因为我们用查询设置
|
||||
// });
|
||||
|
||||
const conn = await getConnection()
|
||||
|
||||
const [rows] = await conn.execute('select * from clock_records where id= 6654');
|
||||
console.log(rows);
|
||||
Reference in New Issue
Block a user