feat: Add PingingPool check on session age #1069
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1068
Implemented the first proposed solution mentioned in issue #1068 .
Details
_new_session
inPingingPool
to add a timestamp_created_at
on the newly created session.PingingPool.get()
to check whether the session is older than 28 days old using the_created_at
we added. If so, we go ahead and check the existence of the sessionNotes/concerns:
1.1.) If sessions may not be deleted, would it be better to just go ahead and replace old session with a new one instead of possibly checking the existence each time it is used to avoid latency?
ping
because:a) We will have to iterate over all sessions to check their
_created_at
(since the one on top of the pool might not necessarily be the oldest in terms of age)b) Or we will check the
_created_at
of the least recently used session only. Which fixes the issue for the lru session but doesn't help for other sessions if the lru session is fresh and the pinging loop breaks early.c) We already check for session age at the time of
get
, so the client won't receive dead sessions (atleast the ones deleted for this reason). And it is such an infrequent case (once a month), So it shouldn't add latency on most requests.