M.S.Udhaya Raj
M.S.Udhaya Raj

Reputation: 150

Nodejs Knex -oracle concurrent call - table is locked

I am using Knex npm as my query builder. version 0.20.11. Node version is 12.16.1

Pool size

Min -3 Max -500

My services is do some long running process, do insert and updates more than 2 tables finally commit the transaction.

i give the concurrent call more than 150 to 200, to my service. The table is locked.service is hanged.Not able to give even a single thread after the table is locked.

i am using knex.transaction, i commit and destroyed my connection after end of the service.

pls suggest me how to solve this,if any one faced this kind of issues.

Note:Working fine in Minimum number of threads

Upvotes: 0

Views: 511

Answers (1)

Christopher Jones
Christopher Jones

Reputation: 10576

If you've increased the connection pool size, then increase UV_THREADPOOL_SIZE, see the node-oracledb documentation Connections, Threads, and Parallelism. As shown, make sure this is set before the Node.js threadpool starts. On Windows it must be set before Node.js itself is executed. So the best way is to set the value as an environment variable. For example, on Linux your package.json may have a script like:

"scripts": {
    "start": "export UV_THREADPOOL_SIZE=10 && node index.js"
  },
. . .

Or, on Windows:

"scripts": {
    "start": "SET UV_THREADPOOL_SIZE=10 && node index.js"
  },
. . .

Knex currently tries to set the value internally: this appears to be too late, and also won't work on Windows.

Also make sure you are closing connections after use, in all places including error routines.

Upvotes: 1

Related Questions