You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "adixitconfluent (via GitHub)" <gi...@apache.org> on 2025/12/03 12:50:38 UTC
Re: [PR] KAFKA-19950: Mark session stale when removed prior disconnection event [kafka]
adixitconfluent commented on code in PR #21062:
URL: https://github.com/apache/kafka/pull/21062#discussion_r2584990456
##########
server/src/main/java/org/apache/kafka/server/share/session/ShareSessionCache.java:
##########
@@ -172,6 +169,17 @@ public synchronized ShareSession remove(ShareSession session) {
if (removeResult != null) {
numPartitions = numPartitions - session.cachedSize();
numMembersPerGroup.compute(session.key().groupId(), (k, v) -> v != null ? v - 1 : 0);
+ // Mark the session as stale in the connectionIdToSessionMap to avoid removing
+ // the active session for the client. When client re-sends the initial epoch where the
+ // broker removes the prior session and establishes new session, then sometimes the connection
+ // id is changed. This leads to removal of the new session from the cache, when old connection
+ // disconnect event is processed. Marking the old connection as stale avoids this issue.
+ // If the connection id remains same for both old and new session, then the subsequent call
+ // for session creation will overwrite the prior stale mapping in the connectionIdToSessionMap.
Review Comment:
this comment is confusing to me. If the connection id remains same for both old and new session, it will be the same session, not different.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org