fix: mark knowledge delete failures after retry exhaustion

This commit is contained in:
langcaiye
2026-06-16 12:08:00 +08:00
committed by lyingbug
parent 6efd2093f5
commit 0c3d45d3cd
6 changed files with 120 additions and 0 deletions
+2
View File
@@ -16,6 +16,7 @@ package asynqdl
import (
"context"
"encoding/json"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
@@ -164,6 +165,7 @@ func buildDeadLetter(t *asynq.Task, taskErr error, attempts int) *types.TaskDead
Payload: json.RawMessage(rawPayload),
LastError: truncateError(taskErr.Error(), 8192),
FailCount: attempts,
FailedAt: time.Now(),
}
}
@@ -117,6 +117,9 @@ func TestMiddleware_FailureWithoutAsynqCtx_RecordsRow(t *testing.T) {
if row.FailCount != 0 {
t.Errorf("fail_count: expected 0 outside worker ctx, got %d", row.FailCount)
}
if row.FailedAt.IsZero() {
t.Error("failed_at: expected non-zero timestamp")
}
}
func TestMiddleware_UnknownPayload_StillRecords(t *testing.T) {