Repository navigation
Return SessionPool sessions after JSON errors - #151
Open
chenshi5012 wants to merge 1 commit into
Open
chenshi5012 wants to merge 1 commit into
chenshi5012 wants to merge 1 commit into
Conversation
chenshi5012
force-pushed
the
fix/json-exception-returns-session
branch
from
October 15, 2026 01:52
ba6dc1d to
8713bbc
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What type of PR is this?
What problem(s) does this PR solve?
Issue(s) number: #149
Description:
When a low-level JSON request fails,
Connectioncan return an empty string.SessionPool::executeJsonWithParameter( )then callsfolly::parseJson()unconditionally. If parsing throws, the normalgiveBack()path is skipped. Although the localSessionmay return its underlying connection toConnectionPoolduring destruction, theSessionwrapper is not returned toSessionPool::idleSessions_, permanently consuming a pool slot.With a small pool, or after repeated failures, subsequent requests can fail with
No idle session.How do you solve it?
Return the acquired
SessiontoSessionPoolin the exception path before rethrowing the original exception. The normal success path continues to return the session as before.This ensures that a failed JSON request or a JSON parsing exception does not permanently reduce the number of available session slots.
Special notes for your reviewer, ex. impact of this fix, design document, etc:
SessionPoolTest.JsonParseFailureReturnsSessionToPool. It closes the underlying connection to deterministically produce an empty JSON response, verifies that parsing throws, and checks that the session slot remains available afterward.session_pool_testCTest target passed.Fixes #149