Closed gottlike closed 3 weeks ago
Another detail: Even if I don't get the channel errors, I'm seeing a few "un-acked" messages in the queue, which block the client.rb
process indefinitely. But not so for e.g. 10 threads or less.
FYI: There's also a related chat on the 84codes Slack: https://app.slack.com/client/T01K2BK0K6G/C01K2BK1PT6
The library isn't thread safe and the problem here is that two threads are trying to open a channel at the same time and the same channel id is used.
@spuun the README here says "fully thread-safe" so this is a bug that we should address? Not "close as completed"
I agree.. this should be reopened as a bug, especially since the RPC feature (which is advertised as a main feature on the LavinMQ homepage) is unusable without implementing special handling for this.
Please take a look at https://github.com/cloudamqp/amqp-client.rb/pull/30 which implements a RPC server and client directly into the lib.
I was too quick here.
Issue
I'm close to using LavinMQ as my replacement for REST, but ran into a blocker. I'm getting this error in the
worker.rb
process (see below), when doing concurrent requests:Reproduction
client.rb
worker.rb
worker_rpc.rb
Steps to reproduce (start everything in new tabs):
docker run --rm -p 5672:5672 -p 15672:15672 cloudamqp/lavinmq
MQ_URL='amqp://guest:guest@localhost' MQ_QUEUE='test.queue' ruby worker.rb
MQ_URL='amqp://guest:guest@localhost' MQ_QUEUE='test.rpc.queue' ruby worker_rpc.rb
ruby client.rb
If you change the
150.times.collect { '{"msg":"Ping!"}' }
to2.times.collect { '{"msg":"Ping!"}' }
it works.Interestingly this does not fail on my M1 MacBook, even with higher numbers. But on a server with weaker shared CPUs it does so, starting at only 50 threads.