Spanner sessions keep increasing
See original GitHub issueOur Spanner Sessions keep increasing until we restart the pods (we create a new database object on pod initialize). https://github.com/googleapis/google-cloud-node
We don’t see any impact on the pods’ memory and CPU. It looks like the only impact is on the max latency of the query-by-id and query-by-column
Environment details
- OS: alpine
- Node.js version: node:14
- npm version: 6.14.13
@google-cloud/spanner
version: 5.9.0
Steps to reproduce
We create a single database instance and we use that database for all queries and transactions. (please advise if that’s the right approach).
const queryOptions = { optimizerVersion: 'latest' };
this.db = instance.database(databaseId, undefined, queryOptions);
Issue Analytics
- State:
- Created 2 years ago
- Comments:24 (15 by maintainers)
Top Results From Across the Web
Sessions | Cloud Spanner
One scenario for keeping sessions alive is to handle regular peak demand on the database. If heavy database use occurs daily from 9:00...
Read more >Spanner session count growing well beyond limit #184 - GitHub
I understand that doing 50% write sessions is overly-aggressive however I keep seeing this go over what I view as the theoretical session...
Read more >Does not Cloud Spanner manage sessions properly?
Google Cloud Spanner client libraries handles sessions automatically and its limit is 10.000 sessions for each node, no problem till here.
Read more >Troubleshooting Cloud Spanner Applications with OpenCensus
Sessions are a central concept in the Cloud Spanner API. ... the value is reset to zero (and then starts increasing again).
Read more >Getting started with Cloud Spanner Client Libraries & ORMs
While you can use Google Cloud APIs by making direct HTTP requests to the server (or RPC calls where available), Cloud Spanner provides ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@skuruppu Thanks for the follow-up. Unfortunately, we haven’t deployed that to prod yet. But our stage environment looks much better. I will post here after I get some data from prod.
@daneshka
That is indeed not a high number, unless those 33602 queries are all executed within a very short fraction of one hour (see below).
I don’t think you should increase the number of pods or number of database instances in each pod based on what we are seeing here. The only configuration change that I think you should consider, is increasing the max number of sessions in the session pool for the databases instances that you are using. That would mean instantiating the database instances with something like this:
The
database.run(query)
statement should not cause any session leaks, so I really don’t think that is the real problem (unless the query is taking a long time to finish, which the above information indicates that it does not).One possibility in this case could be that the query that you are seeing is one that comes in bursts. I noticed that the table that is being queried is called
reminders
. If that query for example is coming from some timed (background) task, and very many instances of that task can be executed at the same time, then that could be the trigger for the problem (and also the reason that you are seeing this query many times in the error message). So that could mean that: