zhaojiandong commented on a change in pull request #6868: Fix deadlock in
DruidStatement & DruidConnection
URL: https://github.com/apache/incubator-druid/pull/6868#discussion_r248204737
##########
File path: sql/src/main/java/org/apache/druid/sql/avatica/DruidConnection.java
##########
@@ -63,7 +63,7 @@ public DruidConnection(final String connectionId, final int
maxStatements, final
this.connectionId = Preconditions.checkNotNull(connectionId);
this.maxStatements = maxStatements;
this.context = ImmutableMap.copyOf(context);
- this.statements = new HashMap<>();
+ this.statements = new ConcurrentHashMap<>();
Review comment:
> @zhaojiandong For clarity's sake, could you please change the type of the
field to ConcurrentMap, & a comment about why it's both `@GuardedBy` and
Concurrent?
>
> ```java
> // ConcurrentMap even though it is usually accessed synchronized, because
it's unsynchronized
> // in one case: the onClose function passed into DruidStatements contained
by the map. This is
> // done to avoid deadlocks; see
https://github.com/apache/incubator-druid/issues/6867.
> @GuardedBy("statements")
> private final ConcurrentMap<Integer, DruidStatement> statements;
> ```
How about use another sync flag: connectionLock, and statements 's type is
ConcurrentMap.
In this way GuardedBy check will passed. @gianm
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]