Upgrading
Upgrading to v1.9.0
go get github.com/dbos-inc/dbos-transact-golang@v1.9.0
If your application imports go.dbos.dev/dbos-enterprise-go, upgrade it to the same minor version:
go get go.dbos.dev/dbos-enterprise-go@v1.9.0
This release adds system-database migrations (including a suspend_key column and new indexes on workflow_status), applied by the first NewContext; if your application sets Config.SkipMigrations, run Migrate first. Changes that may require action:
- Go 1.26 is required. The module now declares
go 1.26.0. pgxis upgraded from v5.10.0 to v5.13.0, which changes how special characters in connection strings are parsed. In particular, a+in a query parameter value ofDatabaseURLis now read literally, not as a space: encode spaces as%20.Shutdownno longer closes a connection pool you supplied. A pool passed asConfig.SystemDBPoolorConfig.SQLiteSystemDBnow stays open afterShutdown, so an application sharing it with DBOS can keep using it: close it yourself once you are done. Pools DBOS creates fromDatabaseURLare still closed.- The
ContextandClientinterfaces gained methods.RecvandSleeptake variadic options,ContextaddsGetShardKey, andClientaddsBindShardKeyandBindShardKeys. Calls through the package-level functions are unchanged, but mocks and other implementations of these interfaces must be regenerated; see Testing & Mocking. - Prefix filters are literal.
WithFilterWorkflowIDPrefixandWithScheduleNamePrefixesno longer treat_and%in a prefix as wildcards.
New features:
- Suspending workflows. A DBOS Transact Enterprise feature that suspends a workflow during a long
SleeporRecv, so it uses no memory, goroutines, or queue capacity until it wakes. SetConfig.SuspendMode, then passWithSleepSuspend()toSleeporWithRecvSuspend()toRecv; the workflow function must return the error they return, which matches the newErrWorkflowSuspended. Suspended workflows have the newSUSPENDEDstatus (WorkflowStatusSuspended). See Suspending Workflows. - Sharding. A DBOS Transact Enterprise feature that spreads the system database across multiple Postgres servers behind a sharding layer such as Citus or PgDog. Set
Config.Sharding(andClientConfig.Shardingon clients), then assign every workflow a shard key withWithShardKeyorWithEnqueueShardKey, and address existing workflows withBindShardKey. See Sharding.
Both features require importing go.dbos.dev/dbos-enterprise-go and an entitled DBOS key, Config.TransactEnterpriseKey or ConductorAPIKey standing in for it; see DBOS Transact Enterprise.
Upgrading to v1.8.0
go get github.com/dbos-inc/dbos-transact-golang@v1.8.0
If your application imports go.dbos.dev/dbos-enterprise-go, upgrade it to the same minor version:
go get go.dbos.dev/dbos-enterprise-go@v1.8.0
v1.8.0 is additive: existing code keeps compiling. This release adds system-database migrations (indexes on application_versions), applied by the first NewContext. New APIs and behavioral changes:
- Auto-upgrade. A DBOS Transact Enterprise feature that moves workflows left on older application versions to the latest one, so each deployment can run under its own version without keeping old processes around to drain. Enable it for every workflow with
Config.AutoUpgrade, or per workflow with theWithAutoUpgrade(bool)registration option, and tune it withConfig.AutoUpgradeIntervalandConfig.AutoUpgradeGracePeriod. It requires importinggo.dbos.dev/dbos-enterprise-goand an entitled DBOS key,Config.TransactEnterpriseKeyorConductorAPIKeystanding in for it;NewContext(orLaunch) fails with an error saying what is missing otherwise. See Auto-Upgrading Workflows and DBOS Transact Enterprise. Config.EnablePatchingis deprecated.PatchandDeprecatePatchno longer require it, andErrorCodePatchingNotEnabledis no longer returned. The flag now only pins the application version toPATCHING_ENABLED, so every deployment shares one version, andNewContextlogs a warning when it is set. To keep that behavior, setConfig.ApplicationVersionexplicitly; to give each deployment its own version instead, enable auto-upgrade.- New
WithMergeAttributes()option onSetWorkflowAttributes, shallow-merging the given top-level keys into a workflow's attributes in one update instead of replacing them.SetWorkflowAttributesis variadic now, so existing calls are unchanged. - Portable workflow inputs. New
WithEnqueuePortableWorkflow()option onEnqueue, storing the enqueued workflow's input in the portable JSON envelope so it runs as a portable workflow when dequeued; passing aPortableWorkflowArgsinput still implies it. A child workflow started from a portable workflow, or a workflow enqueued or debounced from one, is now stored in its own format (portable only when it is itself started withWithPortableWorkflow, enqueued withWithEnqueuePortableWorkflow, or given aPortableWorkflowArgsinput), where it used to be tagged as portable while its input was stored without the envelope, so that a struct input could decode to its zero value on dequeue or recovery.
Upgrading to v1.7.0
go get github.com/dbos-inc/dbos-transact-golang@v1.7.0
-
Connecting to Conductor requires importing
go.dbos.dev/dbos-enterprise-go. The Conductor client is no longer part ofgithub.com/dbos-inc/dbos-transact-golang. An application that setsConfig.ConductorAPIKey, or that runs in DBOS Cloud, must add the import once, anywhere in the program, aftergo get go.dbos.dev/dbos-enterprise-go:import ("github.com/dbos-inc/dbos-transact-golang/dbos"_ "go.dbos.dev/dbos-enterprise-go")Conductor configuration is unchanged. Without the import,
NewContextfails with an initialization error saying what to add. Applications that do not connect to Conductor need no change. See Connecting to Conductor. -
Transient database errors in transactions are no longer checkpointed. A transient database error (a connection failure, or a serialization or deadlock conflict) returned by a
RunAsTransactionfunction is now retried with a fresh transaction instead of being treated as an application error: it does not consume the step's retry budget and is never durably recorded as the step's error, so a transient failure can no longer fail a workflow for good. Application errors still follow the step retry policy.
Upgrading to v1.6.0
go get github.com/dbos-inc/dbos-transact-golang@v1.6.0
v1.6.0 is additive: existing code keeps compiling. Behavioral changes and new APIs:
- Workflow ownership (fencing tokens). Every execution of a workflow now holds a fencing token, so an execution that lost ownership (because the workflow was recovered, resumed, rewound, or cancelled elsewhere) can no longer checkpoint over the current owner. Its next DBOS operation returns an error matching
dbos.ErrConflictingWorkflowID; return it from the workflow and the execution adopts the owner's outcome. A step run withGothat completes after its workflow has completed is discarded. See Concurrent Executions. - New error code
ErrorCodeStepNondeterminism/ErrStepNondeterminism, returned when an execution records a step ID it had already recorded with a different result (a non-deterministic workflow function). - Workflow ID reuse policies. Starting a workflow with an ID that already exists still returns a handle to the existing workflow by default (
WorkflowIDReusePolicyReturnExisting). PassWithWorkflowIDReusePolicy(dbos.WorkflowIDReusePolicyReject)(orWithEnqueueWorkflowIDReusePolicyonEnqueue) to get an error matching the newdbos.ErrWorkflowIDInUseinstead. The reject policy cannot be used with a debouncer. - Workflow timeouts are enforced by a monitor. Every launched process runs a monitor that durably cancels this application's workflows past their deadline, including ones no process is executing, and cancels the
Contextof those running locally. The monitor polls once per second, so a workflow'sContextmay be cancelled up to a second after its deadline. An execution parked on a conflicting ID now waits on the root context (cancelled only byShutdown), so a caller may wait longer than the context's nominal timeout for the durable workflow's outcome. - Child workflows inherit their parent's deadline. A child started under its parent's context now carries the parent's deadline from the start, even when enqueued (it used to start its own timeout at dequeue). Pass a context from
WithoutCancelor a shorterWithTimeoutto detach it, as before. - New
WithDeadlineCause(ctx, deadline, cause), the absolute-deadline counterpart ofWithTimeout; see the context reference. - Self-recovery is skipped when Conductor is configured. When
ConductorAPIKeyis set or the application runs in DBOS Cloud,Launchno longer recovers this executor'sPENDINGworkflows itself; Conductor drives recovery. Applications without Conductor are unchanged. - Idle-in-transaction timeout. DBOS now sets Postgres's
idle_in_transaction_session_timeouton the connections it creates, toConfig.SystemDBIdleTransactionTimeout(also onClientConfig; default 1 minute). Set it to a negative duration to keep the server's setting. - Datasource migrations. A datasource's
transaction_completiontable is now versioned by adbos_transaction_completion_migrationstable, created or migrated byNewDataSource. New:MigrateDataSourcemigrates the schema out of band with a privileged role (WithMigrateApplicationRolegrants a role the runtime permissions:SELECT,INSERT,DELETEontransaction_completionandSELECTon the version table);WithDataSourceSkipMigrationsmakesNewDataSourceverify the schema instead of migrating it;DataSourcePermissionStatementsreturns the grants. A table pre-created by hand under the old scheme is adopted by the first migration, which needs DDL privileges once to create the version table. Likewise,MigrateandMigrationStatementsnow migrate the system database from code, which is whatdbos migrateruns. - New
Config.ConductorMetadataOnlyMode: send only workflow metadata to Conductor, never workflow data, regardless of the console setting. See Connecting to Conductor. - New
dbos.GetAuthenticatedUser(ctx), returning the current workflow's authenticated user from a workflow or one of its steps. See the reference. - New
WithSendToForks()option onSendandSendBulk, delivering a message to every workflow recursively forked from the destination. See the reference. - New
WithFilterIsFork(bool)filter onListWorkflows, selecting workflows that are (or are not) forks of another workflow.
Upgrading to v1.5.0
go get github.com/dbos-inc/dbos-transact-golang@v1.5.0
NewDataSourcemust be called beforeLaunch. On aContextcreated withNewContext, creating a datasource after launch now returns an error (it used to be allowed at any time). The context tracks every datasource created on it so that rewinding a workflow also deletes the transaction checkpoints it holds.NewDataSourcenow takes aClient, so a standalone client can create datasources too, at any time.- New
RewindWorkflow. Re-execute a workflow from a given step while keeping its workflow ID, on aContextor aClient, with optionsWithRewindStartStep,WithRewindApplicationVersion,WithRewindQueue,WithRewindQueuePartitionKey, andWithRewindDataSources. See Rewinding Workflows and the reference. This release adds system-database migrations (index changes and aconsumed_by_function_idcolumn onnotifications), applied by the firstNewContext. - Panics in workflows are recovered. A panic in a workflow function, or in a step run with
Go, no longer crashes the process: DBOS recovers it, logs it with its stack, and records it as the workflow's error under the newErrorCodeWorkflowPaniccode (dbos.ErrWorkflowPanic). When the panic value is anerror, it is wrapped, soerrors.Is/errors.Asstill reach it. Code that relied on a workflow panic terminating the process must now check the workflow's error.
Upgrading to v1.0.0
This guide covers migrating an application from the last v0.x release to v1.0.0:
go get github.com/dbos-inc/dbos-transact-golang@latest
v1 is a breaking release. The sections below cover every breaking change; §10 suggests an order to apply them in.
1. Core renames: DBOSContext → Context
The central interface was renamed. This is the highest-volume change and is purely mechanical:
| v0 | v1 |
|---|---|
dbos.DBOSContext | dbos.Context |
dbos.NewDBOSContext(ctx, cfg) | dbos.NewContext(ctx, cfg) |
Config.SqliteSystemDB | Config.SQLiteSystemDB |
Workflow and step signatures change accordingly:
// v0
func myWorkflow(ctx dbos.DBOSContext, input string) (string, error)
// v1
func myWorkflow(ctx dbos.Context, input string) (string, error)
Shutdown now returns an error (non-nil if the timeout expired before all resources stopped). Use the package-level functions for launch and shutdown — like the other interface methods, Shutdown now takes a leading Client receiver-argument, so method-form calls must be migrated:
// v0
ctx.Launch()
ctx.Shutdown(30 * time.Second)
// v1
err := dbos.Launch(ctx)
err := dbos.Shutdown(ctx, 30*time.Second) // accepts Client or Context
Behavioral (no code change): Launch() now recovers this executor's PENDING workflows before starting the queue runner and scheduler.
Behavioral (no code change): a failed Launch() is now terminal — the context is torn down (system database closed) and cannot be relaunched. Code that retried Launch on the same context after a transient failure must create a fresh context with NewContext for each attempt.
2. Client redesign — Client is now a subset of Context
Client is no longer a separate wrapper type with its own method shapes. It is a formal sub-interface of Context (both embed context.Context), owning every operation that doesn't require Launch(): enqueue, send/get-event/read-stream, workflow management, queue management, schedule management, app-version management, Shutdown. Every Context is a Client, so a launched Context can be passed anywhere a Client is accepted.
dbos.NewClient(ctx, dbos.ClientConfig{...})still exists and returns aClient.ClientConfiggainedSystemDBStartupTimeoutand renamedSqliteSystemDB→SQLiteSystemDB.- Client interface methods now take a leading
Clientreceiver-argument likeContextmethods always did (c.ListWorkflows(c, ...)). In practice, always use the package-level generic functions instead.
The Client* generic helpers are gone
The duplicated client-side generics were removed. The single package-level generic functions now accept a Client (and therefore also a Context):
| v0 (client) | v1 (unified) |
|---|---|
dbos.ClientRetrieveWorkflow[R](client, id) | dbos.RetrieveWorkflow[R](client, id) |
dbos.ClientGetEvent[R](client, wfid, key, timeout) | dbos.GetEvent[R](client, wfid, key, timeout) |
dbos.ClientReadStream[R](client, wfid, key) | dbos.ReadStream[R](client, wfid, key) |
dbos.ClientReadStreamAsync[R](client, wfid, key) | dbos.ReadStreamAsync[R](client, wfid, key) |
dbos.ClientResumeWorkflow[R](client, id) | dbos.ResumeWorkflow[R](client, id) |
dbos.ClientResumeWorkflows[R](client, ids) | dbos.ResumeWorkflows[R](client, ids) |
dbos.ClientForkWorkflow[R](client, input) | dbos.ForkWorkflow[R](client, input) |
dbos.ClientForkWorkflows[R](client, input) | dbos.ForkWorkflows[R](client, input) |
dbos.ClientTriggerSchedule[R](client, name) | dbos.TriggerSchedule[R](client, name) |
client.Enqueue(queue, wf, input) (method) | dbos.Enqueue[R](client, queue, wf, input) |
Enqueue type parameters reordered
Enqueue[P, R] became Enqueue[R, P] so the input type is inferred and you name only the result type:
// v0
handle, err := dbos.Enqueue[string, int](client, "queue", "MyWorkflow", "input")
// v1
handle, err := dbos.Enqueue[int](client, "queue", "MyWorkflow", "input")
Same reorder applies to both debouncer types: Debouncer[P, R] / NewDebouncer[P, R] → Debouncer[R, P] / NewDebouncer[R, P], and DebouncerClient[P, R] / NewDebouncerClient[P, R] → DebouncerClient[R, P] / NewDebouncerClient[R, P]. NewDebouncer's type parameters are still inferred from the workflow function, but it now also returns an error (see §7), and explicitly-typed variables must swap: var d *dbos.Debouncer[string, int] → *dbos.Debouncer[int, string]. NewDebouncerClient cannot infer its parameters — every call site must swap them by hand; watch for cases where input and result types are mutually assignable (e.g. both string), which compile unchanged with swapped meaning.