nodejs-spanner: spanner: Root cause of "Error: Unable to release unknown resource"
From Getting “Error: Unable to release unknown resource.\n at SessionPool.release”:
I am using GCP spanner as my project RDBMS . Lately I am getting a lot of error like the one mentioned above in the logs. Can someone help me figure out what is going wrong here ?
I tried going through google docs, but found very little on the above error . Is it something related to session pool configuration ? How this can be resolved ?
Note: I have only 1 spanner db, which is running on 1 instance on GCP.
Any help is deeply appreciated 😃
Thanks
Error: Got unhandled rejection {"stack":"Error: Unable to release unknown resource.\n at SessionPool.release (/testProject/node_modules/@google-cloud/spanner/build/src/session-pool.js:241:19)\n at <anonymous>\n at process._tickCallback (internal/process/next_tick.js:189:7)","message":"Unable to release unknown resource.","resource":{}}
at process.on (/testProject/index.js:22:17)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 24 (13 by maintainers)
Hi @olavloite @hengfengli
Thanks for the suggestion. I will give this a try and test the same in the staging environment. Will keep you guys updated about the same
Thanks
Hi @codemart786
If I understand you correctly, you are (sort of) able to reproduce this problem on your staging environment, right? If so, would it be possible for you to try the following:
max=100
fail=true
(This setting will cause the session pool to throw an error instead of waiting indefinitely when the maximum number of sessions in the pool has been reached. You should therefore be careful with enabling this setting on your production environment, as these errors could bubble up to the users.)If you could then inspect the stacktraces (
messages
) that are included in theSessionPoolExhaustedError
, it should be possible to determine whether the problem is caused by a session leak or not, and when it is, what part of the code is causing it.@AVaksman @skuruppu @callmehiphop @mf2199
Hey guys, few things I want to ask here, related to this issue .
We did load testing in our staging environment, and have seen session count increasing from 3k to 100k within 30 mins. We have an api which uses spanner locking read-write transaction. We are calling
transaction.end()
function also. I believe this is a session-leak problem, but could’t understand why. We use rps of 4000 for 30 minutes on one of service apis.Having said that, here are my some of doubts which I would like to clarify:
Do I need to call
transaction.end()
even after successful commit of transaction? Right now I am not doing that . I am callingtransaction.end()
only if commit operation throws an error or if we decided to forego commit due to some reason . I believe on successful commit,transaction.end()
is called to release the session back to the pool, by the spanner module itself. (Please correct me if I am wrong here)We added the code snippet as suggested by @callmehiphop on database.close(), before pod shuts-down . The error which we see in the logs is given below:
Please help me know when the @google-cloud/spanner node module throws this stack trace? If I know in which direction to proceed further, it would be very helpful.
PS: Our application has suffered several production outages, which I believe is mostly due to this issue. Please help me in solving this issue. Any help is deeply appreciated 😃
Thanks