Postgres issue after docker container update #5104

Closed
opened 2025-11-02 06:14:36 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @henry-nicolas on GitHub (Mar 23, 2020).

  • Gitea version (or commit ref): 1.12.0+dev-33-gc61b90253
  • Git version: 2.24.1
  • Operating system: Docker container
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:
2020/03/23 21:42:20 ...rm/session_schema.go:25:Ping() [I] PING DATABASE postgres
2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT tablename FROM pg_tables WHERE tablename = $1 [version] - 4.338196ms
2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = $1 AND column_name = $2 [version id] - 14.310184ms
2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = $1 AND column_name = $2 [version version] - 6.544237ms
2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT "id", "version" FROM "version" WHERE "id"=$1 LIMIT 1 [1] - 998.329µs
2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT tablename FROM pg_tables [] - 1.166538ms
2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT column_name, column_default, is_nullable, data_type, character_maximum_length,
	    CASE WHEN p.contype = 'p' THEN true ELSE false END AS primarykey,
	    CASE WHEN p.contype = 'u' THEN true ELSE false END AS uniquekey
	FROM pg_attribute f
	    JOIN pg_class c ON c.oid = f.attrelid JOIN pg_type t ON t.oid = f.atttypid
	    LEFT JOIN pg_attrdef d ON d.adrelid = c.oid AND d.adnum = f.attnum
	    LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
	    LEFT JOIN pg_constraint p ON p.conrelid = c.oid AND f.attnum = ANY (p.conkey)
	    LEFT JOIN pg_class AS g ON p.confrelid = g.oid
	    LEFT JOIN INFORMATION_SCHEMA.COLUMNS s ON s.column_name=f.attname AND c.relname=s.table_name
	WHERE n.nspname= $1 AND c.relkind = 'r'::char AND c.relname = $2 AND s.table_schema = $3 AND f.attnum > 0 ORDER BY f.attnum; [ user ] - 24.952711ms
2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT indexname, indexdef FROM pg_indexes WHERE tablename=$1 [user] - 4.55381ms
2020/03/23 21:42:20 cmd/migrate.go:38:runMigrate() [F] Failed to initialize ORM engine: sync database struct error: Unknown col created_unix seq 0, in index created_unix of table user, columns []

Description

After upgrading my docker container to run gitea version 1.12.0+dev-33-gc61b90253 the web service no longer comes up as the application keeps on crashing and restarting every minute with the above ORM error. Note that the column reported in the error may vary (different names) but it always points out to the user table.

Screenshots

Originally created by @henry-nicolas on GitHub (Mar 23, 2020). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.12.0+dev-33-gc61b90253 - Git version: 2.24.1 - Operating system: Docker container - Database (use `[x]`): - [X] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [X] Not relevant - Log gist: ``` 2020/03/23 21:42:20 ...rm/session_schema.go:25:Ping() [I] PING DATABASE postgres 2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT tablename FROM pg_tables WHERE tablename = $1 [version] - 4.338196ms 2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = $1 AND column_name = $2 [version id] - 14.310184ms 2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = $1 AND column_name = $2 [version version] - 6.544237ms 2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT "id", "version" FROM "version" WHERE "id"=$1 LIMIT 1 [1] - 998.329µs 2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT tablename FROM pg_tables [] - 1.166538ms 2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT column_name, column_default, is_nullable, data_type, character_maximum_length, CASE WHEN p.contype = 'p' THEN true ELSE false END AS primarykey, CASE WHEN p.contype = 'u' THEN true ELSE false END AS uniquekey FROM pg_attribute f JOIN pg_class c ON c.oid = f.attrelid JOIN pg_type t ON t.oid = f.atttypid LEFT JOIN pg_attrdef d ON d.adrelid = c.oid AND d.adnum = f.attnum LEFT JOIN pg_namespace n ON n.oid = c.relnamespace LEFT JOIN pg_constraint p ON p.conrelid = c.oid AND f.attnum = ANY (p.conkey) LEFT JOIN pg_class AS g ON p.confrelid = g.oid LEFT JOIN INFORMATION_SCHEMA.COLUMNS s ON s.column_name=f.attname AND c.relname=s.table_name WHERE n.nspname= $1 AND c.relkind = 'r'::char AND c.relname = $2 AND s.table_schema = $3 AND f.attnum > 0 ORDER BY f.attnum; [ user ] - 24.952711ms 2020/03/23 21:42:20 ...m.io/xorm/core/db.go:150:QueryContext() [I] [SQL] SELECT indexname, indexdef FROM pg_indexes WHERE tablename=$1 [user] - 4.55381ms 2020/03/23 21:42:20 cmd/migrate.go:38:runMigrate() [F] Failed to initialize ORM engine: sync database struct error: Unknown col created_unix seq 0, in index created_unix of table user, columns [] ``` ## Description After upgrading my docker container to run gitea version 1.12.0+dev-33-gc61b90253 the web service no longer comes up as the application keeps on crashing and restarting every minute with the above ORM error. Note that the column reported in the error may vary (different names) but it always points out to the user table. ## Screenshots <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the type/bugissue/duplicate labels 2025-11-02 06:14:36 -06:00
Author
Owner

@resamaraschi commented on GitHub (Mar 24, 2020):

Facing the same issue when scaling our app from one gitea instance to two instances. The second one does not start with the same error.

@resamaraschi commented on GitHub (Mar 24, 2020): Facing the same issue when scaling our app from one gitea instance to two instances. The second one does not start with the same error.
Author
Owner

@lafriks commented on GitHub (Mar 24, 2020):

Duplicate of #10802

@lafriks commented on GitHub (Mar 24, 2020): Duplicate of #10802
Author
Owner

@henry-nicolas commented on GitHub (Mar 24, 2020):

Here I am refering to an upgrade while the other issue refers to a new install.

Question then for me becomes: will I be ok to upgrade as is to the next release that has the bugfix or is my database schema left broken now?

@henry-nicolas commented on GitHub (Mar 24, 2020): Here I am refering to an upgrade while the other issue refers to a new install. Question then for me becomes: will I be ok to upgrade as is to the next release that has the bugfix or is my database schema left broken now?
Author
Owner

@adasauce commented on GitHub (Mar 24, 2020):

@henry-nicolas i'm seeing the same behaviour on the same table after a docker-compose pull and up.

@adasauce commented on GitHub (Mar 24, 2020): @henry-nicolas i'm seeing the same behaviour on the same table after a docker-compose pull and up.
Author
Owner

@lafriks commented on GitHub (Mar 24, 2020):

It is same issue both for install and update. Database schema is not broken, it is just Gitea xorm migration thinks that schema changes are needed and tries to add index that already exists

@lafriks commented on GitHub (Mar 24, 2020): It is same issue both for install and update. Database schema is not broken, it is just Gitea xorm migration thinks that schema changes are needed and tries to add index that already exists
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5104