fix(server): database connection pool timeouts reduced (#2646)

* fix(server): database connection pool timeouts reduced
- previous acquisition timeout was 60s; this is reduced to 16s for faster responsiveness
- this allows for 3x attempts of 5s each to create a connection, plus idle time between attempts

* Apply to other knex instances
This commit is contained in:
Iain Sproat 2024-08-26 09:47:27 +01:00 коммит произвёл GitHub
Родитель a5061eceff
Коммит d36e2036aa
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 15 добавлений и 4 удалений

Просмотреть файл

@ -10,7 +10,9 @@ module.exports = require('knex')({
},
pool: {
min: 0,
max: parseInt(process.env.POSTGRES_MAX_CONNECTIONS_FILE_IMPORT_SERVICE) || 1
max: parseInt(process.env.POSTGRES_MAX_CONNECTIONS_FILE_IMPORT_SERVICE) || 1,
acquireTimeoutMillis: 16000, //allows for 3x creation attempts plus idle time between attempts
createTimeoutMillis: 5000
}
// migrations are in managed in the server package
})

Просмотреть файл

@ -10,7 +10,9 @@ module.exports = require('knex')({
},
pool: {
min: 0,
max: parseInt(process.env.POSTGRES_MAX_CONNECTIONS_PREVIEW_SERVICE) || 2
max: parseInt(process.env.POSTGRES_MAX_CONNECTIONS_PREVIEW_SERVICE) || 2,
acquireTimeoutMillis: 16000, //allows for 3x creation attempts plus idle time between attempts
createTimeoutMillis: 5000
}
// migrations are in managed in the server package
})

Просмотреть файл

@ -92,7 +92,12 @@ const commonConfig = {
},
// we wish to avoid leaking sql queries in the logs: https://knexjs.org/guide/#compilesqlonerror
compileSqlOnError: false,
pool: { min: 0, max: postgresMaxConnections() }
pool: {
min: 0,
max: postgresMaxConnections(),
acquireTimeoutMillis: 16000, //allows for 3x creation attempts plus idle time between attempts
createTimeoutMillis: 5000
}
}
/** @type {Object<string, import('knex').Knex.Config>} */

Просмотреть файл

@ -10,7 +10,9 @@ module.exports = require('knex')({
},
pool: {
min: 0,
max: parseInt(process.env.POSTGRES_MAX_CONNECTIONS_WEBHOOK_SERVICE) || 1
max: parseInt(process.env.POSTGRES_MAX_CONNECTIONS_WEBHOOK_SERVICE) || 1,
acquireTimeoutMillis: 16000, //allows for 3x creation attempts plus idle time between attempts
createTimeoutMillis: 5000
}
// migrations are in managed in the server package
})