Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-213: Racy access of partitionProducer.state #43

Closed
sijie opened this issue Apr 12, 2020 · 0 comments
Closed

ISSUE-213: Racy access of partitionProducer.state #43

sijie opened this issue Apr 12, 2020 · 0 comments

Comments

@sijie
Copy link
Member

sijie commented Apr 12, 2020

Original Issue: apache#213


Expected behavior

No data race.

Actual behavior

Panic in TestDLQ test due to data race: https://github.com/apache/pulsar-client-go/pull/212/checks?check_run_id=579812410

WARNING: DATA RACE
Write at 0x00c0009a8960 by goroutine 187:
  github.com/apache/pulsar-client-go/pulsar.(*partitionProducer).internalClose()
      /pulsar-client-go/pulsar/producer_partition.go:454 +0x5e0
  github.com/apache/pulsar-client-go/pulsar.(*partitionProducer).runEventsLoop()
      /pulsar-client-go/pulsar/producer_partition.go:214 +0x35d

Previous read at 0x00c0009a8960 by goroutine 350:
  github.com/apache/pulsar-client-go/pulsar.(*partitionProducer).Close()
      /pulsar-client-go/pulsar/producer_partition.go:475 +0x56
  github.com/apache/pulsar-client-go/pulsar.(*producer).Close()
      /pulsar-client-go/pulsar/producer_impl.go:173 +0xd8
  github.com/apache/pulsar-client-go/pulsar/internal.(*ClientHandlers).Close()
      /pulsar-client-go/pulsar/internal/client_handlers.go:61 +0x30b
  github.com/apache/pulsar-client-go/pulsar.(*client).Close()
      /pulsar-client-go/pulsar/client_impl.go:165 +0x56
  github.com/apache/pulsar-client-go/pulsar.TestDLQ()
      /pulsar-client-go/pulsar/consumer_test.go:1041 +0xf80

The data access to partitionProducer.state is not thread-safe. internalClose() is writing it from a different goroutine than the readers.

Steps to reproduce

go test -race -count 100 -v -run 'TestDLQ$' .

System configuration

Pulsar version: 2.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant