Skip to content

# Update Flow Options

Flow definitions in pgflow are fundamentally immutable in structure. For structural changes like adding steps or changing dependencies, create a new flow version instead (see Version Your Flows). This guide focuses only on runtime configuration options you can safely update.

## Updatable Options

Section titled “Updatable Options”

You can safely modify these runtime options without creating a new flow version:

Option | Description | Default | Scope
--- | --- | --- | ---
`opt_max_attempts` | Max retry attempts | 3 | Flow & Steps
`opt_base_delay` | Base retry delay (seconds) | 1 | Flow only
`opt_timeout` | Max execution time (seconds) | 60 | Flow & Steps

About opt_timeout

Currently, `opt_timeout` is only used to set the visibility timeout of messages in the queue. You should set this value to be higher than the maximum time a job can possibly run. If processing takes longer than the timeout, the message will become visible again and may be processed by another worker, leading to duplicate processing.

In the future, the Edge Worker will use abort signals to terminate jobs past their timeout, but currently, it does not do this.

For more details on visibility timeouts, see the Edge Worker Configuration documentation.

## Configuration System

Section titled “Configuration System”

pgflow uses a two-level configuration approach:

- Flow-level options: Set defaults for all steps in the flow
- Step-level options: Override flow defaults for specific steps

## Updating Options Manually

Section titled “Updating Options Manually”

Since the compiler doesn’t support updating existing flows, you must manually update options in the database:

### Flow Level (Affects All Steps)

Section titled “Flow Level (Affects All Steps)”

    UPDATE pgflow.flowsSET opt_max_attempts = 5, opt_timeout = 10, opt_base_delay = 2WHERE flow_slug = 'your_flow_slug';

### Step Level (Overrides Flow Defaults)

Section titled “Step Level (Overrides Flow Defaults)”

    UPDATE pgflow.stepsSET opt_max_attempts = 3, opt_timeout = 30WHERE flow_slug = 'your_flow_slug' AND step_slug = 'your_step_slug';

## Example: Increasing Retries for API Calls

Section titled “Example: Increasing Retries for API Calls”

    -- Check current settingsSELECT step_slug, opt_max_attempts FROM pgflow.steps WHERE flow_slug = 'analyze_website';
    -- Update API call step to retry moreUPDATE pgflow.steps SET opt_max_attempts = 5WHERE flow_slug = 'analyze_website' AND step_slug = 'website';

Caution

After updating options in the database, remember to update your flow definition code to keep them in sync.