You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/10/07 23:56:36 UTC

[GitHub] [geode] bschuchardt opened a new pull request #5605: GEODE-8584: Message transmission fails with IllegalStateException in socket i/o code

bschuchardt opened a new pull request #5605:
URL: https://github.com/apache/geode/pull/5605


   Add appropriate synchronization when using ioFilter's buffers.
   to do: add testing
   to do: document the need for synchronization in the NioFilter interface.
   
   Thank you for submitting a contribution to Apache Geode.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically `develop`)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   - [ ] Does `gradlew build` run cleanly?
   
   - [ ] Have you written or updated unit tests to verify your changes?
   
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   
   ### Note:
   Please ensure that once the PR is submitted, check Concourse for build issues and
   submit an update to your PR as soon as possible. If you need help, please send an
   email to dev@geode.apache.org.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] agingade commented on a change in pull request #5605: GEODE-8584: Message transmission fails with IllegalStateException in socket i/o code

Posted by GitBox <gi...@apache.org>.
agingade commented on a change in pull request #5605:
URL: https://github.com/apache/geode/pull/5605#discussion_r501818461



##########
File path: geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java
##########
@@ -2588,17 +2592,20 @@ void writeFully(SocketChannel channel, ByteBuffer buffer, boolean forceAsync,
           }
           // fall through
         }
-        ByteBuffer wrappedBuffer = ioFilter.wrap(buffer);
-        while (wrappedBuffer.remaining() > 0) {
-          int amtWritten = 0;
-          long start = stats.startSocketWrite(true);
-          try {
-            amtWritten = channel.write(wrappedBuffer);
-          } finally {
-            stats.endSocketWrite(true, start, amtWritten, 0);
+        // synchronize on the ioFilter while using its network buffer
+        synchronized (ioFilter) {
+          ByteBuffer wrappedBuffer = ioFilter.wrap(buffer);
+          while (wrappedBuffer.remaining() > 0) {
+            int amtWritten = 0;
+            long start = stats.startSocketWrite(true);
+            try {
+              amtWritten = channel.write(wrappedBuffer);

Review comment:
       Is there anything that needs to be done, if write throws exception...Sorry I may be asking wrong question as I don't have much context here.

##########
File path: geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
##########
@@ -396,9 +402,17 @@ public synchronized void close(SocketChannel socketChannel) {
     } catch (IOException e) {
       throw new GemFireIOException("exception closing SSL session", e);
     } finally {
-      bufferPool.releaseBuffer(TRACKED_SENDER, myNetData);
-      bufferPool.releaseBuffer(TRACKED_RECEIVER, peerAppData);
+      logger.info("NioSSLEngine releasing two buffers myNetData={}({}), peerAppData={}({})",

Review comment:
       This should be info or debug level log? just checking...




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] Bill commented on a change in pull request #5605: GEODE-8584: Message transmission fails with IllegalStateException in socket i/o code

Posted by GitBox <gi...@apache.org>.
Bill commented on a change in pull request #5605:
URL: https://github.com/apache/geode/pull/5605#discussion_r501922128



##########
File path: geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
##########
@@ -52,6 +53,11 @@
 public class NioSslEngine implements NioFilter {
   private static final Logger logger = LogService.getLogger();
 
+  // this variable requires the MakeImmutable annotation but the buffer is empty and
+  // not really modifiable
+  @MakeImmutable
+  private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate(0);

Review comment:
       That won't satisfy PMD (since it returns a `ByteBuffer` which is not considered an immutable object by PMD) but it still might be valuable.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] bschuchardt merged pull request #5605: GEODE-8584: Message transmission fails with IllegalStateException in socket i/o code

Posted by GitBox <gi...@apache.org>.
bschuchardt merged pull request #5605:
URL: https://github.com/apache/geode/pull/5605


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] dschneider-pivotal commented on a change in pull request #5605: GEODE-8584: Message transmission fails with IllegalStateException in socket i/o code

Posted by GitBox <gi...@apache.org>.
dschneider-pivotal commented on a change in pull request #5605:
URL: https://github.com/apache/geode/pull/5605#discussion_r501899913



##########
File path: geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
##########
@@ -52,6 +53,11 @@
 public class NioSslEngine implements NioFilter {
   private static final Logger logger = LogService.getLogger();
 
+  // this variable requires the MakeImmutable annotation but the buffer is empty and
+  // not really modifiable
+  @MakeImmutable
+  private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate(0);

Review comment:
       did you consider adding ".asReadOnlyBuffer()" so that this would be immutable?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] bschuchardt merged pull request #5605: GEODE-8584: Message transmission fails with IllegalStateException in socket i/o code

Posted by GitBox <gi...@apache.org>.
bschuchardt merged pull request #5605:
URL: https://github.com/apache/geode/pull/5605


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] bschuchardt commented on a change in pull request #5605: GEODE-8584: Message transmission fails with IllegalStateException in socket i/o code

Posted by GitBox <gi...@apache.org>.
bschuchardt commented on a change in pull request #5605:
URL: https://github.com/apache/geode/pull/5605#discussion_r501833784



##########
File path: geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java
##########
@@ -2588,17 +2592,20 @@ void writeFully(SocketChannel channel, ByteBuffer buffer, boolean forceAsync,
           }
           // fall through
         }
-        ByteBuffer wrappedBuffer = ioFilter.wrap(buffer);
-        while (wrappedBuffer.remaining() > 0) {
-          int amtWritten = 0;
-          long start = stats.startSocketWrite(true);
-          try {
-            amtWritten = channel.write(wrappedBuffer);
-          } finally {
-            stats.endSocketWrite(true, start, amtWritten, 0);
+        // synchronize on the ioFilter while using its network buffer
+        synchronized (ioFilter) {
+          ByteBuffer wrappedBuffer = ioFilter.wrap(buffer);
+          while (wrappedBuffer.remaining() > 0) {
+            int amtWritten = 0;
+            long start = stats.startSocketWrite(true);
+            try {
+              amtWritten = channel.write(wrappedBuffer);

Review comment:
       handlers for declared exceptions are already in place




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] bschuchardt commented on a change in pull request #5605: GEODE-8584: Message transmission fails with IllegalStateException in socket i/o code

Posted by GitBox <gi...@apache.org>.
bschuchardt commented on a change in pull request #5605:
URL: https://github.com/apache/geode/pull/5605#discussion_r501833149



##########
File path: geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
##########
@@ -396,9 +402,17 @@ public synchronized void close(SocketChannel socketChannel) {
     } catch (IOException e) {
       throw new GemFireIOException("exception closing SSL session", e);
     } finally {
-      bufferPool.releaseBuffer(TRACKED_SENDER, myNetData);
-      bufferPool.releaseBuffer(TRACKED_RECEIVER, peerAppData);
+      logger.info("NioSSLEngine releasing two buffers myNetData={}({}), peerAppData={}({})",

Review comment:
       thanks for catching that Anil - that's debug output that I meant to delete




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] Bill commented on a change in pull request #5605: GEODE-8584: Message transmission fails with IllegalStateException in socket i/o code

Posted by GitBox <gi...@apache.org>.
Bill commented on a change in pull request #5605:
URL: https://github.com/apache/geode/pull/5605#discussion_r501922128



##########
File path: geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
##########
@@ -52,6 +53,11 @@
 public class NioSslEngine implements NioFilter {
   private static final Logger logger = LogService.getLogger();
 
+  // this variable requires the MakeImmutable annotation but the buffer is empty and
+  // not really modifiable
+  @MakeImmutable
+  private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate(0);

Review comment:
       That won't satisfy PMD (since it returns a `ByteBuffer` which is not considered an immutable object by PMD) but it still might be valuable.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] dschneider-pivotal commented on a change in pull request #5605: GEODE-8584: Message transmission fails with IllegalStateException in socket i/o code

Posted by GitBox <gi...@apache.org>.
dschneider-pivotal commented on a change in pull request #5605:
URL: https://github.com/apache/geode/pull/5605#discussion_r501899913



##########
File path: geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
##########
@@ -52,6 +53,11 @@
 public class NioSslEngine implements NioFilter {
   private static final Logger logger = LogService.getLogger();
 
+  // this variable requires the MakeImmutable annotation but the buffer is empty and
+  // not really modifiable
+  @MakeImmutable
+  private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate(0);

Review comment:
       did you consider adding ".asReadOnlyBuffer()" so that this would be immutable?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] bschuchardt commented on a change in pull request #5605: GEODE-8584: Message transmission fails with IllegalStateException in socket i/o code

Posted by GitBox <gi...@apache.org>.
bschuchardt commented on a change in pull request #5605:
URL: https://github.com/apache/geode/pull/5605#discussion_r501833149



##########
File path: geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
##########
@@ -396,9 +402,17 @@ public synchronized void close(SocketChannel socketChannel) {
     } catch (IOException e) {
       throw new GemFireIOException("exception closing SSL session", e);
     } finally {
-      bufferPool.releaseBuffer(TRACKED_SENDER, myNetData);
-      bufferPool.releaseBuffer(TRACKED_RECEIVER, peerAppData);
+      logger.info("NioSSLEngine releasing two buffers myNetData={}({}), peerAppData={}({})",

Review comment:
       thanks for catching that Anil - that's debug output that I meant to delete

##########
File path: geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java
##########
@@ -2588,17 +2592,20 @@ void writeFully(SocketChannel channel, ByteBuffer buffer, boolean forceAsync,
           }
           // fall through
         }
-        ByteBuffer wrappedBuffer = ioFilter.wrap(buffer);
-        while (wrappedBuffer.remaining() > 0) {
-          int amtWritten = 0;
-          long start = stats.startSocketWrite(true);
-          try {
-            amtWritten = channel.write(wrappedBuffer);
-          } finally {
-            stats.endSocketWrite(true, start, amtWritten, 0);
+        // synchronize on the ioFilter while using its network buffer
+        synchronized (ioFilter) {
+          ByteBuffer wrappedBuffer = ioFilter.wrap(buffer);
+          while (wrappedBuffer.remaining() > 0) {
+            int amtWritten = 0;
+            long start = stats.startSocketWrite(true);
+            try {
+              amtWritten = channel.write(wrappedBuffer);

Review comment:
       handlers for declared exceptions are already in place




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] agingade commented on a change in pull request #5605: GEODE-8584: Message transmission fails with IllegalStateException in socket i/o code

Posted by GitBox <gi...@apache.org>.
agingade commented on a change in pull request #5605:
URL: https://github.com/apache/geode/pull/5605#discussion_r501818461



##########
File path: geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java
##########
@@ -2588,17 +2592,20 @@ void writeFully(SocketChannel channel, ByteBuffer buffer, boolean forceAsync,
           }
           // fall through
         }
-        ByteBuffer wrappedBuffer = ioFilter.wrap(buffer);
-        while (wrappedBuffer.remaining() > 0) {
-          int amtWritten = 0;
-          long start = stats.startSocketWrite(true);
-          try {
-            amtWritten = channel.write(wrappedBuffer);
-          } finally {
-            stats.endSocketWrite(true, start, amtWritten, 0);
+        // synchronize on the ioFilter while using its network buffer
+        synchronized (ioFilter) {
+          ByteBuffer wrappedBuffer = ioFilter.wrap(buffer);
+          while (wrappedBuffer.remaining() > 0) {
+            int amtWritten = 0;
+            long start = stats.startSocketWrite(true);
+            try {
+              amtWritten = channel.write(wrappedBuffer);

Review comment:
       Is there anything that needs to be done, if write throws exception...Sorry I may be asking wrong question as I don't have much context here.

##########
File path: geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
##########
@@ -396,9 +402,17 @@ public synchronized void close(SocketChannel socketChannel) {
     } catch (IOException e) {
       throw new GemFireIOException("exception closing SSL session", e);
     } finally {
-      bufferPool.releaseBuffer(TRACKED_SENDER, myNetData);
-      bufferPool.releaseBuffer(TRACKED_RECEIVER, peerAppData);
+      logger.info("NioSSLEngine releasing two buffers myNetData={}({}), peerAppData={}({})",

Review comment:
       This should be info or debug level log? just checking...




----------------------------------------------------------------
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:
users@infra.apache.org