harbor icon indicating copy to clipboard operation
harbor copied to clipboard

duplicate key value violates unique constraint "scan_report_digest_registration_uuid_mime_type_key"

Open flbla opened this issue 2 months ago • 0 comments

If you are reporting a problem, please make sure the following information are provided:

Expected behavior and actual behavior:

When a scan is launched (manually or via a push) we randomly get this error :

2024-06-13T14:23:13Z [ERROR] [/controller/event/handler/internal/artifact.go:259]: scan artifact ************************* failed, error: ERROR: duplicate key value violates unique constraint "scan_report_digest_registration_uuid_mime_type_key" (SQLSTATE 23505)

In my postgresql logs I can see :

2024-06-13 14:23:13 UTC-666aff97.4a66-LOG:  QUERY STATISTICS","detail": "! system usage stats:\n!\t0.000146 s user, 0.000000 s system, 0.005479 s elapsed\n!\t[0.315484 s user, 0.050385 s system total]\n!\t20940 kB max resident size\n!\t0/48 [672/864] filesystem blocks in/out\n!\t0/0 [0/1906] page faults/reclaims, 0 [0] swaps\n!\t0 [0] signals rcvd, 0/0 [0/0] messages rcvd/sent\n!\t2/0 [1487/2322] voluntary/involuntary context switches","statement": "commit
2024-06-13 14:23:13 UTC-666aff7a.49cc-ERROR:  duplicate key value violates unique constraint \"scan_report_digest_registration_uuid_mime_type_key\"","detail": "Key (digest, registration_uuid, mime_type)=(sha256:62b692583d8dada8d68dbc996c5e98fd397a5f3263f4149fde95cad749ba416b, ed4df02c-6216-11eb-980a-e2227a954221, application/vnd.security.vulnerability.report; version=1.1) already exists.","statement": "INSERT INTO \"scan_report\" (\"uuid\", \"digest\", \"registration_uuid\", \"mime_type\", \"report\", \"critical_cnt\", \"high_cnt\", \"medium_cnt\", \"low_cnt\", \"unknown_cnt\", \"none_cnt\", \"fixable_cnt\") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING \"id\"","schema_name": "public","table_name": "scan_report","constraint_name": "scan_report_digest_registration_uuid_mime_type_key

harbor core log :

2024-06-13T14:23:25Z [ERROR] [/controller/event/handler/internal/artifact.go:259]: scan artifact *************************  failed, error: a previous scan process is Running

it looks like harbor try to scan the same artifact more than once, but I don't know why.

Steps to reproduce the problem: it's random

Versions: Please specify the versions of following systems.

  • harbor version: 2.10.2
  • kubernetes : 1.28

flbla avatar Jun 21 '24 07:06 flbla