Fix potential data race in pendingItem.done() (#1347)

* fix potential data race in pendingItem.done()

* update

* use defer
diff --git a/pulsar/producer_partition.go b/pulsar/producer_partition.go
index f652312..a4c2e3f 100755
--- a/pulsar/producer_partition.go
+++ b/pulsar/producer_partition.go
@@ -1741,8 +1741,10 @@
 	if i.isDone {
 		return
 	}
+
 	i.isDone = true
-	buffersPool.Put(i.buffer)
+	// return the buffer to the pool after all callbacks have been called.
+	defer buffersPool.Put(i.buffer)
 	if i.flushCallback != nil {
 		i.flushCallback(err)
 	}