Skip to content

Conversation

@pratapnarra
Copy link

@pratapnarra pratapnarra commented Oct 30, 2025

This PR aims to reduce the overhead of creating a new connection and closing it for every transaction using SessionedClient in DriverRemoteConnection. Instead the existing Client object in DriverRemoteConnection is tied to the new SessionedChildClient as a parent, and this SessionedChildClient borrows the connection from the parent Client's pool for transactions instead of creating a new Connection.

https://issues.apache.org/jira/browse/TINKERPOP-3213

@codecov-commenter
Copy link

codecov-commenter commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 67.74194% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.44%. Comparing base (9b46b67) to head (b918d52).
⚠️ Report is 390 commits behind head on 3.7-dev.

Files with missing lines Patch % Lines
...va/org/apache/tinkerpop/gremlin/driver/Client.java 68.00% 7 Missing and 1 partial ⚠️
.../gremlin/driver/remote/DriverRemoteConnection.java 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             3.7-dev    #3258      +/-   ##
=============================================
+ Coverage      76.14%   76.44%   +0.29%     
- Complexity     13152    13300     +148     
=============================================
  Files           1084     1092       +8     
  Lines          65160    67069    +1909     
  Branches        7285     7381      +96     
=============================================
+ Hits           49616    51270    +1654     
- Misses         12839    13051     +212     
- Partials        2705     2748      +43     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@Cole-Greer Cole-Greer left a comment

Choose a reason for hiding this comment

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

I don't have any major concerns with the changes here. It appears that the existing tests in GremlinServerSessionIntegrateTest are giving reasonable coverage to the new SessionedChildClient. Would you mind elaborating a bit more in the PR description as to the exact problem you're aiming to solve? Is it simply to reduce connection creation overhead in use cases which involve many short lived sessions?

}

@Override
protected synchronized Connection chooseConnection(RequestMessage msg) throws TimeoutException, ConnectionException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

Suggested change
protected synchronized Connection chooseConnection(RequestMessage msg) throws TimeoutException, ConnectionException {
protected synchronized Connection chooseConnection(final RequestMessage msg) throws TimeoutException, ConnectionException {

Copy link
Author

Choose a reason for hiding this comment

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

Yes that's the overhead we are trying to reduce. I have updated the PR description as well.

@kenhuuu kenhuuu changed the title Added a new SessionedChildClient which reuses connection from parent … TINKERPOP-3213 Added a new SessionedChildClient which reuses connection from parent … Nov 4, 2025
* bindings across requests.
* Transaction are not automatically committed. It is up the client to issue commit/rollback commands.
*/
public final static class SessionedChildClient extends Client {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would have been best if there was a solution that kept this class package-private, as it now differs from the other Clients that are only supposed to be exposed via Cluster. It's fine for this PR, but I'd probably recommend adding a Jira to look into this again in the future after this is merged.


public SessionedChildClient(final Client parentClient, String sessionId) {
super(parentClient.cluster, parentClient.settings);
this.parentClient = parentClient;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense for any type of Client to be the parent? SessionedClient only allows for one connection so maybe there should be a check here that disallows that particular client?

this.maintainStateAfterException = parentClient.settings.getSession().map(s -> s.maintainStateAfterException).orElse(false);
}

public String getSessionId() {
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

4 participants