Repository navigation
Add opt-in LISTEN/NOTIFY long polling - #41
Open
Thom Chiovoloni (thomcc-work) wants to merge 6 commits into
Open
Thom Chiovoloni (thomcc-work) wants to merge 6 commits into
Thom Chiovoloni (thomcc-work) wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Unresolved wakeup gaps and schema-wide listener recovery require fixes and PostgreSQL-backed human validation.
2 open issues
What changed in this PR
Adds opt-in notification-driven long polling to the PostgreSQL provider while preserving short polling by default.
Changes:
- Adds listener recovery, bounded timer tracking, and long-poll configuration.
- Installs disabled notification triggers with explicit schema-wide activation.
- Adds integration coverage, CI validation, and operational documentation.
| File | Description |
|---|---|
| tests/postgres_provider_test.rs | Enables validation in either polling mode. |
| tests/long_poll_tests.rs | Adds integration tests and an idle-query benchmark. |
| src/provider.rs | Integrates configuration and long-poll fetches. |
| src/notifier.rs | Implements listeners, timers, recovery, and waiting. |
| src/migrations.rs | Adds notification activation and verification. |
| src/lib.rs | Exports and documents long-poll configuration. |
| README.md | Documents usage and operational limitations. |
| migrations/README.md | Documents activation and test commands. |
| migrations/0027_diff.md | Records migration changes. |
| migrations/0027_add_long_poll_notifications.sql | Installs disabled triggers and updates cleanup. |
| docs/migration-policy.md | Explains activation and compatibility. |
| CHANGELOG.md | Records the unreleased feature. |
| Cargo.toml | Raises the SQLx minimum to 0.8.3. |
| .github/workflows/test.yml | Runs validation with long polling enabled. |
Review effort: Balanced
Thom Chiovoloni (thomcc-work)
force-pushed
the
thomcc/long-polling
branch
from
October 26, 2026 16:05
52557ef to
e2fba14
Compare
Thom Chiovoloni (thomcc-work)
marked this pull request as ready for review
October 26, 2026 16:46
Thom Chiovoloni (thomcc-work)
force-pushed
the
thomcc/long-polling
branch
from
October 29, 2026 17:02
e2fba14 to
60a2bb9
Compare
- Future-dated lease hints, including session expiry, plus immediate release hints for delayed abandonment. - Warm fetch connections, bounded timer scans, and independent degraded-mode fallback. - Bounded, jittered migration/activation retries with rollback and deadlock regressions. - Updated trigger inventory, deterministic catch-up coverage, and a reproducible benchmark driver.
3 of 7 tasks
Run timer reads in transactions with server-side lock and statement timeouts. Retain one owned scan across client watchdog wakeups and listener reconnects instead of cancelling and replacing an in-flight query. Add the supplied backend-accumulation regression, connection-reuse and single-flight coverage, and a timer wake deadline that cannot pass through the polling fallback. Addresses review items 41-N1 and 41-N5. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Place long-poll notification DDL after the pending 0027-0029 migrations, preserving migration 0028's prune_executions_batch cleanup and companion diff baseline. Update upgrade tests and documentation without stacking the prerequisite PRs. Include SQLSTATE and the full context chain in DDL retry warnings, test those diagnostics, and document draining writers and retrying ApplyAll when the fixed contention budget expires. Validated the intended predecessor sequence in an isolated source copy. Addresses 41-C1, 41-N3, and 41-N4. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a 16+16 dispatcher, 64-client profile with sampled notification-commit and synchronous-replication wait time. Exercise workflow claims and saturated orchestration, activity, and session renewals with verified synchronous-standby and pool-capacity preconditions. Document notification-bearing operations and reproducible benchmark methodology without publishing performance results from uncontrolled runs. Include timer transaction control in idle SQL counts. Addresses review item 41-N2. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
This is part of an effort to make duroxide-pg-opt redundant, although it stands on its own and has its own benefits, so I'm PRing it separately. It's a draft until I finish AI review.
Adds notification-driven long-polling for orchestration and activity work, adapted from
duroxide-pg-opt. Existing constructors continue to use short polling by default. The goal is to reduce empty-queue queries and polling-induced latency without changing queue eligibility, locking, or acknowledgment semantics.The same configuration is supported for Entra-authenticated connections.
Implementation
Migration and activation
Migration 0027 installs disabled notification triggers. Notifications are activated schema-wide only when a provider is constructed with both
MigrationPolicy::ApplyAlland long-polling enabled.VerifyOnlyperforms no DDL and requires prior activation. Activation is atomic, follows acknowledgment lock ordering, and retries bounded lock contention. Disabling an individual provider's listener does not disable shared triggers.Long-polling reserves one connection within the configured pool, so at least two connections are required. Client-only providers can leave it disabled.
This remains a normal forward migration: older binaries reject unknown migration versions even when notifications are disabled. It does not convert databases using the incompatible
duroxide-pg-optmigration history.Performance
Local release-mode measurements used PostgreSQL 17.11 without assertions or memory wiping, normal durability settings, and the same Duroxide 0.1.32 runtime configuration.
The loaded figures are medians across three repetitions. These are local engine-level measurements, not production capacity estimates. An ignored idle-query benchmark is included for reproduction.
Operational considerations
PREPARE TRANSACTION. Schemas that have not opted in retain their previous behavior.