Skip to content

fix: silence noisy "Ignoring duplicate key error" messages. Fixes #14344 #14357

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 1 commit into from
Apr 16, 2025

Conversation

MasonM
Copy link
Member

@MasonM MasonM commented Apr 4, 2025

Fixes #14344

Motivation

When offloading a workflow, it's possible for multiple workers to concurrently call Save() with the same workflow, which leads to ERROR: duplicate key value violates unique constraint "argo_workflows_pkey" messages in the logs, along with a stack trace.

These messages are cluttering the logs and confusing users. Duplicate key errors are harmless: Save() detects them automatically and will return the version hash. Since version is part of the primary key of the argo_workflows table, that means it's guaranteed to be identical to the previously-inserted row.

Modifications

This decreases the log level of that message to DEBUG so that it doesn't clutter the logs. I thought about removing it entirely, but I figured it's worth keeping just in case there's an edge case we need to debug.

Verification

I wasn't able to reproduce the error locally, but I verified workflow offloading works by following these steps:

  1. Start with PostgreSQL and ALWAYS_OFFLOAD_NODE_STATUS enabled: make start PROFILE=postgres UI=true ALWAYS_OFFLOAD_NODE_STATUS=true
  2. Submit an example workflow through the UI
  3. Verify it got inserted into the DB:
$ make postgres-cli
GIT_COMMIT=a5de57b4bd4dd95f79fc7ff0fa95ba94cfacb91d GIT_BRANCH=fix-loglevel GIT_TAG=untagged GIT_TREE_STATE=clean RELEASE_TAG=false DEV_BRANCH=true VERSION=latest
KUBECTX=k3d-k3s-default K3D=true DOCKER_PUSH=false TARGET_PLATFORM=linux/amd64
RUN_MODE=local PROFILE=minimal AUTH_MODE=hybrid SECURE=false  STATIC_FILES=false ALWAYS_OFFLOAD_NODE_STATUS=false UPPERIO_DB_DEBUG=0 LOG_LEVEL=debug NAMESPACED=true
kubectl exec -ti svc/postgres -- psql -U postgres
psql (12.14)
Type "help" for help.

postgres=# select * from argo_workflows limit 1;
                 uid                  | namespace | clustername |    version     |                                                                                                                                                                                    nodes                                    
                                                                                                                                                |         updatedat          
--------------------------------------+-----------+-------------+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------
 c4239bc5-8d90-4ca2-9f1a-323a62fb9ee3 | argo      | default     | fnv:2543912711 | {"sparkly-poochenheimer":{"id":"sparkly-poochenheimer","name":"sparkly-poochenheimer","displayName":"sparkly-poochenheimer","type":"Pod","templateName":"argosay","templateScope":"local/sparkly-poochenheimer","phase":"Pen
ding","startedAt":"2025-04-04T23:29:23Z","finishedAt":null,"progress":"0/1","inputs":{"parameters":[{"name":"message","value":"hello argo"}]}}} | 2025-04-04 23:29:23.084941
(1 row)

Documentation

N/A

When offloading a workflow, it's possible for multiple workers to concurrently
call `Save()` with the same workflow, which leads to `ERROR: duplicate key value
violates unique constraint "argo_workflows_pkey"`` messages in the logs, along
with a stack trace. These messages are cluttering the logs and confusing users,
but duplicate key errors are harmless. When it detects a duplicate key error,
`Save()` will return the `version` hash, and `version` is part of the primary
key of the `argo_workflows` table, which means it's guaranteed to be identical
to the previously-inserted row.

This decreases the log level of that message to `DEBUG` so that it doesn't
clutter the logs. I thought about removing it entirely, but I figured it's worth
keeping just in case.

I wasn't able to reproduce the error locally, but I verified workflow offloading
works locally using `make PROFILE=postgres UI=true ALWAYS_OFFLOAD_NODE_STATUS=true`

Signed-off-by: Mason Malone <[email protected]>
@MasonM
Copy link
Member Author

MasonM commented Apr 5, 2025

/retest

@MasonM MasonM marked this pull request as ready for review April 5, 2025 00:35
Copy link
Member

@Joibel Joibel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks

@Joibel Joibel merged commit 3dbd175 into argoproj:main Apr 16, 2025
56 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error in logs duplicate key value violates unique constraint "argo_workflows_pkey"
2 participants