knex transaction Timeout.
Expected behaviour
We shouldnt get any timeout Errors.
Current behaviour
As we can see from the logs below . We get a lot of KnexTimeoutError.
72]: 2023-08-22T23:37:30.280Z - error: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: {
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: error: {
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: name: 'KnexTimeoutError',
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: sql: undefined,
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: bindings: undefined,
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: originalStack: 'KnexTimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?\n' +
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: ' at Client_PG.acquireConnection (/home/node/app/node_modules/knex/lib/client.js:348:26)\n' +
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: ' at runNextTicks (node:internal/process/task_queues:61:5)\n' +
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: ' at listOnTimeout (node:internal/timers:528:9)\n' +
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: ' at processTimers (node:internal/timers:502:7)\n' +
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: ' at async QueryBuilder.execute (/home/node/app/node_modules/objection/lib/queryBuilder/QueryBuilder.js:667:22)\n' +
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: ' at async Function.find (/home/node/app/node_modules/@pubsweet/model-user/node_modules/@pubsweet/base-model/src/index.js:212:20)\n' +
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: ' at async middleware (/home/node/app/node_modules/graphql-shield/dist/generator.js:30:24)'
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: }
Aug 22 23:37:30 ncbi-coko a44ff1563f77[1172]: }
Steps to reproduce
This is difficult to reproduce. We don't know yet which transaction causes the problem.
Possible solution
At the moment we have enable logs for all the queries from Knex. And waiting to happen again in order to check which query (transaction) causing the error.
Acceptance Criteria
-
Transactions are successful and don't time out -
KnexTimeoutError resolved, therefore no longer reported in logs