gabriellefu commented on code in PR #23184:
URL: https://github.com/apache/kafka/pull/23184#discussion_r3816785018
##########
streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:
##########
@@ -476,25 +476,29 @@ public <R> QueryResult<R> query(final Query<R> query,
final PositionBound positionBound,
final QueryConfig config) {
- synchronized (position) {
- // Mirror RocksDBStore#query: under READ_UNCOMMITTED, expose the
writes staged in the
- // transaction buffer since the last commit by merging the
buffer's pending position
- // deltas into a copy of the committed position. READ_COMMITTED
(and the
- // non-transactional store) query the committed position directly.
- final Position queryPosition;
- if (transactionBuffer != null && config.getIsolationLevel() ==
IsolationLevel.READ_UNCOMMITTED) {
- queryPosition =
position.copy().merge(transactionBuffer.pendingPosition());
- } else {
- queryPosition = position;
+ // Lock order must match the write paths (store monitor, then
position),
+ // otherwise concurrent put/query can deadlock (KAFKA-19629).
+ synchronized (this) {
Review Comment:
I have updated here, with hold the position store before using return
StoreQueryUtils.handleBasicQueries, then in StoreQueryUtils.handleBasicQueries,
it will do the order of holding store then lock, which match with the order of
put.
--
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]