apache / rocketmq-client-go

Apache RocketMQ go client
https://rocketmq.apache.org/
Apache License 2.0
1.28k stars 409 forks source link

fix: Map's concurrency issues #1100

Open anrror opened 9 months ago

anrror commented 9 months ago

…e sync.Map

What is the purpose of the change

Map will fail during concurrency。
When using ‘go’ (code:/vebchmark/nessage.go:225 go func... ). the map must add lock or replace with sync.Map It has length usage, so I can't use the sync.Map

bug:

goroutine 841 [running]: runtime.throw({0x2235be1?, 0xc000bac480?}) /usr/local/go/src/runtime/panic.go:992 +0x71 fp=0xc001a9b868 sp=0xc001a9b838 pc=0x438731 runtime.mapassign_faststr(0xc000518d40?, 0x1dc5040?, {0xc000c18b10, 0x16}) /usr/local/go/src/runtime/map_faststr.go:212 +0x39c fp=0xc001a9b8d0 sp=0xc001a9b868 pc=0x4135fc github.com/apache/rocketmq-client-go/v2/consumer.(*pushConsumer).Subscribe(0xc000281740, {0xc000c18b10?, 0x4?}, {{0x0?, 0x40d645?}, {0x0?, 0x4?}}, 0xc0005a2320) /home/app/go/pkg/mod/github.com/apache/rocketmq-client-go/v2@v2.1.2/consumer/push_consumer.go:305 +0x1fb fp=0xc001a9b960 sp=0xc001a9b8d0 pc=0x82ab5b

Brief changelog

Map's concurrency issues

Verifying this change

XXXX

Follow this checklist to help us incorporate your contribution quickly and easily. Notice, it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR.