You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/06/24 21:03:42 UTC

[GitHub] [pulsar-client-go] dferstay commented on a change in pull request #533: [issue 516]Add lock for compressionProviders to fix data race problem

dferstay commented on a change in pull request #533:
URL: https://github.com/apache/pulsar-client-go/pull/533#discussion_r658280811



##########
File path: pulsar/consumer_partition.go
##########
@@ -1062,16 +1065,19 @@ func getPreviousMessage(mid trackingMessageID) trackingMessageID {
 }
 
 func (pc *partitionConsumer) Decompress(msgMeta *pb.MessageMetadata, payload internal.Buffer) (internal.Buffer, error) {
+	pc.providersMutex.Lock()

Review comment:
       @fishpenguin , @cckellogg ,
   I'm thinking an [RWMutex](https://golang.org/pkg/sync/#RWMutex) would generate less contention.  The majority of accesses require the read lock; the write lock is only required when initialising the provider.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org