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

Data race between subscription.StatusChanged and subscription.changeSubStatus #1815

Open
AndrewDK opened this issue Mar 11, 2025 · 1 comment
Assignees
Labels
defect Suspected defect such as a bug or regression

Comments

@AndrewDK
Copy link

Observed behavior

When calling subscription.Drain followed by subscription.StatusChanged, the current status is read from inside StatusChanged outside a mutex, but written inside changeSubStatus, inside the mutex, which causes a data race.

Expected behavior

I expect the status read and write to be serialized.

Server and client version

github.com/nats-io/nats.go v1.38.0

Host environment

No response

Steps to reproduce

No response

@AndrewDK AndrewDK added the defect Suspected defect such as a bug or regression label Mar 11, 2025
@piotrpio piotrpio self-assigned this Mar 11, 2025
@piotrpio
Copy link
Collaborator

Hello @AndrewDK, thanks for creating the issue. You're right, that is a potential race, I'll look into it.

@AndrewDK AndrewDK changed the title Data race between subscription.StatusChanged and changeSubStatus.changeSubStatus Data race between subscription.StatusChanged and subscription.changeSubStatus Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Suspected defect such as a bug or regression
Projects
None yet
Development

No branches or pull requests

2 participants