Gilthoniel commented on code in PR #1372:
URL: https://github.com/apache/pulsar-client-go/pull/1372#discussion_r2152231041


##########
pulsar/producer_partition.go:
##########
@@ -1743,15 +1743,22 @@ func (i *pendingItem) done(err error) {
        }
 
        i.isDone = true
-       // return the buffer to the pool after all callbacks have been called.
-       defer buffersPool.Put(i.buffer)
+
        if i.flushCallback != nil {
                i.flushCallback(err)
        }
 
        if i.cancel != nil {
                i.cancel()
        }
+
+       if err == nil {
+               // Buffer is returned after executing all the callbacks and 
only if the
+               // pending item is successful because that is the only state 
that ensure
+               // a finality of the buffer at that time (an erroneuous item 
might still
+               // be in the connection sending queue).
+               buffersPool.Put(i.buffer)

Review Comment:
   We observe that bug several times a day in our CI.



-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to