diff --git a/config/dbMysqlConn.js b/config/dbMysqlConn.js index 55d07a9..f76fc7d 100755 --- a/config/dbMysqlConn.js +++ b/config/dbMysqlConn.js @@ -43,33 +43,33 @@ pool.getConnection((err, conn) => { // console.log('Connection %d released', connection.threadId); // }); -// --- The Deadlock Optimizer --- -// This function wraps your queries and retries them if a deadlock occurs -const queryWithRetry = async (sql, params, retries = 3) => { - for (let attempt = 1; attempt <= retries; attempt++) { - try { - return await pool.execute(sql, params); - } catch (err) { - const isDeadlock = err.code === 'ER_LOCK_DEADLOCK' || err.errno === 1213; +// // --- The Deadlock Optimizer --- +// // This function wraps your queries and retries them if a deadlock occurs +// const queryWithRetry = async (sql, params, retries = 3) => { +// for (let attempt = 1; attempt <= retries; attempt++) { +// try { +// return await pool.execute(sql, params); +// } catch (err) { +// const isDeadlock = err.code === 'ER_LOCK_DEADLOCK' || err.errno === 1213; - if (isDeadlock && attempt < retries) { - console.warn(`Deadlock detected. Retry attempt ${attempt}...`); - // Wait slightly longer each time (Exponential Backoff) - await new Promise(res => setTimeout(res, attempt * 100)); - continue; - } - throw err; // If not a deadlock or out of retries, throw - } - } -}; +// if (isDeadlock && attempt < retries) { +// console.warn(`Deadlock detected. Retry attempt ${attempt}...`); +// // Wait slightly longer each time (Exponential Backoff) +// await new Promise(res => setTimeout(res, attempt * 100)); +// continue; +// } +// throw err; // If not a deadlock or out of retries, throw +// } +// } +// }; -module.exports = { - pool, - query: queryWithRetry -}; +// module.exports = { +// pool, +// query: queryWithRetry +// }; -// module.exports = pool; +module.exports = pool;