Gitea fails to restart due to index recreation #6343

Closed
opened 2025-11-02 06:53:12 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @ghimisradu on GitHub (Nov 18, 2020).

  • Gitea version (or commit ref):
  • Git version: gitea-1.12.6-linux-amd64 (taken from https://dl.gitea.io/gitea/1.12.6)
  • Operating system: ubuntu 18.04 LTS
  • Gitea it's running as a systemd service
  • Database (use [x]):
    • MySQL
    • PostgreSQL
    • MSSQL
    • SQLite
  • Log gist:
    2020/11/18 20:07:04 routers/init.go:133:GlobalInit() [I] ORM engine initialization successful! 2020/11/18 20:07:04 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT 'TABLE_NAME', 'ENGINE', 'AUTO_INCREMENT', 'TABLE_COMMENT' from 'INFORMATION_SCHEMA'.'TABLES' WHERE 'TABLE_SCHEMA'=? AND ('ENGINE'='MyISAM' OR 'ENGINE' = 'InnoDB' OR 'ENGINE' = 'TokuDB') [gitea] - 2.089805ms 2020/11/18 20:07:04 ...m.io/xorm/core/db.go:277:ExecContext() [I] [SQL] CREATE TABLE IF NOT EXISTS 'oauth2_session' ('id' VARCHAR(100) PRIMARY KEY NOT NULL, 'data' TEXT NULL, 'created_unix' BIGINT(20) NULL, 'updated_unix' BIGINT(20) NULL, 'expires_unix' BIGINT(20) NULL) DEFAULT CHARSET utf8 ROW_FORMAT=DYNAMIC [] - 1.625221ms 2020/11/18 20:07:04 ...m.io/xorm/core/db.go:277:ExecContext() [I] [SQL] CREATE INDEX 'IDX_oauth2_session_expires_unix' ON 'oauth2_session' ('expires_unix') [] - 3.241712ms 2020/11/18 20:07:04 routers/init.go:139:GlobalInit() [F] Failed to initialize OAuth2 support: Error 1061: Duplicate key name 'IDX_oauth2_session_expires_unix'

Description

After the initial setup of the Gitea the database is created and everything it's working properly, but after I restart the service, I get the mentioned errors.
If I try to delete that index manually the application start fine until the next restart when the same error occurs.

Are there any options to disable the automatic index creation or database initialization?

Originally created by @ghimisradu on GitHub (Nov 18, 2020). - Gitea version (or commit ref): - Git version: gitea-1.12.6-linux-amd64 (taken from https://dl.gitea.io/gitea/1.12.6) - Operating system: ubuntu 18.04 LTS - Gitea it's running as a systemd service - Database (use `[x]`): - [x] MySQL - [ ] PostgreSQL - [ ] MSSQL - [ ] SQLite - Log gist: ` 2020/11/18 20:07:04 routers/init.go:133:GlobalInit() [I] ORM engine initialization successful! 2020/11/18 20:07:04 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT 'TABLE_NAME', 'ENGINE', 'AUTO_INCREMENT', 'TABLE_COMMENT' from 'INFORMATION_SCHEMA'.'TABLES' WHERE 'TABLE_SCHEMA'=? AND ('ENGINE'='MyISAM' OR 'ENGINE' = 'InnoDB' OR 'ENGINE' = 'TokuDB') [gitea] - 2.089805ms 2020/11/18 20:07:04 ...m.io/xorm/core/db.go:277:ExecContext() [I] [SQL] CREATE TABLE IF NOT EXISTS 'oauth2_session' ('id' VARCHAR(100) PRIMARY KEY NOT NULL, 'data' TEXT NULL, 'created_unix' BIGINT(20) NULL, 'updated_unix' BIGINT(20) NULL, 'expires_unix' BIGINT(20) NULL) DEFAULT CHARSET utf8 ROW_FORMAT=DYNAMIC [] - 1.625221ms 2020/11/18 20:07:04 ...m.io/xorm/core/db.go:277:ExecContext() [I] [SQL] CREATE INDEX 'IDX_oauth2_session_expires_unix' ON 'oauth2_session' ('expires_unix') [] - 3.241712ms 2020/11/18 20:07:04 routers/init.go:139:GlobalInit() [F] Failed to initialize OAuth2 support: Error 1061: Duplicate key name 'IDX_oauth2_session_expires_unix' ` ## Description After the initial setup of the Gitea the database is created and everything it's working properly, but after I restart the service, I get the mentioned errors. If I try to delete that index manually the application start fine until the next restart when the same error occurs. Are there any options to disable the automatic index creation or database initialization?
Author
Owner

@jolheiser commented on GitHub (Nov 18, 2020):

Please fill out the issue template, there are a lot of variables to take into account here.

@jolheiser commented on GitHub (Nov 18, 2020): Please fill out the issue template, there are a lot of variables to take into account here.
Author
Owner

@6543 commented on GitHub (Nov 18, 2020):

@ghimisradu unrelated but ... DEFAULT CHARSET utf8 you will get 500-error if you use emojis, you shuld move to utf8mb4

@6543 commented on GitHub (Nov 18, 2020): @ghimisradu unrelated but ... `DEFAULT CHARSET utf8` you will get 500-error if you use emojis, you shuld [move to utf8mb4](https://docs.gitea.io/en-us/faq/#why-are-emoji-broken-on-mysql)
Author
Owner

@ghimisradu commented on GitHub (Nov 19, 2020):

Ok, found the issue, the wrong db engine was defined on the oauth2_session, instead of InnoDB, the ndbcluster was used. Changing the table definition to use InnoDB solved the issue.

@ghimisradu commented on GitHub (Nov 19, 2020): Ok, found the issue, the wrong db engine was defined on the `oauth2_session`, instead of _InnoDB_, the _ndbcluster_ was used. Changing the table definition to use InnoDB solved the issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6343