Skip to content

RDBC-1143 RavenDB-27175 Subscriptions - make it easier to inspect the current state - #317

Merged
poissoncorp merged 2 commits into
ravendb:v7.2from
poissoncorp:sdk-sync/RDBC-1143
Oct 22, 2026
Merged

poissoncorp merged 2 commits into
ravendb:v7.2from
poissoncorp:sdk-sync/RDBC-1143

Conversation

@poissoncorp

@poissoncorp poissoncorp commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

SubscriptionWorker now reports what it is doing through status and on_state_changed, and raises an event each time its connection to the server is established.

  • Changed: new SubscriptionWorkerState and SubscriptionWorkerStatus (state, exception, since_utc, failing_since_utc), exported from ravendb. SubscriptionWorker gains status, add_/remove_on_state_changed and add_/remove_on_established_subscription_connection. The run loop sets Connecting, WaitingForDocuments, Processing, Retrying, Faulted and Stopped at the same points as the C# client.
  • Not ported: Stopped on cancellation of the token passed to Run. Python run() takes no token, so stopping goes through close(), which reports Stopped.
  • Tests: new test_ravenDB_27175.py with 5 server tests from RavenDB_27175 and 7 status transition tests that need no server. Skipped: the reflection checks for public API, the reconnection tests that need DropConnectionAsync, and the tests that use the Run cancellation token or SimulateUnexpectedException.
  • Checks: black --check . passed; the 7 transition tests passed; the server tests run only in CI.

Decision needed

The worker waits for the next batch with read_from_server.result(time_to_wait_before_connection_retry), 5 seconds by default. On an idle subscription that wait can time out, and the worker treats the timeout as an error and reconnects. If so, an idle Python worker reports Retrying, Connecting and WaitingForDocuments on every cycle, the established connection event fires each time, and failing_since_utc is set briefly. The C# worker stays in WaitingForDocuments. This is read from the code and not confirmed against a server.

  1. Merge as is and fix the idle read timeout in a separate change (recommended): the status reports what the worker does today, and changing reconnect behavior is a separate behavior change.
  2. Fix the batch wait in this PR before merging.
  3. Do not merge.

Timestamps are naive UTC datetimes, like the worker's existing _last_connection_failure. Timezone-aware UTC is the alternative.


Ticket: RDBC-1143
C# change: ravendb/ravendb#23271

SDK Sync Agent

@poissoncorp

Copy link
Copy Markdown
Contributor Author

The failing check is not caused by this PR. No code change.

A rerun of the failed job should pass. If it fails again, the secured test server setup in CI needs a look.

SDK Sync Agent

@poissoncorp

Copy link
Copy Markdown
Contributor Author

The failing build job is not caused by this PR.

SDK Sync Agent

@poissoncorp

Copy link
Copy Markdown
Contributor Author

The failing check is not caused by this PR. No code change.

SDK Sync Agent

@poissoncorp

Copy link
Copy Markdown
Contributor Author

Merged v7.2 into this branch (561525c) to pick up the test fix from #318. No change to the code of this PR.

  • test_secured_subscription_basic: the tests now wait 15 seconds for a batch instead of 4, longer than the 5-second reconnect delay of the worker.
  • This PR does not change the reconnect delay, so the fix holds with the worker changes here.
  • black --check passes locally. The tests need a server and run only in CI.

SDK Sync Agent

@poissoncorp

poissoncorp commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Merge as is and fix the idle read timeout in a separate change (recommended): the status reports what the worker does today, and changing reconnect behavior is a separate behavior change.

@poissoncorp
poissoncorp merged commit 8a39526 into ravendb:v7.2 Oct 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk-sync Port of C# client changes from an SDK sync task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant