Repository navigation
Add opt-in primary Bridge pile preference - #942
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #942 +/- ##
==========================================
+ Coverage 82.72% 83.02% +0.30%
==========================================
Files 99 99
Lines 12965 13033 +68
Branches 1266 1286 +20
==========================================
+ Hits 10725 10821 +96
+ Misses 1789 1770 -19
+ Partials 451 442 -9
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
An active moderate issue remains because the verification can accept duplicate recovery markers for one scenario while failing to confirm recovery for all five scenarios.
1 open issue
What changed in this PR
Adds opt-in Bridge pile-aware endpoint selection to synchronous and asynchronous YDB drivers, preferring PRIMARY/PROMOTED endpoints while retaining synchronized fallback, node affinity, and legacy behavior without Bridge metadata.
Changes:
- Adds
prefer_primary_pileconfiguration and priority-aware discovery and connection caching for sync and async drivers. - Adds tests covering pile role changes, fallback behavior, cache admission, endpoint retirement, and affinity.
- Adds documentation, changelog coverage, and a hosted five-scenario Bridge chaos SLO workflow with verification and artifact collection.
| File | Description |
|---|---|
| ydb/resolver.py | Parses Bridge pile metadata and orders discovered endpoints by pile priority. |
| ydb/pool.py | Applies Bridge priorities to synchronous connection selection, eviction, and cache admission. |
| ydb/driver.py | Adds the synchronous prefer_primary_pile driver configuration option. |
| ydb/aio/resolver.py | Propagates Bridge pile preference through asynchronous endpoint discovery. |
| ydb/aio/pool.py | Mirrors priority-aware connection handling and cache behavior for asynchronous drivers. |
| ydb/aio/driver.py | Supports prefer_primary_pile through asynchronous driver configuration. |
| tests/test_discovery_detect_local_dc.py | Tests synchronous Bridge prioritization, fallback, cache behavior, endpoint retirement, and affinity. |
| tests/slo/src/root_runner.py | Uses shared driver configuration construction for SLO workloads. |
| tests/slo/src/options.py | Adds the SLO option and driver configuration helper for Bridge pile preference. |
| tests/slo/requirements.txt | Aligns the OpenTelemetry API dependency version with related packages. |
| tests/slo/README.md | Documents the hosted Bridge SLO workload and acceptance criteria. |
| tests/slo/bridge/verify.py | Verifies chaos scenario completion, workload progress, container state, and collected artifacts. |
| tests/slo/bridge/prepare.py | Prepares the pinned Bridge deployment for bounded hosted-runner resources. |
| tests/slo/bridge/.gitignore | Ignores generated Python cache files. |
| tests/aio/test_discovery_detect_local_dc.py | Tests asynchronous Bridge prioritization, fallback, cache behavior, cancellation, and affinity. |
| docs/driver.rst | Documents prefer_primary_pile and its Bridge routing semantics. |
| CHANGELOG.md | Records the new opt-in Bridge pile preference feature. |
| .github/workflows/slo-2dc.yml | Runs the hosted five-scenario Bridge SLO workload and uploads qualification evidence. |
Review effort: Lite
| if log.count("] Recovered: ") != len(SCENARIOS): | ||
| errors.append("Expected five completed chaos recoveries") |
97f709c to
55cd0da
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The change affects concurrent discovery and request routing while intentionally retiring live connections, so ordering and session-interruption behavior require runtime stress coverage beyond static review.
1 open issue
1 resolved since last review
Review effort: Lite

Add
prefer_primary_piletoDriverConfigfor synchronous and asynchronous drivers. When enabled, PRIMARY/PROMOTED endpoints take priority over SYNCHRONIZED fallback, while clusters without Bridge metadata retain their existing balancing behavior.Discovery refreshes priorities on existing connections when pile roles change. If the cache is full and has no preferred connection, the driver opens a preferred connection before retiring one lower-priority connection. Sessions using the retired connection may be interrupted.