chia7712 commented on code in PR #19500:
URL: https://github.com/apache/kafka/pull/19500#discussion_r2052293842


##########
server/src/main/java/org/apache/kafka/server/share/session/ShareSessionCache.java:
##########
@@ -122,15 +113,9 @@ public synchronized ShareSession remove(ShareSession 
session) {
      * Update a session's position in the lastUsed tree.
      *
      * @param session  The session.
-     * @param now      The current time in milliseconds.
      */
-    public synchronized void touch(ShareSession session, long now) {
+    public synchronized void updateNumPartitions(ShareSession session) {
         synchronized (session) {

Review Comment:
   > There is a read and update to the session
   
   You are right. Maybe we can add a specific method to handle the case to 
ensure the atomicity? for example:
   
   `ShareSession`
   ```java
       public synchronized int updateCachedSize() {
           var previousSize = cachedSize;
           cachedSize = partitionMap.size();
           return previousSize != -1 ? cachedSize - previousSize : cachedSize;
       }
   ```
   
   `ShareSessionCache`
   ```java
       public synchronized void updateNumPartitions(ShareSession session) {
           numPartitions += session.updateCachedSize();
       }
   ```



-- 
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-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to