apache / pulsar-client-go

Apache Pulsar Go Client Library
https://pulsar.apache.org/
Apache License 2.0
659 stars 336 forks source link

[Issue 1274][connection] Refactor connection concurrency model #1275

Closed Gilthoniel closed 2 months ago

Gilthoniel commented 2 months ago

Fixes #1274

Motivation

A race can happen while a consumer or a producer is registering itself to the connection to later receive closing notification.

Modifications

This pull request changes the concurrency model of the connection to properly lock the different actors between the closing procedure and the registration of handlers and listeners. After this, a caller will properly check the state of the connection and aborts if closed, and it will be certain that it will not be registered in concurrency with a closing.

Verifying this change

This change is already covered by existing tests.

Does this pull request potentially affect one of the following parts:

none

Documentation

none

frankjkelly commented 2 months ago

@Gilthoniel Thanks for this fix. Was this issue introduced in 0.13.1 or was does it predate that and if so do you know how far back it goes?

CC: @crossoverJie @nodece