Skip to content

Commit

Permalink
[feature] Added mysql timeouts to config
Browse files Browse the repository at this point in the history
  • Loading branch information
DrToldme committed Jun 4, 2024
1 parent 92682e7 commit 5d978e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Common/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@
"idleTimeoutMillis": 30000
}
},
"mysqlExtraOptions": {}
"mysqlExtraOptions": {
"connectTimeout": 60000,
"transactionTimeout": 15000
}
},
"redis": {
"name": "redis",
Expand Down
7 changes: 6 additions & 1 deletion DocService/sources/databaseConnectors/mysqlConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down

0 comments on commit 5d978e7

Please sign in to comment.