fix(db): always use begin tx (#7142)

* fix(db): always use begin tx

* fix(handler): timeout for begin
This commit is contained in:
Silvan
2024-01-04 17:12:20 +01:00
committed by GitHub
parent c0cef4983a
commit b7d027e2fd
19 changed files with 59 additions and 56 deletions

View File

@@ -316,13 +316,17 @@ func (h *Handler) processEvents(ctx context.Context, config *triggerConfig) (add
}
}()
txCtx := ctx
if h.txDuration > 0 {
var cancel func()
ctx, cancel = context.WithTimeout(ctx, h.txDuration)
defer cancel()
// add 100ms to store current state if iteration takes too long
txCtx, cancel = context.WithTimeout(ctx, h.txDuration+100*time.Millisecond)
defer cancel()
}
tx, err := h.client.Begin()
tx, err := h.client.BeginTx(txCtx, nil)
if err != nil {
return false, err
}