Commit 2a04345
authored
Db retries (#146)
Address #93
This PR adds a `retry` method that can take in another function for
retry until a specific condition is met. `retry` can be configured with
functional options and has a `retryWithResult` generic counterpart for
functions returning a value.
All system database methods are now called within `retry` or
`retryWithResult`.
For example
```go
dequeuedWorkflows, err := retryWithResult(ctx, func() ([]dequeuedWorkflow, error) {
return ctx.systemDB.dequeueWorkflows(ctx, dequeueWorkflowsInput{
queue: queue,
executorID: ctx.executorID,
applicationVersion: ctx.applicationVersion,
})
}, withRetrierLogger(qr.logger))
```
retry performs exponential backoff with jitter. It defaults to infinite
retries.
The default condition for retrying is `isRetryablePGError`, which
matches the function returned error with a set of connection errors
(postgres codes, pgx connection errors, `net.Error`)
Note: in the particular case of RunWorkflow, which does manage
transactions, the entire function has to be retried. This is because the
transaction object becomes invalid as soon as Commit/Rollback have been
called, regardless of whether the operation was successful. See
https://github.com/jackc/pgx/blob/61d3c965ad442cc14d6b0e39e0ab3821f3684c03/tx.go#L180
This PR also improves `DBOSError` with the ability to unwrap the
underlying error, if any.1 parent 5501699 commit 2a04345
File tree
11 files changed
+878
-160
lines changed- .github/workflows
- chaos_tests
- cmd/dbos
- dbos
- integration
11 files changed
+878
-160
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | 47 | | |
58 | 48 | | |
59 | 49 | | |
| |||
0 commit comments