gabriellefu commented on code in PR #23184:
URL: https://github.com/apache/kafka/pull/23184#discussion_r3832966589


##########
streams/src/main/java/org/apache/kafka/streams/state/internals/StoreQueryUtils.java:
##########
@@ -128,29 +128,33 @@ public static <R> QueryResult<R> handleBasicQueries(
         final QueryResult<R> result;
 
         final QueryHandler<?> handler = 
QUERY_HANDLER_MAP.get(query.getClass());
-        synchronized (position) {
-            if (handler == null) {
-                result = QueryResult.forUnknownQueryType(query, store);
-            } else if (context == null || !isPermitted(position, 
positionBound, context.taskId().partition())) {
-                result = QueryResult.notUpToBound(
-                    position,
-                    positionBound,
-                    context == null ? null : context.taskId().partition()
-                );
-            } else {
-                result = ((QueryHandler<R>) handler).apply(
-                    query,
-                    positionBound,
-                    config,
-                    store
-                );
-            }
-            if (config.isCollectExecutionInfo()) {
-                result.addExecutionInfo(
-                    "Handled in " + store.getClass() + " in " + 
(System.nanoTime() - start) + "ns"
-                );
+        // Lock order must match the write paths (store monitor, then 
position),
+        // otherwise concurrent put/query can deadlock (KAFKA-19629).
+        synchronized (store) {

Review Comment:
   ❯ in restore, I changed the lock order to put first, which get the order of 
store then position, then we realease the two lock and only get the position 
lock, in this case, there won't be a deadlock                             



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to