DurableTask.PostgreSQL 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DurableTask.PostgreSQL --version 2.0.0
                    
NuGet\Install-Package DurableTask.PostgreSQL -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DurableTask.PostgreSQL" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DurableTask.PostgreSQL" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DurableTask.PostgreSQL" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DurableTask.PostgreSQL --version 2.0.0
                    
#r "nuget: DurableTask.PostgreSQL, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DurableTask.PostgreSQL@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DurableTask.PostgreSQL&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DurableTask.PostgreSQL&version=2.0.0
                    
Install as a Cake Tool

PostgreSQL Provider for Durable Task Framework (Standalone)

DurableTask.PostgreSQL is a PostgreSQL-backed storage provider for the Durable Task Framework (DTFx), focused on the standalone runtime scenario.

This repository follows the same overall direction as microsoft/durabletask-mssql, but targets PostgreSQL and currently concentrates on standalone DTFx support.

Why this provider

  • PostgreSQL portability: run on local environments, managed cloud PostgreSQL services, or self-hosted clusters.
  • Data ownership: orchestration runtime data lives in your database and can be managed with your existing backup and governance processes.
  • Operational visibility: SQL scripts and schema are part of this repository, making runtime behavior easier to inspect and operate.

Package

Package Description
DurableTask.PostgreSQL Standalone DTFx provider for PostgreSQL

Project file: src/DurableTask.PostgreSQL/DurableTask.PostgreSQL.csproj

Upgrading to 2.0

Recompile applications when upgrading from 1.x. Settings properties now have mutable setters, which fixes the DI configuration callback but changes their binary signatures. Configure settings before constructing the service; live reconfiguration is unsupported.

Current scope

  • Standalone DTFx backend (IOrchestrationService and IOrchestrationServiceClient)
  • PostgreSQL schema + logic scripts shipped with the package
  • Integration-test coverage for core orchestration flows

Feature support & known limitations

This is a port in progress toward parity with the microsoft/durabletask-mssql 1.x reference. To set expectations clearly:

Supported and integration-tested:

  • Create / get-state / get-history for orchestrations
  • Activity execution (schedule + complete)
  • Durable timers
  • ContinueAsNew (orchestration loops with a new execution id)
  • Sub-orchestration (nested orchestrations with result propagation)
  • External events raised via the client, with the orchestrator waiting via the OnEvent pattern
  • Purge by filter and by instance id
  • Orchestration query (GetOrchestrationWithQueryAsync)
  • Multi-tenancy via task hubs (TaskHubName)
  • Concurrent-deploy safety (schema creation retries on contention)

Known limitations (not yet at parity):

  • Durable entities: not implemented (the MSSQL provider's entity feature has no PostgreSQL equivalent yet). Tracked in #4, without a committed release date.
  • Schema migrations: forward migrations are supported. The baseline (schema.postgresql.sql) is applied idempotently for fresh installs; subsequent upgrades are applied from embedded Scripts/migrations/migration-{semver}.postgresql.sql resources in semantic-version order, each recorded in dt.versions. Migrations must use idempotent DDL (ADD COLUMN IF NOT EXISTS, CREATE TYPE IF NOT EXISTS, etc.).
  • Tags: OrchestrationState.Tags is a non-null empty dictionary but tags are not persisted (no schema column).
  • Least-privilege role: no dt_runtime-style role/GRANT model yet; connect with a user that can create the schema.

If any of the above is a blocker for your use case, please open an issue.

Quick start

Install package:

dotnet add package DurableTask.PostgreSQL

Register with DI:

using DurableTask.PostgreSQL;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();

services.AddDurableTaskPostgreSql(new PostgreSqlOrchestrationServiceSettings
{
    ConnectionString = "Host=localhost;Port=5433;Database=durabletask;Username=postgres;Password=postgres",
    SchemaName = "dt",
    TaskHubName = "sample-hub",
    AutoDeploySchema = true
});

Npgsql configuration

Everything configurable through a connection string works as-is. For Npgsql features a connection string cannot express — rotating-token auth (AWS RDS IAM, Azure Entra), client certificates, a logger factory, tracing — use ConfigureDataSource to configure the data source the provider builds:

services.AddDurableTaskPostgreSql(new PostgreSqlOrchestrationServiceSettings
{
    // Note: no Password= here. Npgsql throws NotSupportedException ("When registering a
    // password provider, a password or password file may not be set") if the connection
    // string carries a password and the callback also registers a password provider.
    ConnectionString = "Host=db.example.com;Database=durabletask;Username=app",
    TaskHubName = "orders-hub",
    ConfigureDataSource = builder =>
    {
        builder.UsePeriodicPasswordProvider(
            (csb, ct) => tokenProvider.GetTokenAsync(ct),
            successRefreshInterval: TimeSpan.FromMinutes(50),
            failureRefreshInterval: TimeSpan.FromSeconds(5));
        builder.UseLoggerFactory(loggerFactory);
    }
});

The provider passes ConnectionString to the builder before invoking your callback, so the connection string and the callback must not both supply the same credential: omit Password (and Passfile) whenever you register UsePasswordProvider or UsePeriodicPasswordProvider.

The provider keeps ownership of the pool, and re-applies TaskHubName as the connection's ApplicationName after your callback runs — so a shared configuration helper that sets ApplicationName cannot silently repoint the task hub. The callback does not apply to schema deployment, so a deployment that authenticates only through such a callback must deploy the schema out of band (leave AutoDeploySchema at its default of false).

The provider cannot accept a pre-built NpgsqlDataSource: its composite type mappings use internal CLR types a caller cannot register, and sharing the pool would make task hub isolation and pool disposal unsafe. See DATASOURCE.md for the full connection model, limits, and verification queries.

Polling and backoff

The provider polls PostgreSQL for work. When a poll finds nothing, it waits before trying again, using randomized exponential backoff between MinWorkItemPollingInterval and WorkItemPollingInterval. This matters because each poll runs as a transaction that commits even when it returns no rows, so polling without a delay inflates pg_stat_database.xact_commit and puts needless load on the server while the task hub is idle.

The backoff does not delay real work: creating an instance, raising an external event, completing an activity, or checkpointing an orchestration that enqueued work all signal the relevant poller, which wakes immediately and resets to the minimum interval.

Setting Default Purpose
MinWorkItemPollingInterval 50 ms Delay after the first poll that finds no work, and the interval returned to once work appears.
WorkItemPollingInterval 1 s Upper bound. An idle worker settles here (one poll per interval, per dispatcher).
DeltaBackoffWorkItemPollingInterval 50 ms Growth increment applied as successive polls come back empty.

Raise WorkItemPollingInterval to reduce load from idle workers; lower MinWorkItemPollingInterval to shave latency on a busy task hub. MinWorkItemPollingInterval must not exceed WorkItemPollingInterval — the constructor rejects that combination.

Database scripts

The provider ships SQL scripts at:

  • src/DurableTask.PostgreSQL/Scripts/schema.postgresql.sql
  • src/DurableTask.PostgreSQL/Scripts/logic.postgresql.sql

These scripts are also packed in NuGet as content files.

Local development

Restore/build:

dotnet restore src/DurableTask.PostgreSQL/DurableTask.PostgreSQL.csproj
dotnet build src/DurableTask.PostgreSQL/DurableTask.PostgreSQL.csproj -c Release

Run tests:

dotnet test tests/DurableTask.PostgreSQL.Tests/DurableTask.PostgreSQL.Tests.csproj -c Release

By default, integration tests use:

Host=localhost;Port=5433;Database=durabletask;Username=postgres;Password=postgres

Or set POSTGRES_CONNECTION_STRING to override.

Sample app

A minimal consumer exists in:

samples/ConsumerApp

Run it with:

dotnet run --project samples/ConsumerApp/ConsumerApp.csproj

Releases

NuGet publishing is automated by GitHub Actions in .github/workflows/publish-nuget.yml.

Triggers:

  • Pull Request and Push (main/vnext/desenv): build + pack validation
  • Tag push v*: build + publish to NuGet.org
  • Manual (workflow_dispatch): optional publish when publish=true

For trusted publishing, configure:

  • NuGet.org trusted publisher for this GitHub repository/workflow
  • GitHub secret NUGET_ORG_USERNAME with the owner username at NuGet.org

Contributing

Contributions are welcome. Open an issue to discuss proposals and behavior changes before large PRs.

Please review Code of Conduct before contributing.

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 117 11/14/2026
2.0.0 109 11/14/2026
1.0.4 1,834 11/3/2026
1.0.3 892 10/19/2026
1.0.2 151 9/20/2026
1.0.1 149 9/18/2026
1.0.0 149 7/31/2026
1.0.0-alpha.3 829 7/4/2026
1.0.0-alpha.2 119 6/16/2026
1.0.0-alpha.1 231 3/31/2026