Skip to content

Fix Session move assignment ownership - #153

Open
chenshi5012 wants to merge 1 commit into
vesoft-inc:masterfrom
chenshi5012:fix/session-move-assignment-transfers-ownership
Open

chenshi5012 wants to merge 1 commit into
vesoft-inc:masterfrom
chenshi5012:fix/session-move-assignment-transfers-ownership

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: #148

Description:

Session::operator=(Session&& ) currently transfers the session ID and some metadata, but does not release the destination's existing session or transfer the source connection and owning-pool pointer.

This can leave the destination with a session ID that does not match its connection or pool. The source connection may not be returned to its original pool, and the destination's connection may be returned to the wrong pool when the session is destroyed.

How do you solve it?

Release the destination's current session before assigning the new one. Then transfer the source session's ID, connection, owning pool, and related state, including reconnect settings and the broken-connection flag.

Leave the source in a safe moved-from state, and handle self-move assignment without changing the object.

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

  • Added the regression test SessionTest.MoveAssignmentReturnsConnectionsToOwningPools.
  • The test obtains sessions from two separate connection pools, move-assigns one session to the other, and verifies that each pool receives its connection back after the sessions are destroyed.
  • The session_test target built successfully, and the focused regression test passed.

Fixes #148

@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/session-move-assignment-transfers-ownership branch from 20ad301 to f6b680d 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.

[p2]Session move assignment transfers the ID but not the connection or owning pool

2 participants