Repository navigation
HTTP policy control (concurrency, etc) - #429
Open
Thom Chiovoloni (thomcc-work) wants to merge 11 commits into
Open
Thom Chiovoloni (thomcc-work) wants to merge 11 commits into
Thom Chiovoloni (thomcc-work) wants to merge 11 commits into
Conversation
Thom Chiovoloni (thomcc-work)
force-pushed
the
thomcc/policies
branch
2 times, most recently
from
October 29, 2026 14:33
d363447 to
ff6c0f8
Compare
Thom Chiovoloni (thomcc-work)
force-pushed
the
thomcc/policies
branch
from
October 29, 2026 20:58
ff6c0f8 to
21b6e00
Compare
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The runtime pin relies on an unmerged dependency and changes admission, shutdown, and replay behavior, requiring PostgreSQL shutdown, epoch-replacement, HTTP restart, and N-1 replay integration results beyond source inspection.
No open issues 🎉
What changed in this PR
Adds server-wide and workflow-scoped HTTP concurrency controls to pg_durable’s shared runtime, with durable queue deferral when capacity is unavailable. The PR depends on the admission support in microsoft/duroxide#74.
Changes:
- Adds configurable activity and HTTP limits, plus composable subtree policies through
df.with_policy(). - Integrates admission checks and shutdown-interruptible runtime initialization.
- Adds concurrency, cancellation, and restart tests, alongside API and operational documentation.
| File | Description |
|---|---|
USER_GUIDE.md |
Explains concurrency settings, workflow policies, and limitations. |
tests/e2e/sql/92_http_restart.sql |
Tests interrupted HTTP recovery and persisted policy enforcement. |
tests/e2e/sql/91_http_policies.sql |
Tests nested scopes, independent budgets, loops, and races. |
tests/e2e/sql/90_http_concurrency.sql |
Tests global limits, cancellation, SQL headroom, and permit lifetimes. |
tests/e2e/http_origin_server.py |
Adds gated responses and concurrency counters. |
src/worker.rs |
Configures runtime capacity and interruptible startup. |
src/types.rs |
Carries policies and materializes HTTP scope metadata. |
src/registry.rs |
Registers admission hooks for both HTTP activities. |
src/policies.rs |
Implements policy validation, scope accounting, and admission guards. |
src/lib.rs |
Registers concurrency settings and adds integration tests. |
src/explain.rs |
Displays HTTP scope limits in graph explanations. |
src/dsl.rs |
Adds the df.with_policy() graph helper. |
sql/pg_durable--0.2.9--0.2.10.sql |
Exposes the policy helper during extension upgrades. |
scripts/test-e2e-local.sh |
Runs HTTP concurrency scenarios and restart orchestration. |
scripts/test-e2e-docker.sh |
Skips tests requiring the local TLS fixture. |
docs/upgrade-testing.md |
Documents schema compatibility, replay behavior, and validation. |
docs/multi-database-installation.md |
Updates runtime shutdown guarantees and remaining limitations. |
docs/http-security.md |
Explains capacity enforcement and its security boundaries. |
docs/grammar.md |
Documents policy annotations in the DSL grammar. |
docs/E2E_TESTING.md |
Lists the new HTTP test scenarios. |
docs/api-reference.md |
Documents the policy API and concurrency settings. |
CHANGELOG.md |
Records HTTP limits, policies, and startup shutdown handling. |
Cargo.toml |
Updates Duroxide and pins the temporary admission revision. |
Cargo.lock |
Locks the updated runtime dependency graph. |
.agents/skills/pg-durable-sql/SKILL.md |
Adds workflow policy syntax and usage guidance. |
Review effort: Balanced
Thom Chiovoloni (thomcc-work)
marked this pull request as ready for review
November 3, 2026 15:37
Still pinned via git.
Pinned to 9ae067b, alongside the merged duroxide revision. Changes: - Updated the provider dependency and lockfile. - Advanced WORKER_SCHEMA_VERSION to 4 for the bundled migrations. - Added a 500-request backlog regression. - Updated migration, rollout, and behavior documentation.
Address review 429-1 using the documented disposable-database alternative. The current provider pin records migration 0029 without the pending 0027/0028 prefix; do not disguise this by changing readiness or migration ledger rows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address review 429-3 with the supplied full-stack measurement, its workload and limits. Keep retry-delay policy unchanged as requested; tuning latency versus database load remains follow-up work. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address review 429-2: recover poisoned admission locks without resetting reservations, make counter cleanup non-panicking with saturating decrements, and log invariant faults. Add tests for poisoned admission/release and inconsistent counters. Validation: build and Clippy passed; 469 unit tests passed (16 ignored); all 91 E2E tests passed through the shared PostgreSQL lock-aware runners. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address review 429-4 by checking the submitting role against every required HTTP overload in the origin database. Share signature selection with activity-time checks, cache repeated checks per graph, and preserve SQLSTATE 42501 for independent starts. Retain execution-time authorization for revocation and historical work. Cover raw and nested graphs, all four overloads, both transaction modes, hostile search paths, inherited grants, definer identity, no persisted submission on denial, satellite isolation and post-submission revocation. Build, Clippy, unit and authorization regressions pass; the corrected satellite test and all 177 upgrade checks pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace both Git overrides with exact crates.io dependencies. The former provider could publish readiness 4 without applying migrations 0027 and 0028. Require readiness 5 before accepting new work; installing the full migration sequence does not enable long polling. Document the drained upgrade from released versions separately from PR-only stores that recorded 0029 out of order and cannot upgrade in place. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
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
Give administrators a ceiling on outbound HTTP concurrency and let a workflow set a lower ceiling for itself or a subtree. When a request cannot run yet, it stays in the durable queue rather than waiting inside an activity slot.
pg_durable.max_activity_concurrency2pg_durable.max_http_concurrencydf.http()anddf.http_multipart()combined, across all users and origin databases2Both settings require a PostgreSQL restart. The defaults preserve the existing two-activity capacity. Set the HTTP ceiling below total activity capacity to leave slots available for other work.
Workflow policies
In this example, only one of the two HTTP requests can run at a time. Each request reserves capacity against the server ceiling and every enclosing scope, or takes no capacity at all. An inner policy cannot raise an outer limit. Parallel branches and loop iterations share their enclosing scopes, including after restart; separate workflow starts have independent local budgets.
df.explain()shows which scopes apply.Admission and authorization
df.start()checks the submitter's HTTP privileges in the origin database before enqueueing, including for raw graphs and untaken branches. A missing grant raises42501in either transaction mode. Activities still recheck privileges before sending, so a later revocation takes effect.Dependencies and upgrade
The PR uses the released duroxide 0.2.0 and duroxide-pg 0.2.0 crates. There are no Git overrides or pending upstream dependencies.
0027/0028, including clients, workers, maintenance jobs, and direct SQL callers. Start the new control worker first and wait for readiness5before resuming traffic. Allow time and WAL space for the continue-as-new timestamp backfill and plan for the0029queue-index lock.0030installs disabled notification triggers; long polling remains off.ALTER EXTENSION pg_durable UPDATE TO '0.2.10'fordf.with_policy(). Unconfigured HTTP payloads keep their existing bytes; policies add no orchestration operations to replay.0029without0027/0028. Development stores with that gap cannot upgrade in place; do not edit the migration ledger. This caveat does not apply to fresh installations or upgrades from released pg_durable versions. See the rollout and prerelease-store guidance.Validation
Local PostgreSQL 17 checks used the shared test lock and a disposable cluster:
0027,0028,0029, and0030in order, published readiness5, and had all six notification triggers disabled.