[ 
https://issues.apache.org/jira/browse/GEODE-8542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17203337#comment-17203337
 ] 

ASF GitHub Bot commented on GEODE-8542:
---------------------------------------

Bill commented on a change in pull request #5562:
URL: https://github.com/apache/geode/pull/5562#discussion_r496068316



##########
File path: 
geode-core/src/test/java/org/apache/geode/internal/tcp/MsgStreamerTest.java
##########
@@ -92,9 +117,9 @@ protected BaseMsgStreamer createMsgStreamer(boolean 
mixedDestinationVersions) {
     when(connection2.getRemoteAddress()).thenReturn(member2);
     
when(connection2.getSendBufferSize()).thenReturn(Connection.SMALL_BUFFER_SIZE);
     if (mixedDestinationVersions) {
-      
when(connection1.getRemoteVersion()).thenReturn(KnownVersion.GEODE_1_12_0);
+      
when(connection2.getRemoteVersion()).thenReturn(KnownVersion.GEODE_1_12_0);
     } else {
-      when(connection1.getRemoteVersion()).thenReturn(KnownVersion.CURRENT);
+      when(connection2.getRemoteVersion()).thenReturn(KnownVersion.CURRENT);

Review comment:
       I don't know why this code was changed to make the second connection 
(instead of the first), the old version connection. But the resulting code 
seems just as correct as the old code  ✓

##########
File path: 
geode-core/src/main/java/org/apache/geode/internal/tcp/MsgStreamer.java
##########
@@ -129,7 +130,8 @@ public ConnectExceptions getConnectExceptions() {
     this.stats = stats;
     this.msg = msg;
     this.cons = cons;
-    this.buffer = bufferPool.acquireDirectSenderBuffer(sendBufferSize);
+    int bufferSize = Math.min(sendBufferSize, Connection.MAX_MSG_SIZE);
+    this.buffer = bufferPool.acquireDirectSenderBuffer(bufferSize);

Review comment:
       since this class is in the same package as `Connection` this seems like 
appropriate coupling ✓

##########
File path: 
geode-core/src/test/java/org/apache/geode/internal/tcp/MsgStreamerTest.java
##########
@@ -77,6 +77,31 @@ public void streamerListReleaseWithException() throws 
IOException {
     verify(pool, times(2)).releaseSenderBuffer(isA(ByteBuffer.class));
   }
 
+  @Test
+  public void streamerRespectsMaxMessageSize() {
+    InternalDistributedMember member1;
+    member1 = new InternalDistributedMember("localhost", 1234);
+
+    DistributionMessage message = new SerialAckedMessage();
+    message.setRecipients(Arrays.asList(member1));
+
+    when(connection1.getRemoteAddress()).thenReturn(member1);
+    when(connection1.getRemoteVersion()).thenReturn(KnownVersion.CURRENT);
+    // create a streamer for a Connection that has a buffer size that's larger 
than the
+    // biggest message we can actually send. This is picked up by the 
MsgStreamer to allocate
+    // a buffer
+    when(connection1.getSendBufferSize()).thenReturn(Connection.MAX_MSG_SIZE * 
2);

Review comment:
       This test could be stronger if the requested message size was 
`MAX_MSG_SIZE + 1`. As it stands this test allows a lot of wiggle-room for the 
implementation.




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


> java.lang.IllegalStateException: tcp message exceeded max size of 16777215
> --------------------------------------------------------------------------
>
>                 Key: GEODE-8542
>                 URL: https://issues.apache.org/jira/browse/GEODE-8542
>             Project: Geode
>          Issue Type: Bug
>          Components: messaging
>    Affects Versions: 1.14.0
>            Reporter: Bruce J Schuchardt
>            Assignee: Bruce J Schuchardt
>            Priority: Major
>              Labels: pull-request-available
>
> We had reports of this exception when using TLS for cluster communications.  
> I wrote a test that set socket-lease-time to 1 second and then looped 
> creating a thread to do a single 20mb put() and then waiting 2 seconds after 
> the put() completed so that connections would time out.
> I saw message-length growth without the fix for GEODE-8506 that went away 
> with the fix for that ticket.  If I let the test go on long enough the 
> message-length grew to over 16mb and the test failed with this error:
> {noformat}
> java.lang.IllegalStateException: tcp message exceeded max size of 16777215
> [vm2]         at 
> org.apache.geode.internal.tcp.Connection.calcHdrSize(Connection.java:610)
> [vm2]         at 
> org.apache.geode.internal.tcp.MsgStreamer.setMessageHeader(MsgStreamer.java:454)
> [vm2]         at 
> org.apache.geode.internal.tcp.MsgStreamer.realFlush(MsgStreamer.java:311)
> [vm2]         at 
> org.apache.geode.internal.tcp.MsgStreamer.write(MsgStreamer.java:378)
> [vm2]         at 
> org.apache.geode.DataSerializer.writeByteArray(DataSerializer.java:1258)
> [vm2]         at 
> org.apache.geode.DataSerializer.writeByteArray(DataSerializer.java:1226)
> [vm2]         at 
> org.apache.geode.internal.cache.DistributedCacheOperation.writeValue(DistributedCacheOperation.java:134)
> [vm2]         at 
> org.apache.geode.internal.cache.UpdateOperation$UpdateMessage.toData(UpdateOperation.java:413)
> [vm2]         at 
> org.apache.geode.internal.InternalDataSerializer.invokeToData(InternalDataSerializer.java:2300)
> [vm2]         ... 53 more{noformat}
> While the fix for GEODE-8506 made it unlikely that we'll run into this again 
> I think we should bullet-proof the MsgStreamer class to never try to send 
> message chunks larger than Connection.MAX_MSG_SIZE.
> Note that we can still send cache operation messages larger than 16mb because 
> MsgStreamer will break them into smaller chunks.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to