Skip to content

Commit

Permalink
Merge pull request #446 from balena-io/pg-query-statement-timeout
Browse files Browse the repository at this point in the history
Add the ability to specify query/statement timeouts for pg backend
  • Loading branch information
Page- authored Jan 22, 2021
2 parents 12e01a7 + 59e6548 commit a9c59cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/config-loader/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ if (process.env.TRANSACTION_TIMEOUT_MS) {

export const db = {
poolSize: 50,
idleTimeoutMillis: 30000,
connectionTimeoutMillis: 30000,
keepAlive: true,
idleTimeoutMillis: 30000 as number | undefined,
statementTimeout: undefined as number | undefined,
queryTimeout: undefined as number | undefined,
connectionTimeoutMillis: 30000 as number | undefined,
keepAlive: true as boolean | undefined,
rollbackTimeout: 30000,
timeoutMS,
};
Expand Down
2 changes: 2 additions & 0 deletions src/database-layer/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ if (maybePg != null) {
}
config.max = env.db.poolSize;
config.idleTimeoutMillis = env.db.idleTimeoutMillis;
config.statement_timeout = env.db.statementTimeout;
config.query_timeout = env.db.queryTimeout;
config.connectionTimeoutMillis = env.db.connectionTimeoutMillis;
config.keepAlive = env.db.keepAlive;
const pool = new pg.Pool(config);
Expand Down

0 comments on commit a9c59cb

Please sign in to comment.