Open sujit-baniya opened 11 months ago
It's looke like some issue is here
log.Printf("callback: publish confirmed status [%v] from queue [%s]\n", confirm.Ack, ch.Queue())
channel.Queue method has a lock
func (ch *Channel) Queue() string {
ch.baseChan.mu.RLock()
defer ch.baseChan.mu.RUnlock()
return ch.queue
}
If you change ch.Queue() for simple string, for example "queueName" - all is good
It looks like lock/unluck on ch.Queue is useless and make some decrease in performance
@valinurovam Thank you for response.
So you mean, If I remove lock, it might work?
Question: Is lock necessary there? Because I don't see any operations that might cause deadlock
Looks like deadlock somewhere. If you change method like this
// Queue returns the active (as indicated by [IsDestination] option in topology options) queue name.
// Useful for finding the server assigned name.
func (ch *Channel) Queue() string {
fmt.Println("try to get lock... ")
ch.baseChan.mu.RLock()
fmt.Println(" locked.")
defer func() {
fmt.Println(" unlocked.\n")
ch.baseChan.mu.RUnlock()
}()
return ch.queue
}
Logs
try to get lock...
2023/12/29 19:11:40 going to send: test number 1623
locked.
unlocked.
callback: publish confirmed status [true] from queue [workload]
try to get lock...
2023/12/29 19:11:40 going to send: test number 1624
locked.
unlocked.
callback: publish confirmed status [true] from queue [workload]
2023/12/29 19:11:40 going to send: test number 1625
2023/12/29 19:11:40 going to send: test number 1626
2023/12/29 19:11:40 going to send: test number 1627
2023/12/29 19:11:40 going to send: test number 1628
try to get lock...
2023/12/29 19:11:40 going to send: test number 1629
locked.
unlocked.
callback: publish confirmed status [true] from queue [workload]
try to get lock...
I'm using BadgerDB as persistent DB and when trying to publish around 500K messages with
Persistent
messages for testing without any delay, it causes publisher to freeze.Screenshot
Seems Channel is closed before all messages are being published