beobal commented on code in PR #3655:
URL: https://github.com/apache/cassandra/pull/3655#discussion_r1867687581


##########
src/java/org/apache/cassandra/transport/CQLMessageHandler.java:
##########
@@ -747,18 +773,85 @@ private void markBackpressure(Overload backpressure)
             this.backpressure = backpressure;
         }
 
+        private void markTooBig()
+        {
+            this.tooBig = true;
+        }
+
+        protected void onIntactFrame(IntactFrame frame)
+        {
+            if (tooBig || overload != Overload.NONE)
+                // we do not want to add the frame to buffers (to not consume 
a lot of memory and throw it away later
+                // we also do not want to release capacity because we haven't 
accuired it
+                frame.consume();
+            else
+                super.onIntactFrame(frame);
+        }
+
+        protected void onCorruptFrame()
+        {
+            if (!isExpired && !isCorrupt && !tooBig)
+            {
+                releaseBuffers(); // release resources once we transition from 
normal state to corrupt
+                if (overload != Overload.BYTES_IN_FLIGHT)
+                    releaseCapacity(size);
+            }
+            isCorrupt = true;
+            isExpired |= approxTime.isAfter(expiresAtNanos);
+        }
+
+
         protected void onComplete()
         {
-            if (overload != Overload.NONE)
-                
handleErrorAndRelease(buildOverloadedException(endpointReserveCapacity, 
globalReserveCapacity, overload), header);
+            if (tooBig)
+                // we haven't accuired a capacity for too big messages to 
release it
+                
handleError(buildOversizedCQLMessageException(header.bodySizeInBytes), header);
+            else if (overload != Overload.NONE)
+                if (overload == Overload.BYTES_IN_FLIGHT)
+                    // we haven't accuired a capacity successfully to release 
it
+                    
handleError(buildOverloadedException(endpointReserveCapacity, 
globalReserveCapacity, overload), header);
+                else
+                    
handleErrorAndRelease(buildOverloadedException(endpointReserveCapacity, 
globalReserveCapacity, overload), header);
             else if (!isCorrupt)
                 processRequest(assembleFrame(), backpressure);
         }
 
         protected void abort()
         {
-            if (!isCorrupt)
-                releaseBuffersAndCapacity(); // release resources if in normal 
state when abort() is invoked
+            if (!isCorrupt && !tooBig && overload == Overload.NONE)
+                releaseBuffers();
+
+            if (overload == Overload.NONE || overload == 
Overload.BYTES_IN_FLIGHT)
+                releaseCapacity(size);
+        }
+
+        private OversizedCQLMessageException 
buildOversizedCQLMessageException(long messageBodySize)
+        {
+            return new OversizedCQLMessageException("CQL Message of size " + 
messageBodySize
+                                                    + " bytes exceeds allowed 
maximum of "
+                                                    + 
DatabaseDescriptor.getNativeTransportMaxMessageSizeInBytes() + " bytes");
+        }
+    }
+
+    static class OversizedAuthMessageException extends ProtocolException
+    {
+        OversizedAuthMessageException(String message)
+        {
+            super(message);
+        }
+    }
+
+    private boolean isItLargeMessageSentDuringAuth(Envelope.Header header)

Review Comment:
   sure, if you're happy with that.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to