gogs: PostgreSQL: unique constraint violation after backup restored
- Gogs version: 0.9.170.0226 / 0.10 RC
- Git version: latest
- Operating system: docker on ubuntu (using the provided image.rpi armhf host)
- Database (use
[x]
):- [X ] PostgreSQL
- MySQL
- MSSQL
- SQLite
- Can you reproduce the bug at https://try.gogs.io:
- Yes (provide example URL)
- No
- Not relevant
Description
Hi, So i’ve been using gogs for a while. Some months ago i had to use the gogs feature to dump everything because i had to move to another gogs instance (complete server reinstall). So this time i’m suign docker. Built the docker image myself with docker build command and i’ve reimported the database and files.
Since i did that everything seemed to be working, but now i notice that everytime i try to create a new repo or user the server returns 500 and the following errors(organizations seems to be fine): For a repo: ‘’‘pq: duplicate key value violates unique constraint “repository_pkey”’‘’ For a user: ‘’‘pq: duplicate key value violates unique constraint “user_pkey”’‘’ For a migration: ‘’‘pq: duplicate key value violates unique constraint “repository_pkey”’‘’
Log:
‘’’ 2017/03/28 16:23:01 [TRACE] CSRF Token: TOKEN 2017/03/28 16:23:01 [ERROR] […s/context/context.go:97 Handle()] CreatePost: pq: duplicate key value violates unique constraint “repository_pkey” 2017/03/28 16:23:01 [TRACE] Template: status/500 2017/03/28 16:50:40 [TRACE] CSRF Token: TOKEN 2017/03/28 16:50:41 [ERROR] […s/context/context.go:97 Handle()] CreateUser: pq: duplicate key value violates unique constraint “user_pkey” 2017/03/28 16:50:41 [TRACE] Template: status/500 2017/03/28 16:52:21 [TRACE] CSRF Token: TOKEN 2017/03/28 16:52:21 [ERROR] […s/context/context.go:97 Handle()] MigratePost: pq: duplicate key value violates unique constraint “repository_pkey” 2017/03/28 16:52:21 [TRACE] Template: status/500 “”"
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 27 (11 by maintainers)
Commits related to this issue
- restore: reset table sequences for PostgreSQL (#4357) — committed to gogs/gogs by unknwon 7 years ago
- Enforce token on api routes [fixed critical security issue #4357] (#4840) — committed to unfoldingWord/dcs by beeonthego 6 years ago
I confirm that this has been fixed! The patch works. 😃 So to fix it you have to export and reimport the database from a backup as explained before. Here’s a recap of the commands.
For backupping the database:
For restoring the database: