Skip to content

Fix SessionPool move constructor - #152

Open
chenshi5012 wants to merge 1 commit into
vesoft-inc:masterfrom
chenshi5012:fix/sessionpool-move-retains-idle-sessions
Open

chenshi5012 wants to merge 1 commit into
vesoft-inc:masterfrom
chenshi5012:fix/sessionpool-move-retains-idle-sessions

Conversation

@chenshi5012

Copy link
Copy Markdown

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number: #147

Description:

The SessionPool move constructor transfers the configuration and the underlying ConnectionPool, but does not transfer idleSessions_.

As a result, the moved-to pool has no idle sessions and requests can fail with No idle session.. Meanwhile, the moved-from pool retains Session wrappers that hold raw pointers to the underlying connection pool. If the moved-to pool is destroyed first, those pointers may become dangling, creating a potential use-after-free during destruction of the moved-from pool.

How do you solve it?

Move idleSessions_ along with the configuration and the underlying ConnectionPool in the SessionPool move constructor. This keeps the idle sessions with the pool that owns their connection pool and leaves the moved-from pool without those session wrappers.

Special notes for your reviewer, ex. impact of this fix, design document, etc:

  • Added the regression test SessionPoolTest.MoveConstructorTransfersIdleSessions.
  • The test initializes a one-slot pool, move-constructs a destination pool, executes YIELD 1 on the destination, and destroys the destination before the source.
  • The session_pool_test target built successfully, and the focused regression test passed.
  • No separate ASan run was performed to capture the potential use-after-free.

Fixes #147

@CLAassistant

CLAassistant commented Oct 15, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@chenshi5012
chenshi5012 force-pushed the fix/sessionpool-move-retains-idle-sessions branch from 4ccd969 to f8651c2 Compare October 15, 2026 01:52

This branch has not been deployed

No deployments
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.

[P1]SessionPool move constructor does not transfer idle sessions and can leave dangling pool references

2 participants