Skip to content

fix: Corrected algorithm that releases stale sessions in the pool#156

Merged
dazuma merged 1 commit into
googleapis:mainfrom
dazuma:pr/keepalive
Mar 24, 2025
Merged

fix: Corrected algorithm that releases stale sessions in the pool#156
dazuma merged 1 commit into
googleapis:mainfrom
dazuma:pr/keepalive

Conversation

@dazuma

@dazuma dazuma commented Mar 19, 2025

Copy link
Copy Markdown
Contributor

This seems like a bad bug that releases stale sessions incorrectly: instead of releasing stale sessions down to the min level (as I assume we're supposed to), it releases more sessions if the number is below the min, but never releases sessions if the number is above the min. Fixed and added tests.

@dazuma dazuma requested review from a team March 19, 2025 18:09
@dazuma dazuma force-pushed the pr/keepalive branch 2 times, most recently from ca93102 to 566f03b Compare March 19, 2025 18:40
@dazuma dazuma added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 19, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 19, 2025
@viacheslav-rostovtsev

Copy link
Copy Markdown
Member

Yes, this looks like a nasty one. Good catch!

@viacheslav-rostovtsev viacheslav-rostovtsev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@viacheslav-rostovtsev

Copy link
Copy Markdown
Member

One thing that will happen with the fixed code is that if a lot of sessions go inactive they will all get sent for release in one go, wrapped in individual futures. These will all be concurrent server requests to delete_session, causing a spike. The futures as far as I can tell will also swallow all potential errors.

Monitoring the futures is probably a backlog candidate for volume of work reasons, but do we perhaps want to stagger the releases?

@dazuma

dazuma commented Mar 21, 2025

Copy link
Copy Markdown
Contributor Author

Monitoring the futures is probably a backlog candidate for volume of work reasons, but do we perhaps want to stagger the releases?

That is an interesting thought. There are things we could do. For example, we can limit the number of sessions to release at a time, to a certain max. Then that many sessions would be released, and the next batch would be done the next time the session keepalive timer ticks (every 5 minutes currently), and so forth. However, before we take a step like that, I'd want some evidence that a "spike" of session releases is an actual problem (and also, some quantitative idea of what limits we should be placing). These are questions that go well beyond this fix.

@dazuma dazuma merged commit 2718042 into googleapis:main Mar 24, 2025
@dazuma dazuma deleted the pr/keepalive branch August 11, 2025 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants