fix: handle context correctly in processEvents (#7320)

This commit is contained in:
Livio Spring 2024-01-31 11:25:28 +01:00 committed by GitHub
parent 46bffd24ee
commit e000fdd792
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -471,11 +471,11 @@ 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()
var cancel, cancelTx func()
// add 100ms to store current state if iteration takes too long
txCtx, cancel = context.WithTimeout(ctx, h.txDuration+100*time.Millisecond)
txCtx, cancelTx = context.WithTimeout(ctx, h.txDuration+100*time.Millisecond)
defer cancelTx()
ctx, cancel = context.WithTimeout(ctx, h.txDuration)
defer cancel()
}

View File

@ -93,8 +93,8 @@ func (h *Handler) setState(tx *sql.Tx, updatedState *state) error {
updatedState.offset,
)
if err != nil {
h.log().WithError(err).Debug("unable to update state")
return err
h.log().WithError(err).Warn("unable to update state")
return zerrors.ThrowInternal(err, "V2-WF23g2", "unable to update state")
}
if affected, err := res.RowsAffected(); affected == 0 {
h.log().OnError(err).Error("unable to check if states are updated")