[
https://issues.apache.org/jira/browse/TINKERPOP-2135?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Florian Hockmann updated TINKERPOP-2135:
----------------------------------------
Description:
The {{ConnectionPool}} of Gremlin.Net checks whether a connection is actually
still open before it returns that connection to execute a request ([in
{{SelectLeastUsedConnection}}|https://github.com/apache/tinkerpop/blob/67764ba23d67d9f62048c22e8bbcefb87463584e/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs#L124]):
{code:java}
if (connection.IsOpen) return true;
DefinitelyDestroyConnection(connection);
{code}
However, the connection stays in the pool as {{DefinitelyDestroyConnection}}
only disposes the connection:
{code:java}
private void DefinitelyDestroyConnection(Connection connection)
{
connection.Dispose();
Interlocked.Decrement(ref _nrConnections);
}
{code}
This is problematic as it can potentially fill the pool with unusable
connections. Even worse, {{SelectLeastUsedConnection}} will likely return such
an unusable connection since it only checks for the number of in-flight
requests and a disposed connection won't have any in-flight requests. This
means that {{GetConnectionFromPool}} will try to get a connection until another
still valid connection also has no in-flight requests.
Note: This all can only happen when a connection was closed while sitting idle
in the pool which shouldn't usually happen due to the heartbeat. If a
connection problem occurs during the execution of a request, then all
connections will be closed and new ones will be created.
was:
The {{ConnectionPool}} of Gremlin.Net checks whether a connection is actually
still open before it returns that connection to execute a request ([in
{{SelectLeastUsedConnection}}|https://github.com/apache/tinkerpop/blob/67764ba23d67d9f62048c22e8bbcefb87463584e/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs#L124]):
{code}
if (connection.IsOpen) return true;
DefinitelyDestroyConnection(connection);
{code}
However, the connection stays in the pool as {{DefinitelyDestroyConnection}}
only disposes the connection:
{code}
private void DefinitelyDestroyConnection(Connection connection)
{
connection.Dispose();
Interlocked.Decrement(ref _nrConnections);
}
{code}
This is problematic as it can potentially fill the pool with unusable
connections. Even worse, {{SelectLeastUsedConnection}} will likely return such
an unusable connection since it only checks for the number of in-flight
requests and a disposed connection won't have any in-flight requests. This
should ultimately result in a {{NoConnectionAvailableException}} when the pool
tried {{_poolSize}} times to return such a disposed connection.
Note: This all can only happen when a connection was closed while sitting idle
in the pool which shouldn't usually happen due to the heartbeat. If a
connection problem occurs during the execution of a request, then all
connections will be closed and new ones will be created.
> Gremlin.Net ConnectionPool doesn't handle closed idle connections properly
> --------------------------------------------------------------------------
>
> Key: TINKERPOP-2135
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2135
> Project: TinkerPop
> Issue Type: Bug
> Affects Versions: 3.4.0
> Reporter: Florian Hockmann
> Priority: Major
>
> The {{ConnectionPool}} of Gremlin.Net checks whether a connection is actually
> still open before it returns that connection to execute a request ([in
> {{SelectLeastUsedConnection}}|https://github.com/apache/tinkerpop/blob/67764ba23d67d9f62048c22e8bbcefb87463584e/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs#L124]):
> {code:java}
> if (connection.IsOpen) return true;
> DefinitelyDestroyConnection(connection);
> {code}
> However, the connection stays in the pool as {{DefinitelyDestroyConnection}}
> only disposes the connection:
> {code:java}
> private void DefinitelyDestroyConnection(Connection connection)
> {
> connection.Dispose();
> Interlocked.Decrement(ref _nrConnections);
> }
> {code}
> This is problematic as it can potentially fill the pool with unusable
> connections. Even worse, {{SelectLeastUsedConnection}} will likely return
> such an unusable connection since it only checks for the number of in-flight
> requests and a disposed connection won't have any in-flight requests. This
> means that {{GetConnectionFromPool}} will try to get a connection until
> another still valid connection also has no in-flight requests.
> Note: This all can only happen when a connection was closed while sitting
> idle in the pool which shouldn't usually happen due to the heartbeat. If a
> connection problem occurs during the execution of a request, then all
> connections will be closed and new ones will be created.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)