jdeppe-pivotal commented on a change in pull request #5420:
URL: https://github.com/apache/geode/pull/5420#discussion_r468997420



##########
File path: 
geode-redis/src/main/java/org/apache/geode/redis/internal/netty/ExecutionHandlerContext.java
##########
@@ -138,6 +161,25 @@ public void exceptionCaught(ChannelHandlerContext ctx, 
Throwable cause) {
     writeToChannel(getExceptionResponse(ctx, cause));
   }
 
+  public EventLoopGroup getSubscriberGroup() {
+    return subscriberGroup;
+  }
+
+  public synchronized void changeChannelEventLoopGroup(EventLoopGroup 
newGroup, Runnable callback) {
+    if (newGroup.equals(channel.eventLoop())) {
+      // already registered with newGroup
+      return;
+    }
+    channel.deregister().addListener((ChannelFutureListener) future -> {
+      synchronized (channel) {

Review comment:
       Without the synchronization I believe that errors like the following 
appear:
   ```
   [vm1] [warn 2020/08/11 21:54:29.557 GMT 
<GeodeRedisServer-SubscriberThread-3> tid=0x2ab] A task raised an 
exception. Task: io.netty.channel.AbstractChannel$AbstractUnsafe$1@47045f4d
   [vm1] java.lang.AssertionError
   [vm1]        at 
io.netty.channel.AbstractChannel$AbstractUnsafe.assertEventLoop(AbstractChannel.java:426)
   [vm1]        at 
io.netty.channel.AbstractChannel$AbstractUnsafe.closeForcibly(AbstractChannel.java:774)
   [vm1]        at 
io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:521)
   [vm1]        at 
io.netty.channel.AbstractChannel$AbstractUnsafe.access$200(AbstractChannel.java:417)
   [vm1]        at 
io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:474)
   [vm1]        at 
io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
   [vm1]        at 
io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
   [vm1]        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
   [vm1]        at 
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
   [vm1]        at 
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
   [vm1]        at java.base/java.lang.Thread.run(Thread.java:834)
   ```




----------------------------------------------------------------
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.

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


Reply via email to