WS3: Fix client lifecycle and thread safety
I maintainer di solito rispondono entro 1 giorno
@j7nw4r ci sta già lavorando.
Dal 28/7/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Summary
The C++ Event Hubs clients carry two data races and no defined behavior after close. ProducerClient::Close mutates the sender map without taking the lock that guards it. Processor::m_isRunning is a plain bool written on one thread and read on another. No public header states a concurrency guarantee, and use after close throws std::out_of_range from a map lookup.
Severity tags follow the key in #7252.
Motivation
The .NET clients document safe concurrent use, close is idempotent, and a closed client throws EventHubsException with FailureReason.ClientClosed (sdk/eventhub/Azure.Messaging.EventHubs/src/EventHubsException.cs:227).
In C++, ProducerClient::Close iterates and clears m_senders without taking m_sendersLock (src/producer_client.cpp:36-69), while EnsureSender mutates the same map under that lock (src/producer_client.cpp:196-229). A concurrent Send and Close is a data race. Close also clears m_sessions and m_connections unguarded. No closed-state flag exists, so use after close reaches m_senders.at(...) and throws std::out_of_range (src/producer_client.cpp:230-234), which is a standard library error rather than a library error the caller can act on.
Processor::Start writes m_isRunning after it starts the worker thread, Stop writes it from another thread (src/processor.cpp:64,71), and the worker reads it in its loop (src/processor.cpp:100). The member is a plain bool (inc/azure/messaging/eventhubs/processor.hpp:277), so that is an unsynchronized read and write.
No public header documents which methods are safe to call concurrently or what Close guarantees.
Proposal
- Make
ProducerClient::Closetakem_sendersLockbefore it iterates and clearsm_senders,m_sessions, andm_connections(src/producer_client.cpp:36-69,196-229). [GA blocker] - Make
Closeidempotent, add a closed-state flag, and make use after close throwEventHubsExceptioninstead ofstd::out_of_range(src/producer_client.cpp:230-234). Apply the same treatment toConsumerClient::Close. Reference: .NET raisesFailureReason.ClientClosed. [GA blocker] - Make
Processor::m_isRunningatomic, and set it before the worker thread starts (inc/azure/messaging/eventhubs/processor.hpp:277,src/processor.cpp:51-77,100). [GA blocker] - Document the concurrency contract for every public client type in the headers and the README: which methods are safe to call concurrently, and what
Closeguarantees. [GA quality bar] - Correct the log text in
ConsumerClient::Close, which says "Close producer client" (src/consumer_client.cpp:40). [GA quality bar]
Validation
- A thread sanitizer run over a concurrent send and close reports no race.
- A thread sanitizer run over a processor start and stop reports no race.
- Calling
Closetwice succeeds. - Calling
SendafterClosethrowsEventHubsException. - Every public client header states its concurrency guarantee.
- Lingua principale
- C++
- Stelle
- 207
- Fork
- 173
- Merge medio
- 1g 10h
- PR unite (30g)
- 30
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Azure/azure-sdk-for-cpp
-
DataLakeFileSystemClient::ListPaths() throws JSON exception due to accessing undefined fieldsApertacustomer-reported needs-triage question
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Azure/azure-sdk-for-cpp#7435 ·
I maintainer di solito rispondono entro 1 giorno
-
bug EngSys
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
Azure/azure-sdk-for-cpp#7362 ·
I maintainer di solito rispondono entro 1 giorno
-
Client needs-team-attention Service Attention Storage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Azure/azure-sdk-for-cpp#7347 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Client Event Hubs needs-team-attention Service Attention
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
Azure/azure-sdk-for-cpp#7333 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
DataLakeDirectoryClient::ListPaths() throws exception due to incorrect format used for date-time fieldsForse già presa @seanmcc-msft l’ha presa oggi. Apertacustomer-reported needs-triage question
Azure/azure-sdk-for-cpp#7436 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Azure/azure-sdk-for-cpp
Issue simili
-
Broken links in the docsAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
microsoft/onnxruntime#33018 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
ChromieCraft Generic Confirmed World Event
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
azerothcore/azerothcore-wotlk#27882 ·
I maintainer di solito rispondono entro 1 giorno
-
MacOS build failureApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
aristocratos/btop#1874 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
cataclysmbn/Cataclysm-BN#10447 ·
I maintainer di solito rispondono entro 1 giorno