This is an automated email from the ASF dual-hosted git repository.

SteNicholas pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/celeborn.git


The following commit(s) were added to refs/heads/main by this push:
     new 59413d040f [CELEBORN-2385] Guard ByteBufAllocator cast in 
ChannelsLimiter trim path
59413d040f is described below

commit 59413d040f7e9a6c6145ce13ced3e1707058682f
Author: sychen <[email protected]>
AuthorDate: Thu Jul 23 10:12:19 2026 +0800

    [CELEBORN-2385] Guard ByteBufAllocator cast in ChannelsLimiter trim path
    
    ### What changes were proposed in this pull request?
    
    `ChannelsLimiter#userEventTriggered` unconditionally casts `ctx.alloc()` to
    `PooledByteBufAllocator` when handling a `TrimCache` event:
    
    ```java
    ((PooledByteBufAllocator) ctx.alloc()).trimCurrentThreadCache();
    ```
    
    The concrete type of ctx.alloc() is determined by
    celeborn.network.memory.allocator.pooled. When it is set to false (the
    documented escape hatch for workers whose direct memory stays high even 
after
    trimming), the allocator is an UnpooledByteBufAllocator, so this cast 
throws a
    ClassCastException on the Netty EventLoop thread the next time memory 
pressure
    triggers MemoryManager#trimAllListeners → ChannelsLimiter#onTrim →
    trimCache().
    
    ### Why are the changes needed?
    
    ### Does this PR resolve a correctness bug?
    
    - [ ] Yes
    
    ### Does this PR introduce _any_ user-facing change?
    
    - [ ] Yes
    
    ### How was this patch tested?
    
    Closes #3763 from cxzl25/CELEBORN-2385.
    
    Authored-by: sychen <[email protected]>
    Signed-off-by: Nicholas Jiang <[email protected]>
---
 .../apache/celeborn/service/deploy/worker/memory/ChannelsLimiter.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/worker/src/main/java/org/apache/celeborn/service/deploy/worker/memory/ChannelsLimiter.java
 
b/worker/src/main/java/org/apache/celeborn/service/deploy/worker/memory/ChannelsLimiter.java
index 1d633d1055..24a3c6b2e2 100644
--- 
a/worker/src/main/java/org/apache/celeborn/service/deploy/worker/memory/ChannelsLimiter.java
+++ 
b/worker/src/main/java/org/apache/celeborn/service/deploy/worker/memory/ChannelsLimiter.java
@@ -122,7 +122,9 @@ public class ChannelsLimiter extends ChannelDuplexHandler
   @Override
   public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
     if (evt instanceof TrimCache) {
-      ((PooledByteBufAllocator) ctx.alloc()).trimCurrentThreadCache();
+      if (ctx.alloc() instanceof PooledByteBufAllocator) {
+        ((PooledByteBufAllocator) ctx.alloc()).trimCurrentThreadCache();
+      }
       needTrimChannels.decrementAndGet();
     }
   }

Reply via email to