streadway / amqp

Go client for AMQP 0.9.1
http://godoc.org/github.com/streadway/amqp
BSD 2-Clause "Simplified" License
4.85k stars 620 forks source link

concurrent map iteration and map write from amqp/types.go #503

Closed tbekiares closed 3 years ago

tbekiares commented 3 years ago

Hi,

I have an app that publishes hundreds of AMQP messages every few seconds. Within my app, messages are queued to a channel from multiple threads, and then a single service thread drains the channel to (amqpChannel).Publish().

I occasionally get this panic on Publish():

Apr 10 19:03:02 ip-172-20-78-106 forward[827]: fatal error: concurrent map iteration and map write Apr 10 19:03:02 ip-172-20-78-106 forward[827]: Apr 10 19:03:02 ip-172-20-78-106 forward[827]: goroutine 7 [running]: Apr 10 19:03:02 ip-172-20-78-106 forward[827]: runtime.throw(0xea1123, 0x26) Apr 10 19:03:02 ip-172-20-78-106 forward[827]: #011/usr/local/go/src/runtime/panic.go:774 +0x72 fp=0xc0003eb868 sp=0xc0003eb838 pc=0x42f292 Apr 10 19:03:02 ip-172-20-78-106 forward[827]: runtime.mapiternext(0xc0003eb9b0) Apr 10 19:03:02 ip-172-20-78-106 forward[827]: #011/usr/local/go/src/runtime/map.go:858 +0x579 fp=0xc0003eb8f0 sp=0xc0003eb868 pc=0x40f459 Apr 10 19:03:02 ip-172-20-78-106 forward[827]: runtime.mapiterinit(0xd6a0e0, 0xc0019c83c0, 0xc0003eb9b0) Apr 10 19:03:02 ip-172-20-78-106 forward[827]: #011/usr/local/go/src/runtime/map.go:848 +0x1c3 fp=0xc0003eb910 sp=0xc0003eb8f0 pc=0x40edf3 Apr 10 19:03:02 ip-172-20-78-106 forward[827]: github.com/streadway/amqp.validateField(0xd6a0e0, 0xc0019c83c0, 0xc0019b2a20, 0x0) Apr 10 19:03:02 ip-172-20-78-106 forward[827]: #011/src/vendor/github.com/streadway/amqp/types.go:241 +0x3d0 fp=0xc0003eba20 sp=0xc0003eb910 pc=0x8c6dc0 Apr 10 19:03:02 ip-172-20-78-106 forward[827]: github.com/streadway/amqp.Table.Validate(...) Apr 10 19:03:02 ip-172-20-78-106 forward[827]: #011/src/vendor/github.com/streadway/amqp/types.go:254 Apr 10 19:03:02 ip-172-20-78-106 forward[827]: github.com/streadway/amqp.(*Channel).Publish(0xc000124000, 0xc0019d9460, 0x1a, 0xc000481530, 0x10, 0x420000, 0xc0019c83c0, 0xe8d0d2, 0x14, 0x0, ...) Apr 10 19:03:02 ip-172-20-78-106 forward[827]: #011/src/vendor/github.com/streadway/amqp/channel.go:1327 +0x49 fp=0xc0003eba98 sp=0xc0003eba20 pc=0x8b0db9

any thoughts? I can't see how I'm doing anything concurrently from my application (which uses a single service thread to read from a channel and publish to this amqp library).

Thanks!

tbekiares commented 3 years ago

ha! never mind, within my own app I of course found a place where there could be contention writing out the amqp headers table affixed to each msg.