Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5628

MaxMessageSize is never reset on a read buffer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.16.0
    • 0.18.0
    • netstd - Library
    • None

    Description

      It appears that for the ReadBuffer of a TMemoryBufferTransport the method CountConsumedMessageBytes() is called, but ResetConsumedMessageSize() is never called. 

      Our code as a long lived client which is polling periodically for an extended time. RemainingMessageSize eventually falls to <= 0 and a TTransportException("MaxMessageSize reached") is then thrown.

      Is this a bug or expected?

      I can fix this by changing TMemoryBufferTransport as follows

      public override ValueTask<int> ReadAsync(byte[] buffer, int offset, int length, CancellationToken cancellationToken)
      {
        var count = Math.Min(Length - Position, length);
        Buffer.BlockCopy(Bytes, Position, buffer, offset, count);
        Position += count;
        CountConsumedMessageBytes(count);
        ---> ResetConsumedMessageSize();
        return new ValueTask<int>(count);
      }

      but not confident this is correct.

      Or as a work around I can set TConfiguration.MaxMessageSize = int.MaxValue which will allow our code to operate for longer (20x) before failing.

      Or I can recreate the client periodically.

      Attachments

        Activity

          People

            ImpPhil3 Philip Lee
            ImpPhil3 Philip Lee
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: