#mutation retry count

4 messages · Page 1 of 1 (latest)

little urchin
#

mutation retry count

inner wrenBOT
#

Hi @little urchin. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the knowledge sources, Convex mutations have built-in retry capabilities for handling conflicts and failures. Here's what you should know about mutation retry counts:

Automatic Retries for Mutations

Convex automatically retries mutations when they fail due to conflicts from parallel mutation executions (known as Optimistic Concurrency Control or OCC conflicts). The system will perform several internal retries to mitigate this concern, but there's a limit to how many times it will retry before throwing an error.

When mutations are called from the WebSocket-powered client, Convex will retry them for days until they run to completion. This provides an exactly-once guarantee for your mutations.

Retry Limits

The knowledge sources don't specify an exact number for the default retry count limit for mutations. However, when using the scheduler with a mutation, it will "indefinitely retry the mutation on database conflicts until it succeeds or throws an exception from your code" as mentioned in the Stack article on durable workflows.

Custom Retry Behavior

If you need more control over retries, Convex provides several components that allow you to specify custom retry behavior:

  1. Action Retrier Component: For retrying actions (not mutations), you can specify:
const retrier = new ActionRetrier(components.actionRetrier);
await retrier.run(ctx, internal.module.myAction, { arg: 123 }, {
  initialBackoffMs: 125,
  base: 2.71,
  maxFailures: 3,
});
  1. Workpool Component: Allows configuring retry behavior for both actions and mutations:
const pool = new Workpool(components.workpool, {
  retryActionsByDefault: true,
  defaultRetryBehavior: {
    maxAttempts: 5,
    initialBackoffMs: 1000,
    base: 2,
  },
});
#
  1. Workflow Component: Similar configuration options:
const workflow = new WorkflowManager(components.workflow, {
  workpoolOptions: {
    retryActionsByDefault: true,
    defaultRetryBehavior: {
      maxAttempts: 5,
      initialBackoffMs: 1000,
      base: 2,
    },
  },
});

It's important to note that while mutations are automatically retried, actions are not retried by default unless you explicitly configure them to be retried using one of these components.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: