Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(relayer): requeue back to original queue on select errors #17584

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions packages/relayer/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/ecdsa"
"database/sql"
"encoding/json"
"errors"
"fmt"
"log/slog"
Expand Down Expand Up @@ -489,23 +490,28 @@ func (p *Processor) eventLoop(ctx context.Context) {
if err := p.queue.Ack(ctx, m); err != nil {
slog.Error("Err acking message", "err", err.Error())
}
case errors.Is(err, context.Canceled):
slog.Error("process message failed due to context cancel", "err", err.Error())
case errors.Is(err, context.Canceled) ||
strings.Contains(err.Error(), "timeout") ||
strings.Contains(err.Error(), "i/o") ||
strings.Contains(err.Error(), "connect") ||
strings.Contains(err.Error(), "failed to get tx into the mempool"):
slog.Error("process message failed", "err", err.Error())

// we want to negatively acknowledge the message and make sure
// we requeue it
if err := p.queue.Nack(ctx, m, true); err != nil {
if err := p.queue.Nack(ctx, m, false); err != nil {
slog.Error("Err nacking message", "err", err.Error())
break
}
case strings.Contains(err.Error(), "timeout") ||
strings.Contains(err.Error(), "i/o") ||
strings.Contains(err.Error(), "connect"):
slog.Error("process message failed due to networking issue", "err", err.Error())

// we want to negatively acknowledge the message and make sure
// we requeue it
if err := p.queue.Nack(ctx, m, true); err != nil {
slog.Error("Err nacking message", "err", err.Error())
marshalledMsg, err := json.Marshal(msg)
if err != nil {
slog.Error("err marshaling queue message", "err", err.Error())
break
}

if err := p.queue.Publish(ctx, p.queueName(), marshalledMsg, nil, nil); err != nil {
slog.Error("err publishing to queue", "err", err.Error())
}
default:
slog.Error("process message failed", "err", err.Error())
Expand Down
Loading