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

Golang TFramedTransport's writeBuffer increases if writes to transport failed

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.11.0
    • Component/s: None
    • Labels:
      None

      Description

      https://github.com/apache/thrift/blob/master/lib/go/thrift/framed_transport.go#L143
      if p.transport.Write fails, p.buf will not be truncated, which leads to thrift client's memory increasing forever.

      Is it more reasonable to truncate p.buf when write to transport fails? here are my pull request, https://github.com/apache/thrift/pull/1303

      i'm new in github&jira, if more details are needed, please tell me, thx.

      func (p *TFramedTransport) Flush() error {
      	size := p.buf.Len()
      	buf := p.buffer[:4]
      	binary.BigEndian.PutUint32(buf, uint32(size))
      	_, err := p.transport.Write(buf)
      	if err != nil {
      		return NewTTransportExceptionFromError(err)
      	}
      	if size > 0 {
      		if n, err := p.buf.WriteTo(p.transport); err != nil {
      			print("Error while flushing write buffer of size ", size, " to transport, only wrote ", n, " bytes: ", err.Error(), "\n")
      			return NewTTransportExceptionFromError(err)
      		}
      	}
      	err = p.transport.Flush()
      	return NewTTransportExceptionFromError(err)
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pirDOL pirDOL
                Reporter:
                pirDOL pirDOL
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: