Skip to content

Cannot upload after OrientDB to H2 migration: Unique index or primary key violation #449

@dioss-Machiel

Description

@dioss-Machiel

We are running "OSS 3.70.1-02", after running the migration script and setting nexus.datastore.enabled=true everything seems to work except uploading new data.

When uploading we see exceptions like this
Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.RAW_ASSET_BLOB(ASSET_BLOB_ID) ( /* key:0 */ 36, 'default@e6eab474-ed51-4131-8c45-f9bdae0fd551', CAST(420190 AS BIGINT), 'application/x-bzip2', JSON '{""sha1"":""cd45031441ac944eacebdc8d4b82b20cd9cc8461"",""md5"":""a23646617546bf6ad56f061d8b283c85""}', TIMESTAMP WITH TIME ZONE '2019-04-04 13:41:49.113+00', 'stijnv', '10.152.0.56', TIMESTAMP WITH TIME ZONE '1970-01-01 00:00:00+00')"; SQL statement: INSERT INTO raw_asset_blob (blob_ref, blob_size, content_type, checksums, blob_created, created_by, created_by_ip ) VALUES (?, ?, ?, ?, ?, ?, ? ) [23505-224]

After some further investigation it seems like all "auto increment" columns in the H2 database have been reset to start at "1"

I believe the workaround is to manually fix all the auto increment columns to not start at "1" but at the last value + 1:

ALTER TABLE PUBLIC.DOCKER_ASSET_BLOB ALTER COLUMN ASSET_BLOB_ID RESTART WITH SELECT max(ASSET_BLOB_ID) + 1 FROM DOCKER_ASSET_BLOB

However, I would assume the migration script already takes this into account, so I am wondering if something else is going on and other data might be missing in the migration?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions