From f2d265c37ad2567dfe2ef2065fffa8e7170aa57f Mon Sep 17 00:00:00 2001 From: Arseniy Klempner Date: Thu, 3 Oct 2024 21:58:12 -0700 Subject: [PATCH] fix: truncate log for duplicate lightpush/filter message --- lib/metrics/generic.go | 6 ------ telemetry/server.go | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/metrics/generic.go b/lib/metrics/generic.go index 325eb3c..8f01b28 100644 --- a/lib/metrics/generic.go +++ b/lib/metrics/generic.go @@ -78,12 +78,6 @@ func (g *GenericMetric[T]) Process(ctx context.Context, db *sql.DB, errs *common return result.Err() } - var lastInsertId int - err = result.Scan(&lastInsertId) - if err != nil { - return err - } - if err := tx.Commit(); err != nil { errs.Append(data.ID, fmt.Sprintf("Error committing transaction: %v", err)) return err diff --git a/telemetry/server.go b/telemetry/server.go index 30f68c0..4e4109e 100644 --- a/telemetry/server.go +++ b/telemetry/server.go @@ -7,6 +7,7 @@ import ( "fmt" "log" "net/http" + "strings" "time" "github.com/gorilla/mux" @@ -241,6 +242,10 @@ func (s *Server) createWakuTelemetry(w http.ResponseWriter, r *http.Request) { continue } if err := pushFilter.Put(s.DB); err != nil { + if strings.Contains(err.Error(), "duplicate key value violates unique constraint") { + errorDetails.Append(data.Id, "Error saving lightpush/filter metric: Duplicate key value violates unique constraint") + continue + } errorDetails.Append(data.Id, fmt.Sprintf("Error saving lightpush/filter metric: %v", err)) continue }