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


##########
streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBStore.java:
##########
@@ -536,21 +536,25 @@ public <R> QueryResult<R> query(
         final PositionBound positionBound,
         final QueryConfig config) {
 
-        synchronized (position) {
-            final Position queryPosition;
-            if (config.getIsolationLevel() == IsolationLevel.READ_COMMITTED) {
-                queryPosition = position;
-            } else {
-                queryPosition = 
position.copy().merge(dbAccessor.uncommittedPositionDeltas());
+        // Lock order must match the write paths (store monitor, then 
position),
+        // otherwise concurrent put/query can deadlock (KAFKA-19629).
+        synchronized (this) {

Review Comment:
   The RocksDB test was dropped in `remove the redundant tests`, but I don't 
think it's redundant — it's actually the one most worth keeping:
   
   - KAFKA-19629 is a RocksDB deadlock, so this is the store where the reported 
repro actually happens.
   - `RocksDBStore#query` uses a fix distinct from the other stores: it 
snapshots the position and *releases* the lock before calling 
`handleBasicQueries`. The remaining tests (`InMemoryKeyValueStore`, 
`InMemoryLRUCache`) exercise the nested `store -> position` approach instead, 
so neither one runs this code path. If someone later widens the `synchronized` 
scope back over `handleBasicQueries`, only a RocksDB test would catch the 
regression.



-- 
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