Add a thread sanitizer CI lane and Event Hubs thread safety tests

Đang mở
#7,290 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@j7nw4r đang làm issue này rồi.

Từ ngày 5/8/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

Event Hubs

Summary

The Event Hubs library has no thread safety test and no sanitizer lane in CI. The races in #7284 thus went into main with no warning, and a new race can do the same. A thread sanitizer build and a small test suite let CI hold the thread safety guarantee.

Parent: #7284. Severity tags follow the key in #7252. The code anchors refer to commit 2de7c583e.

Motivation

A thread sanitizer finds all three defects in #7284. It needs one test that shares a client across threads. No such test exists. The stress test applies load (test/eventhubs-stress-test/). It does not share one client across threads, and it does not run under a sanitizer.

A sanitizer lane also protects the locking rework, which is the largest change in this workstream. #7286 changes EnsureSender to a double-checked write. #7288 moves to a std::shared_mutex. A small error in either change gives a rare race, not a test failure.

The repository can already run an ASan lane or a UBSan lane. A TSan job can then extend it. Read the CI definitions before you add a job.

Proposal

Build support.

  • Add a CMake option that turns on -fsanitize=thread for clang and gcc. [GA quality bar]
  • Put ASan and UBSan on the same option. The option selects one sanitizer, because a binary cannot hold the thread sanitizer and the address sanitizer together. [GA quality bar]
  • Add a CI job that builds the Event Hubs tests with the thread sanitizer and runs the thread safety tests. [GA quality bar]

Tests.

  • Add a test for the unlocked map read. N threads call Send to N different partitions that no thread used before. The test uses one shared ProducerClient. [GA quality bar]
  • Add a shared-client stress test. One ProducerClient, many threads, sends to the same partition and to different partitions. The test counts the messages that arrive. [GA quality bar]
  • Add a wrong-use test. A TryAdd during a Send on the same batch fails each time, and the batch stays correct. [GA quality bar]
  • Add a processor test. Parallel partition handlers write to a checkpoint store. The test loses no checkpoint and duplicates no checkpoint. [GA quality bar]
  • Add a lifecycle test for the races in #7255: a parallel Send and Close, then a parallel Start and Stop. The two workstreams then share one suite. [GA quality bar]
  • Extend the stress test to apply load to one shared client (test/eventhubs-stress-test/). [Post GA]

The map-read test must cause a thread sanitizer error before #7285. It must pass after #7285.

The tests that need a broker must use the existing test broker, not a live namespace. The lane then stays cheap enough for every pull request. #7270 pinned the broker hash, so the target is stable.

Validation

  • The thread sanitizer lane runs in CI. A reported race fails the build.
  • The map-read test causes a thread sanitizer error when you revert #7285.
  • The full test suite passes under the thread sanitizer with no suppressions. A necessary suppression has a comment that gives the reason and the issue that removes it.
  • The lane is fast enough to run on every pull request.
Ngôn ngữ chính
C++
Star
206
Fork
178
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
33

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Azure/azure-sdk-for-cpp

Tất cả issue của Azure/azure-sdk-for-cpp

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.