Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/slo-2dc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Hosted 2DC SLO

on:
pull_request:
paths:
- .github/workflows/slo-2dc.yml
- tests/slo/**
- ydb/driver.py
- ydb/resolver.py
- ydb/pool.py
- ydb/aio/driver.py
- ydb/aio/pool.py
workflow_dispatch:
inputs:
server_image:
description: YDB server image to qualify (resolved to a digest)
default: cr.yandex/crpb3d0up7s6a7iuofo9/ydb-appteam-ci/local-ydb:trunk
required: true

permissions:
contents: read

jobs:
bridge:
runs-on: ubuntu-24.04
timeout-minutes: 30
concurrency:
group: hosted-2dc-${{ github.ref }}
cancel-in-progress: true
env:
WORKLOAD_MEMORY_LIMIT: 1G
WORKLOAD_CPU_LIMIT: '1.00'
WORKLOAD_CURRENT_IMAGE: py-slo-bridge:current
REQUESTED_IMAGE: ${{ inputs.server_image || 'cr.yandex/crpb3d0up7s6a7iuofo9/ydb-appteam-ci/local-ydb@sha256:bce9caa6a1a6aac9b513510b46f61c4d4b58c1f88d937bcb54c20dc1bda6c8d4' }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: ydb-platform/ydb-slo-action
ref: 54c3c03de1ce8c6a2d8b0828b328bd5db82ef2bb
path: .slo-action
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install the Compose version required by the action
run: |
set -euo pipefail
mkdir -p "$HOME/.docker/cli-plugins"
curl -fsSL --retry 3 \
https://github.com/docker/compose/releases/download/v2.40.3/docker-compose-linux-x86_64 \
-o "$HOME/.docker/cli-plugins/docker-compose"
chmod +x "$HOME/.docker/cli-plugins/docker-compose"
docker compose version
docker compose up --help | grep -F -- --quiet-build
- name: Record runner and resolve server image
run: |
set -euo pipefail
mkdir -p bridge-artifacts
free -h
df -h
docker version
docker compose version
docker pull --platform linux/amd64 "$REQUESTED_IMAGE"
docker image inspect "$REQUESTED_IMAGE" > bridge-artifacts/server-image.json
SERVER_IMAGE=$(docker image inspect --format '{{index .RepoDigests 0}}' "$REQUESTED_IMAGE")
printf '%s\n' "$SERVER_IMAGE" > bridge-artifacts/server-image.txt
python tests/slo/bridge/prepare.py .slo-action "$SERVER_IMAGE"
- name: Build current Python SDK workload
run: docker build -f tests/slo/Dockerfile -t py-slo-bridge:current .
- name: Run all five Bridge scenarios
id: slo
uses: ./.slo-action/init
timeout-minutes: 20
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workload_name: sync-query
workload_duration: '600'
workload_current_ref: current
workload_current_image: py-slo-bridge:current
workload_current_command: >-
--read-rps 50 --write-rps 10 --read-threads 2 --write-threads 2
--read-timeout 30000 --write-timeout 30000
--prefer-primary-pile
bridge_mode: true
disable_compose_profiles: extra-nodes
fail_on_workload_error: true
- name: Verify scenario coverage and workload recovery
if: always()
timeout-minutes: 3
env:
ACTION_OUTCOME: ${{ steps.slo.outcome }}
run: python tests/slo/bridge/verify.py
- name: Upload qualification evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: python-hosted-2dc
path: bridge-artifacts/
retention-days: 14
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Add opt-in PRIMARY/PROMOTED Bridge pile preference with synchronized-pile fallback for sync and async drivers
* Fix automatic refresh of short-lived login tokens by using their JWT expiration time.

## 3.35.0 ##
Expand Down
34 changes: 34 additions & 0 deletions docs/driver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ DriverConfig
* - ``discovery_request_timeout``
- ``10``
- Timeout in seconds for each discovery request.
* - ``prefer_primary_pile``
- ``False``
- Prefer PRIMARY/PROMOTED Bridge endpoints with synchronized-pile fallback; no effect without Bridge metadata.
* - ``table_client_settings``
- ``None``
- :class:`~ydb.TableClientSettings` instance to configure the Table service client.
Expand All @@ -62,6 +65,37 @@ DriverConfig
- gRPC-level compression (e.g. ``grpc.Compression.Gzip``).


Preferring the primary Bridge pile
----------------------------------------

Set ``prefer_primary_pile`` on the ``DriverConfig`` passed to the sync or async driver.

.. code-block:: python

config = ydb.DriverConfig(
endpoint="grpc://discovery.example:2135",
database="/Root/mydb",
prefer_primary_pile=True,
)
driver = ydb.Driver(config)

While discovery reports Bridge pile states, the driver tries PRIMARY and PROMOTED
endpoints first, followed by SYNCHRONIZED endpoints, then endpoints in other or
unknown states. This order applies to connection attempts and to unbound requests
for either value of ``use_all_nodes``. Endpoints within a tier have equal priority
regardless of their datacenter. The driver updates priorities when discovery reports a role change.
When a discovery response contains no pile states, the driver resumes its
configured balancing policy for both existing and new connections.
The option controls client-side routing and is disabled by default.

If the connection cache is full and none of its connections lead to a PRIMARY
or PROMOTED pile, discovery opens a connection to a preferred endpoint before
closing one lower-priority connection. Sessions using that connection can be
interrupted. Once the cache has a preferred connection, additional endpoints
can join as slots become available. Existing sessions keep their node affinity
while their connection is available.


Creating a Driver
-----------------

Expand Down
Loading
Loading