Skip to content
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

Can't push docker image after database migrate, duplicate key value violates unique constraint blob_pkey #21219

Open
cataglyphis opened this issue Nov 20, 2024 · 2 comments
Assignees

Comments

@cataglyphis
Copy link

cataglyphis commented Nov 20, 2024

We deploy Harbor with Helm to our Kubernetes cluster and use AWS-managed RDS PostgreSQL. We then use AWS DMS to migrate data from one PostgreSQL instance to another. After updating the database connection information to the new database and redeploying Harbor, our CI/CD system can't push images to Harbor.

Expected behavior and actual behavior:

  • CI/CD can push image to harbor after database migrate

Steps to reproduce the problem:

  • migrate data from database to another one
  • restart harbor with new database

Versions:

  • harbor version: 2.9.5
  • postgresql version: 13.0

Additional context:

  • harbor error logs
  | 2024-11-19T13:05:16Z [ERROR] [/lib/http/error.go:57]: {"errors":[{"code":"UNKNOWN","message":"unknown: ERROR: duplicate key value violates unique constraint \"blob_pkey\" (SQLSTATE 23505)"}]} |  
-- | -- | --
  | 2024-11-19T13:05:16Z [ERROR] [/server/middleware/blob/put_blob_upload.go:68][middleware="blob" requestID="9afceb14-bb3e-49d3-ad5c-47fa67d5fa0d"]: ensure blob sha256:53061bf0b21afaccb510226ef2d5fa8c2804c257c32e04e0adbe2970f1e2e30c failed, error: ERROR: duplicate key value violates unique constraint "blob_pkey" (SQLSTATE 23505) |  
-- | -- | --
  | 2024-11-19T13:05:16Z [ERROR] [/lib/http/error.go:57]: {"errors":[{"code":"UNKNOWN","message":"unknown: ERROR: duplicate key value violates unique constraint \"blob_pkey\" (SQLSTATE 23505)"}]} |  
-- | -- | --

CleanShot 2024-11-20 at 09 05 04@2x

  • database error logs
21:05:37 | STATEMENT: INSERT INTO "artifact" ("type", "media_type", "manifest_media_type", "project_id", "repository_id", "repository_name", "digest", "size", "icon", "push_time", "pull_time", "extra_attrs", "annotations") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) RETURNING "id"
-- | --
21:05:37 | DETAIL: Key (id)=(56894) already exists.
21:05:37 | ERROR: duplicate key value violates unique constraint "artifact_pkey"
21:05:22 | STATEMENT: INSERT INTO "blob" ("digest", "content_type", "size", "status", "update_time", "version", "creation_time") VALUES ($1, $2, $3, $4, $5, $6, $7) ON CONFLICT (digest) DO UPDATE SET "digest"=$8, "content_type"=$9, "size"=$10, "status"=$11, "update_time"=$12, "version"=$13, "creation_time"=$14 RETURNING "id"
21:05:22 | DETAIL: Key (id)=(231829) already exists.
21:05:22 | ERROR: duplicate key value violates unique constraint "blob_pkey"
21:05:22 | STATEMENT: INSERT INTO "blob" ("digest", "content_type", "size", "status", "update_time", "version", "creation_time") VALUES ($1, $2, $3, $4, $5, $6, $7) ON CONFLICT (digest) DO UPDATE SET "digest"=$8, "content_type"=$9, "size"=$10, "status"=$11, "update_time"=$12, "version"=$13, "creation_time"=$14 RETURNING "id"
21:05:22 | DETAIL: Key (id)=(231828) already exists.

CleanShot 2024-11-20 at 09 07 32@2x

@cataglyphis cataglyphis changed the title Can't push docker image after database migrate Can't push docker image after database migrate, duplicate key value violates unique constraint blob_pkey Nov 20, 2024
@wy65701436 wy65701436 self-assigned this Nov 22, 2024
@wy65701436
Copy link
Contributor

hi @cataglyphis to be clarify, you did upgrade harbor version, but just migrate the DB data to an new postgres instance through AWS DMS?

@cataglyphis
Copy link
Author

cataglyphis commented Nov 23, 2024

hi @cataglyphis to be clarify, you did upgrade harbor version, but just migrate the DB data to an new postgres instance through AWS DMS?

@wy65701436 Just migrate DB data to another instance, no harbor version upgrade

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

No branches or pull requests

2 participants