diff --git a/Common/config/default.json b/Common/config/default.json index 170d3868f..ff9399b08 100644 --- a/Common/config/default.json +++ b/Common/config/default.json @@ -241,7 +241,10 @@ "idleTimeoutMillis": 30000 } }, - "mysqlExtraOptions": {} + "mysqlExtraOptions": { + "connectTimeout": 60000, + "transactionTimeout": 15000 + } }, "redis": { "name": "redis", diff --git a/DocService/sources/databaseConnectors/mysqlConnector.js b/DocService/sources/databaseConnectors/mysqlConnector.js index d46d4511b..beac2d487 100644 --- a/DocService/sources/databaseConnectors/mysqlConnector.js +++ b/DocService/sources/databaseConnectors/mysqlConnector.js @@ -53,6 +53,11 @@ const connectionConfiguration = { const additionalOptions = configSql.get('mysqlExtraOptions'); const configuration = Object.assign({}, connectionConfiguration, additionalOptions); +let transactionTimeout = 15000; +if (configuration.transactionTimeout) { + transactionTimeout = configuration.transactionTimeout; + delete configuration.transactionTimeout; +} let pool = mysql.createPool(configuration); @@ -68,7 +73,7 @@ async function executeQuery(ctx, sqlCommand, values = [], noModifyRes = false, n try { connection = await pool.getConnection(); - const result = await connection.query(sqlCommand, values); + const result = await connection.query({ sql: sqlCommand, timeout: transactionTimeout, values }); let output; if (!noModifyRes) {