Problems using buffer object pool (sync.Pool) (forward + summary)

sync.Pool can improve throughput in high concurrency scenarios, but improper use will lead to serious problems. Here is a detailed review of the problems encountered this time.

# preface

The problem of missing body always occurred in the test simulation environment before. After a long time of troubleshooting, the reason was finally found. The client of our gateway uses fasthttp, and the test simulation environment uses LB built by nginx. When the business version is released, nginx will reload the configuration file. Originally, there was no problem with this process. However, due to the implementation of fasthttp, the disconnection of the server side cannot be perceived, resulting in the loss of the client's body. See this for details issue

# Original code

In order to solve the problem of losing body, we can only use buffer instead. The specific implementation is as follows:

func (c *Context) BodyBuffer() (*bytes.Buffer, error) {
   if v, ok := c.Get("BB"); ok {
      return v.(*bytes.Buffer), nil
   }
 
   buff := initvar.BufPool.Get().(*[]byte)
   buffer := initvar.BufferPool.Get().(*bytes.Buffer)
   buffer.Reset()
 
   _, err := io.CopyBuffer(buffer, c.Request.Body, *buff)
   if err != nil {
      return nil, err
   }
 
   initvar.BufPool.Put(buff)
   initvar.BufferPool.Put(buffer)
   c.Set("BB", buffer)
   return buffer, nil
}

As a result, there is a service feedback on the line. They have an interface, and the received RequestBody is mixed with other data. After receiving the feedback, we reviewed the code again and quickly thought of sync There is a problem with the use of pool.

Here, we return the buffer pointer after Put, which will cause multiple requests to share a buffer, which will naturally lead to the mixing of the Body of other requests in a Request.

# correct

After locating the problem, we quickly modified it. But, unexpectedly, I was careless again!

func (c *Context) BodyBytes() ([]byte, error) {
   if v, ok := c.Get("BB"); ok {
      return v.([]byte), nil
   }
 
   buff := initvar.BufPool.Get().(*[]byte)
   buffer := initvar.BufferPool.Get().(*bytes.Buffer)
   defer initvar.BufPool.Put(buff)
   defer initvar.BufferPool.Put(buffer)
 
   buffer.Reset()
   _, err := io.CopyBuffer(buffer, c.Request.Body, *buff)
   if err != nil {
      return nil, err
   }
 
   c.Set("BB", buffer.Bytes())
   return buffer.Bytes(), nil
}

It can be seen that in order to solve the problem of the original code, we want to take out Bytes and return them before Put. However, the Bytes function here reads a [] byte in the Buffer attribute, so there is still a problem.

# reproduce

In order to verify our conjecture, we wrote the following code to verify. In the final output, we can see that other data is mixed in the Body.

func main() {
	pool := sync.Pool{New: func() interface{} {
		return new(bytes.Buffer)
	}}

	readBytes := func(src io.Reader) []byte {
		buffer := pool.Get().(*bytes.Buffer)
		defer pool.Put(buffer)

		buffer.Reset()
		_, err := io.Copy(buffer, src)
		if err != nil {
			fmt.Println(err)
		}

		return buffer.Bytes()
	}

	aaa := []string{
		"{\"data\":{\"pri\":\"IwtsnydXLqUzECkCxfi5WmQxQMoVSHiCT0NIOmkqPO\\/vhwb9uez0kkFlKuCRTvdeNpM\\/LE0tOCYxEB9DBVGqj4MZi2QRJuy0wQq75637cX9fUe69zyzS0dFZGcG6robTXMhBqykgbCn+aEa7wfuxJ1HEb7SZZyaJpZv8D4ztKC4\\/Yblr0xBVLl0Ltw5UJ9aGHg7JpSWZvmLuFTQ8\\/GwAdjBX4yznE8GzutTLWQrETLHdBRkx9y3Vq8Kauvq8QsXbVSsXqcX2nMn6r8I\\/TOHtAQRQwDSTfoZ5TOkz9ZckxPCgku8b2yhgQcALs8VkfYN0iZPA4L8m+Ed2WJsAtare6A==\",\"fingerprint\":\"8WX9JP9l1ZIVwUNgTPCu1\\/tKUTOGn02BVtE+cSDB8Me2plhZVS6PG+0WcZDY3D9jFxXvTFjWqavqjSP52QkHld1mQd+ywA0q9ZO\\/+6rq4Qu4GO\\/yW5sZbIZns5WWGo1+O3ubmIPK4Rv3bjxZ4Sz61UVtq17KWog1IOgz7lzy3DvamnqyC+ayr39v30EOj2xAOMjS7M20jU7psfgeoBrWAYKkGdS7D9FCcDtoDXZa5KW7aQxZm2pH6d4z4e66ag7F9FzrCptXbty6ZkUvWJ7OC0+JcTtzaZy5z6ftQBd1nR6XaZWAnzaa5jmaJtAfdQfN+CwS8l7w9ZtiBu82PA2lC9EyZZO\\/HdUmOtarNOFRs9S2O3vRorv96za+laEHBZwUIXvMQ1YTQ44cK9jFoLQQohWpnXG9wIGKWhf+N1P2p\\/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jG9bgc3FK9K4APSojCV45Y8Mtb\\/+zOUdiiZ49C38EuMRw5JxV0HESx10z\\/kEeXSQh\\/JkvQA\\/kRHFT2rXWvo+UlANdMOpU9cdYk4Gk63+a5QeW4zfp\\/wP8=\",\"tn\":\"atDQJEkeSKdH8C+0pOmw6rOQ4BBMx1ALk7wIIAHYxR3GrCk++IGtVTsKU01TyB6wsvTv2UphwIWmIpCcBW5JyYs4vo77rIkJ3GLg8Ch8HC86GXwG\\/r+Dx\\/op03nVpKVYxZHG739jsLjIKdRqUXwno29OeTIBV\\/n2Htz+Efw3fbruDY33013wirblnUZHVDYo5qWXsTa48uHt\\/oR2CRmwr8QYwFz+yes+NviUxRGTl8tIppUKC7gxhFEnK+PjiL8KGFz25x1fJbmMmLLw4z71fFXGfYXxzOpg5n5nQrtEGnN5aF8e+ozyRMV3cl93VoYpZvSi0K+0X7HaO+lXjDsX3g==\",\"sessionId\":\"1588754495607\",\"fpEncode\":11},\"encrypt\":1,\"organization\":\"oXGNW54W7cZcFS1goYH7\",\"channel\":\"\"}",
		"h=%7b%22u%22%3a%222552111184%22%2c%22thumb%22%3a%22xl%22%2c%22dt%22%3a%22phone%22%2c%22ov%22%3a%2210%22%2c%22net%22%3a%224G%22%2c%22os%22%3a%22ANDROID%22%2c%22d%22%3a%2253cexxxxxxae11f%22%2c%22dv%22%3a%22PCT-TL10%22%2c%22t%22%3a%22json%22%2c%22chil%22%3a%227%22%2c%22v%22%3a%222%22%2c%22av%22%3a%227.8.0%22%2c%22scr%22%3a%223.0%22%2c%22adv%22%3a%221%22%2c%22ts%22%3a%221588726552%22%2c%22s%22%3a%22450efcxxxxx65f145%22%2c%22seid%22%3a%222377955226xxxxxa49004xxxx9db957%22%7d&struct_id=1340828",
	}
	rand.Seed(time.Now().Unix())
	for i := 0; i < 10; i++ {
		bbb := aaa[rand.Intn(2)]
		src1 := bytes.NewBufferString(bbb)

		go func() {
			bb := readBytes(src1)
			time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000)))
			if string(bb) != bbb {
				fmt.Println(string(bb))
			}
		}()

		time.Sleep(time.Millisecond * time.Duration(rand.Intn(50)))
	}
	time.Sleep(time.Second)
	return
}

# solve

Finally, we put the buffer into the Context, and the problem is solved.

func (c *Context) ReadBodyBytes() ([]byte, error) {
   if c.bodyBuffer.Len() > 0 {
      return c.bodyBuffer.Bytes(), nil
   }
 
   written, err := io.Copy(&c.bodyBuffer, c.Request.Body)
   if err != nil {
      return nil, fmt.Errorf("read body error: %s, written: %d, buffer: %s", err, written, c.bodyBuffer.String())
   }
 
   return c.bodyBuffer.Bytes(), nil
}

# summary

When using sync You should pay attention to the reference problem when using pool. Remember to ensure that the Put object has been used.

This is what the original text says. It may be difficult to understand. In summary, the object put back is for the return of Bytes. In fact, the data obtained from the outer layer is still a reference to the object put back. We know that after the Pool is put back, it will be used in other situations. In case of concurrency, the data will be modified by other go stack s in the process of use, Causes body data loss

Keywords: Go Back-end

Added by A JM on Sun, 02 Jan 2022 00:41:16 +0200