Gleiphir2769 commented on code in PR #1055:
URL: https://github.com/apache/pulsar-client-go/pull/1055#discussion_r1263219202
##########
pulsar/producer_partition.go:
##########
@@ -1407,31 +1410,39 @@ func (p *partitionProducer) releaseSemaphoreAndMem(size
int64) {
p.client.memLimit.ReleaseMemory(size)
}
-func (p *partitionProducer) canAddToQueue(sr *sendRequest,
uncompressedPayloadSize int64) bool {
+func (p *partitionProducer) canAddToQueue(sr *sendRequest) bool {
if p.options.DisableBlockIfQueueFull {
if !p.publishSemaphore.TryAcquire() {
runCallback(sr.callback, nil, sr.msg,
errSendQueueIsFull)
return false
}
- if !p.client.memLimit.TryReserveMemory(uncompressedPayloadSize)
{
+ } else {
+ if !p.publishSemaphore.Acquire(sr.ctx) {
+ runCallback(sr.callback, nil, sr.msg, errContextExpired)
+ return false
+ }
+ }
+ p.metrics.MessagesPending.Inc()
+ p.metrics.BytesPending.Add(float64(len(sr.msg.Payload)))
Review Comment:
Thanks for your careful review. L1425-L1426 is the original code and +1 to
move it to `canReserveMem`.
https://github.com/apache/pulsar-client-go/blob/e45122c2defc5efd4efc493d0acef278a7ccfc01/pulsar/producer_partition.go#L1436-L1441
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]