Skip to content

Migrate failure 1.19.3 => 1.20.0: Change Container Metadata failed #25918

Closed
@fabianheusser

Description

@fabianheusser

Description

After replacing the binary, the service does not start.

The following lines could be found in gitea.log:

2023/07/17 07:08:45 cmd/web.go:175:serveInstalled() [I] PING DATABASE mssql
2023/07/17 07:08:45 ...ations/migrations.go:599:Migrate() [I] Migration[250]: Change Container Metadata
2023/07/17 07:08:45 routers/init.go:69:mustInitCtx() [F] code.gitea.io/gitea/routers/common.InitDBEngine(ctx) failed: migrate: migration[250]: Change Container Metadata failed: mssql: Die id-Identitätsspalte kann nicht aktualisiert werden.

"Die id-Identitätsspalte kann nicht aktualisiert werden." => The id-column cannot be updated.

I think the error roots in this file: https://github.com/go-gitea/gitea/blob/release/v1.20/models/migrations/v1_20/v250.go

The sql that is sent to the database is

exec sp_executesql N'UPDATE [package_version] SET [id] = @p1, [metadata_json] = @p2 WHERE [id]=@p3',N'@p1 bigint,@p2 nvarchar(423),@p3 bigint',@p1=162,@p2=N'{"type":"oci","is_tagged":true,"manifests":[{"platform":"linux/amd64","digest":"sha256:96b4cb3fa5f8c89e1eba6db982198bab0c8a3b6e41b07eaa8249d5c4124f9e10","size":98495012},{"platform":"linux/arm64","digest":"sha256:7dfd63f5449f46579d9cdad9f98642a0e48c0950809bdf468177386ec2bb6d41","size":90048661},{"platform":"unknown/unknown","digest":"sha256:53bd566ce06c95bed8c51d95269785742fbf34eaaa3c9731d823f723de9c66ad","size":1890}]}',@p3=162
go

If I remove the identity from the ID column, the migration succeeds, and Gitea starts successfully.

Gitea Version

1.20.0

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

git version 2.17.1

Operating System

ubuntu 18.04

How are you running Gitea?

I run gitea-1.20.0-linux-amd64 with systemd. MSSQL 14.0.3460.9 (SQL Server 2017)

Database

MSSQL

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/criticalThis issue should be fixed ASAP. If it is a PR, the PR should be merged ASAPtopic/packagestype/bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions