AndrewJSchofield commented on code in PR #24169:
URL: https://github.com/apache/kafka/pull/24169#discussion_r4573007204
##########
core/src/main/java/kafka/server/share/SharePartitionManager.java:
##########
Review Comment:
This method ought to provide the connection ID too I think so that we can do
the consistency check when a session is released, and the operations on the
cache should be synchronized so we don't introduce a new timing window.
##########
server/src/main/java/org/apache/kafka/server/share/session/ShareSessionCache.java:
##########
@@ -227,6 +227,17 @@ public synchronized void
registerShareGroupListener(ShareGroupListener shareGrou
this.shareGroupListener = shareGroupListener;
}
+ /**
+ * Get the key of the share session that the client connection was last
used for.
+ *
+ * @param connectionId The client connection id.
+ * @return The share session key, or null if the connection has not been
used for a share session.
+ */
+ public synchronized ShareSessionKey connectionShareSessionKey(String
connectionId) {
+ SessionKeyAndState sessionKeyAndState =
connectionIdToSessionMap.get(connectionId);
+ return sessionKeyAndState == null ? null :
sessionKeyAndState.shareSessionKey();
Review Comment:
Should this not also take account of staleness?
```
return sessionKeyAndState == null || sessionKeyAndState.stale() ? null :
sessionKeyAndState.shareSessionKey();
```
It should be possible for a connection to close its share session and have
another connection use that share session key subsequently (which could be a
reconnect from the same client if there's a network drop).
--
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]