cockroachdb / cockroachdb/cockroach
sql.closed_session_cache.time_to_live default of 3600 seconds not respected
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
[sql.closed_session_cache.time_to_live](http://127.0.0.1:4000/docs/v23.1/cluster-settings.html#setting-sql-closed-session-cache-time-to-live) is the maximum time to live, in seconds, and defaults to 3600.
Therefore, the closed session details should be kept for 60 minutes after a session is closed before it is deleted from the cache.
This is assuming that the limit set by [sql.closed_session_cache.capacity](http://127.0.0.1:4000/docs/v23.1/cluster-settings.html#setting-sql-closed-session-cache-capacity) (the maximum number of sessions in the cache which defaults to 1000) is not reached.
With very few closed sessions, the closed session details are unavailable after only 10 minutes.
**To Reproduce**
1. Set up a CockroachDB 23.1.2 cluster.
```
cockroach start-single-node --http-addr=localhost:8080 --listen-addr=localhost:36257 --sql-addr=localhost:26257 --insecure --background
```
2. Connect to the cluster in a sql shell:
```
cockroach sql --insecure --port=26257
```
3. In the DB Console, open the SQL Activity > Sessions page and click on your idle session to open the Session Details page. Note the url with the session ID, such as:
```
http://localhost:8080/#/session/179c385d-d38b-c398-0000-000000000001
```
4. In the sql shell, exit with `\q`.
5. In the DB Console, refresh the Sessions Details page. Status should now be `Closed`. Note the Session End Time.
6. Wait 10 minutes.
7. In the DB Console, refresh the Sessions Details page again.
8. See message: `Unable to find session`
**Expected behavior**
After 60 minutes, you see message: `Unable to find session`
**Environment:**
- CockroachDB version 23.1.12
- Server OS: Mac, but also observed on Dedicated AWS Cluster
- Client app `cockroach sql`
Jira issue: CRDB-33969
Contributor guide
Assessment
This issue has not been assessed yet.