Skip to content

[FS-1544]Effective logs to catch duplicate key value violates unique constraint #218

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

Merged
merged 4 commits into from
Jul 2, 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
10 changes: 10 additions & 0 deletions internal/store/fleetdb/fleetdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,12 @@ func (r *Store) createUpdateServerComponents(ctx context.Context, serverID uuid.

_, err = r.CreateComponents(ctx, serverID, add)
if err != nil {
if strings.Contains(err.Error(), "duplicate key value violates unique constraint") {
r.logger.WithFields(logrus.Fields{
"create-components": add,
"err": err.Error(),
}).Error("create components returned duplicate key error")
}
// count error
metrics.FleetDBAPIQueryErrorCount.With(stageLabel).Inc()

Expand All @@ -411,6 +417,10 @@ func (r *Store) createUpdateServerComponents(ctx context.Context, serverID uuid.

_, err = r.UpdateComponents(ctx, serverID, update)
if err != nil {
r.logger.WithFields(logrus.Fields{
"update-components": update,
"err": err.Error(),
}).Error("update components returned error")
// count error
metrics.FleetDBAPIQueryErrorCount.With(stageLabel).Inc()

Expand Down
Loading