Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on startup 1.5 #4360

Closed
2 of 7 tasks
ymabispo opened this issue Jul 4, 2018 · 30 comments · Fixed by #4473 or #4440
Closed
2 of 7 tasks

Error on startup 1.5 #4360

ymabispo opened this issue Jul 4, 2018 · 30 comments · Fixed by #4473 or #4440
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail issue/stale type/bug

Comments

@ymabispo
Copy link

ymabispo commented Jul 4, 2018

  • Gitea version (or commit ref): 1.5
  • Git version: 2.17.1
  • Operating system: Windows Server 2008 R2 Standard
  • 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:

Description

Guys, a few minutes ago a tried to update 1.4.3 to 1.5 and the windows service doesn't start up.
log error:

2018/07/04 07:56:23 [I] Log Mode: File(Trace)
2018/07/04 07:56:23 [I] XORM Log Mode: File(Trace)
2018/07/04 07:56:23 [I] Cache Service Enabled
2018/07/04 07:56:23 [I] Session Service Enabled
2018/07/04 07:56:23 [I] Migration: add multiple assignees
2018/07/04 07:56:23 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Drop table issue columns [assignee_id]: mssql: ALTER TABLE DROP COLUMN assignee_id failed because one or more objects access this column.
...

Screenshots

@lunny lunny added the type/bug label Jul 4, 2018
@daviian daviian modified the milestone: 1.5.0 Jul 4, 2018
@daviian daviian added the issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP label Jul 4, 2018
@lunny
Copy link
Member

lunny commented Jul 4, 2018

The CI for MSSQL could be added by #4282

@lafriks
Copy link
Member

lafriks commented Jul 13, 2018

@ymabispo can you check if code from pull request #4440 fixes your problem?

@bjoe2k4
Copy link

bjoe2k4 commented Jul 14, 2018

@lafriks I'm seeing a similar problem after updating from 1.4.1 to git-master, but with mysql.

[I] Gitea v8e103d3 built with: bindata, sqlite
[...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Drop table `issue` columns [assignee_id]: sql: Transaction has already been committed or rolled back```

@lafriks lafriks reopened this Jul 14, 2018
@back2root
Copy link

@lafriks I guess commit e95417e fixes an issue for MSSQL but introduces an issue for MySQL.

I do see a similar problem as @bjoe2k4 but with migrating db v69 -> 70 as it seems that I'm already on a newer DB Version.

Error Message I get on first Start:

2018/07/17 20:29:18 [I] Migration: move team units to team_unit table
2018/07/17 20:29:19 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Drop table team columns [unit_types]: sql: Transaction has already been committed or rolled back

Subsequent Starts will log (just in case anyone is googling for this error):

2018/07/17 20:37:42 [I] Migration: move team units to team_unit table
2018/07/17 20:37:42 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Insert team units: Error 1062: Duplicate entry '1-1' for key 'UQE_team_unit_s'

My first guess is that we simply need to open a new session:

Insert (after committing session):

sess.Close()
sess := x.NewSession()
defer sess.Close()

@back2root
Copy link

If PR #4459 get's accepted and you still get the following error:

2018/07/17 20:37:42 [I] Migration: move team units to team_unit table
2018/07/17 20:37:42 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Insert team units: Error 1062: Duplicate entry '1-1' for key 'UQE_team_unit_s'

you may simply "drop table team_unit" and restart gitea.

@johanhugg
Copy link

johanhugg commented Jul 19, 2018

Getting this too..
2018/07/19 14:48:17 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Drop table issue columns [assignee_id]: sql: Transaction has already been committed or rolled back

However, we're using postgres

@johanhugg
Copy link

I manually applied PR #4459 and it worked wonderfully!

@lunny
Copy link
Member

lunny commented Jul 20, 2018

@johanhugg could you try #4473 if it works?

@anthrogan
Copy link

I attempted updating today from 1.4.1 and had the same issue #4473 doesn't seem to fix it (Running on windows 10 pro box)

@aurel-appsthru
Copy link

Hi , I attempted updating today from 1.4.3 to 1.5 and had the same issue #4360

2018/08/20 17:28:46 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Drop table issue columns [assignee_id]: mssql: ALTER TABLE DROP COLUMN assignee_id a échoué car un ou plusieurs objets accèdent à cette colonne.

( Windows Server 2008R2 , MSSQL 2012 )

thx for your help

@lafriks
Copy link
Member

lafriks commented Aug 21, 2018

Were you using final 1.5.0 release?

@bjoe2k4
Copy link

bjoe2k4 commented Aug 21, 2018

I have just updated from 1.4.1 to 1.5.0. Worked fine for me. So the error I received earlier (same as the one of @aurel-appsthru) seems to be resolved for me.

Edit: However there are a bunch of logs emitted on every restart, How to get rid of them?

gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table user Column allow_create_organization db default is 1, struct default is true
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table user Column prohibit_login db default is 0, struct default is false
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table repository Column is_fork db default is 0, struct default is false
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table repository Column is_fsck_enabled db default is 1, struct default is true
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table action Column is_deleted db default is 0, struct default is false
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table action Column is_private db default is 0, struct default is false
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table mirror Column enable_prune db default is 1, struct default is true
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table release Column is_draft db default is 0, struct default is false
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table release Column is_prerelease db default is 0, struct default is false
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table release Column is_tag db default is 0, struct default is false
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table login_source Column is_actived db default is 0, struct default is false
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table login_source Column is_sync_enabled db default is 0, struct default is false
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table protected_branch Column can_push db default is 0, struct default is false
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table protected_branch Column enable_merge_whitelist db default is 0, struct default is false
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table user_open_id Column show db default is 0, struct default is false
gitea-1.5.0-linux-amd64[12494]: 2018/08/21 13:18:03 [W] Table comment has column old_assignee_id but struct has not related field

@aurel-appsthru
Copy link

@lafriks : yes I tried with 1.5.0. The service start but stop on first refresh of a page.
I tried also 1.5 and master : service did not start, same log.

( Windows Server 2008R2 , MSSQL 2012 )

1.5.0 log :

2018/08/21 14:04:40 [I] Log Mode: File(Trace)
2018/08/21 14:04:40 [I] XORM Log Mode: File(Trace)
2018/08/21 14:04:40 [I] Cache Service Enabled
2018/08/21 14:04:40 [I] Session Service Enabled
2018/08/21 14:04:40 [I] Migration: add label descriptions
2018/08/21 14:04:42 [I] Migration: add merge whitelist for protected branches
2018/08/21 14:04:43 [I] Migration: add is_fsck_enabled column for repos
2018/08/21 14:04:45 [I] Migration: add size column for attachments
2018/08/21 14:04:45 [...ations/migrations.go:53 Migrate()] [E] calculate file size of attachment[UUID: 8162838b-76b5-410f-a546-3be9ae7d995e]: CreateFile E:\GitRepositories\attachments/8/1/8162838b-76b5-410f-a546-3be9ae7d995e: Le chemin d’accès spécifié est introuvable.
2018/08/21 14:04:45 [I] Migration: add last used passcode column for TOTP
2018/08/21 14:04:45 [I] Migration: add language column for user setting
2018/08/21 14:04:45 [I] Migration: add multiple assignees
2018/08/21 14:04:45 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Drop table issue columns [assignee_id]: mssql: ALTER TABLE DROP COLUMN assignee_id a échoué car un ou plusieurs objets accèdent à cette colonne.

1.5 and master log :

2018/08/21 14:07:52 [I] Log Mode: File(Trace)
2018/08/21 14:07:52 [I] XORM Log Mode: File(Trace)
2018/08/21 14:07:52 [I] Cache Service Enabled
2018/08/21 14:07:52 [I] Session Service Enabled
2018/08/21 14:07:52 [I] Migration: add multiple assignees
2018/08/21 14:07:52 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Drop table issue columns [assignee_id]: mssql: ALTER TABLE DROP COLUMN assignee_id a échoué car un ou plusieurs objets accèdent à cette colonne.

@tenacubus
Copy link
Contributor

tenacubus commented Aug 28, 2018

@lafriks I'm still getting the migration issue with the new 1.5.0 binary as well

2018/08/28 09:43:25 [I] Migration: add multiple assignees
2018/08/28 09:43:25 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Drop table issue columns [assignee_id]: mssql: ALTER TABLE DROP COLUMN assignee_id failed because one or more objects access this column.

Tried running the alter drop column manually in mssql to see if I got a more descriptive error. Turns out we've got an index IDX_issue_assignee_id hanging around getting in the way.

Msg 5074, Level 16, State 1, Line 7
The index 'IDX_issue_assignee_id' is dependent on column 'assignee_id'.
Msg 4922, Level 16, State 9, Line 7
ALTER TABLE DROP COLUMN assignee_id failed because one or more objects access this column.

Manually deleting the index and rerunning the upgrade finished successfully

@aurel-appsthru
Copy link

@lafriks @tenacubus
Hi, deleting the index manually, it works.

DROP INDEX [IDX_issue_assignee_id] ON [dbo].[issue]

thx a lot

@leepfrog-ger
Copy link

@lafriks I received the same error as @aurel-appsthru and @tenacubus
when updating from 1.4.1 to 1.5.1 running on MSSQL 2016.

Dropping the index DROP INDEX [IDX_issue_assignee_id] ON [dbo].[issue] allowed the migration to run through

Maybe this should be treated as separate issue as this original error in this issue seems to be different

@tenacubus
Copy link
Contributor

@leepfrog-ger I'd say we should reopen this issue as the initial error was the exact one I had. Additionally the initial poster never confirmed it fixed their problem. Hey @ymabispo did you ever try it?

What do you think @lafriks? I don't know the policy as far as reopening issues or creating a new one.

I see the mssql code in DropTableColumns only looks for and deletes constraints but does not address indexes

case setting.UseMSSQL:
cols := ""
for _, col := range columnNames {
if cols != "" {
cols += ", "
}
cols += "`" + strings.ToLower(col) + "`"
}
sql := fmt.Sprintf("SELECT Name FROM SYS.DEFAULT_CONSTRAINTS WHERE PARENT_OBJECT_ID = OBJECT_ID('%[1]s') AND PARENT_COLUMN_ID IN (SELECT column_id FROM sys.columns WHERE lower(NAME) IN (%[2]s) AND object_id = OBJECT_ID('%[1]s'))",
tableName, strings.Replace(cols, "`", "'", -1))
constraints := make([]string, 0)
if err := sess.SQL(sql).Find(&constraints); err != nil {
sess.Rollback()
return fmt.Errorf("Find constraints: %v", err)
}
for _, constraint := range constraints {
if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` DROP CONSTRAINT `%s`", tableName, constraint)); err != nil {
sess.Rollback()
return fmt.Errorf("Drop table `%s` constraint `%s`: %v", tableName, constraint, err)
}
}
if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` DROP COLUMN %s", tableName, cols)); err != nil {
sess.Rollback()
return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err)
}
return sess.Commit()
default:
log.Fatal(4, "Unrecognized DB")
}

@lafriks lafriks reopened this Sep 5, 2018
@leepfrog-ger
Copy link

@tenacubus you are right, I mixed up something, I've also got the same errors as in the initial issue. so the reopening is fine with me.

@ymabispo
Copy link
Author

ymabispo commented Sep 7, 2018

Hi guys, sorry about the late response.
I've been using gitea to manage very important repositories, so i can not try a new update without any confirmation about the integrity of this new version.

Thanks

@davydov-vyacheslav
Copy link

is there any update on 1.5.2 issues? E.g. this issue looks like critical and I'm scaring of upgrading to latest 1.5 version (from 1.4)

Thanks in advance

@lafriks
Copy link
Member

lafriks commented Sep 26, 2018

@davydov-vyacheslav it only affects instamces running mssql database

@davydov-vyacheslav
Copy link

ok. thank you

@techknowlogick techknowlogick modified the milestones: 1.5.2, 1.7.0 Oct 9, 2018
@vinnyaju
Copy link

I'm on version 1.4.3 and i tried to delete manually using DROP INDEX [IDX_issue_assignee_id] ON [dbo].[issue]
and now i'm stuck in a timeout while applying another migration "[I] Migration: remove stale watches"

i've tried to migrate from 1.4.3 to 1.5, 1.5.1, 1.5.3 and 1.6 allways restoring the database and runing all the way through.

@lafriks lafriks modified the milestones: 1.7.0, 1.8.0 Dec 27, 2018
@lafriks lafriks added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Dec 27, 2018
@lafriks
Copy link
Member

lafriks commented Dec 27, 2018

I think there was some mssql fixes for migrations. Is this still an unresolved issue?

@vinnyaju
Copy link

vinnyaju commented Dec 27, 2018

i just tried update from 1.4.3 to 1.6.2 and i got:

2018/12/27 14:02:34 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Drop table issue columns [assignee_id]: mssql: ALTER TABLE DROP COLUMN assignee_id failed because one or more objects access this column.

and i droped the index on issue table:
DROP INDEX [IDX_issue_assignee_id] ON [dbo].[issue]

then i got more migrations applied:
2018/12/27 14:06:38 [I] Migration: add multiple assignees
2018/12/27 14:06:38 [I] Migration: add u2f
2018/12/27 14:06:39 [I] Migration: add login source id column for public_key table

and got a timeout...
2018/12/27 14:06:42 [I] Migration: remove stale watches
2018/12/27 14:07:13 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: read tcp 10.100.4.98:57151->10.200.5.108:1433: i/o timeout

Still can't evolve my version...

@rafaeldeda
Copy link

Guys, anyone to help us? We are still having trouble updating gitea version 1.4.3 to version 1.7 motivated by this error in mssql. Will there be any correction for this?

capturar

@vinnyaju
Copy link

As i said in my last comment here, after i dropped the index on issue table i got a timeout.

Watching a more detailed log i saw the timeout in this statement: SELECT * FROM "watch" WHERE (id NOT IN (SELECT TOP 50 id FROM "watch"))

So i decided to delete all the data in the watch table and tried to update from 1.4.3 to 1.7.1 and it was ok in my test environment, i'll do it in production environment tomorrow morning and send an e-mail telling everyone to click watch button in the repository they want to follow.

The problem with the update has something to do with the data that was in this table...

@techknowlogick techknowlogick modified the milestones: 1.8.0, 1.9.0 Feb 19, 2019
@techknowlogick techknowlogick modified the milestones: 1.9.0, 1.10.0 Jun 4, 2019
@techknowlogick techknowlogick modified the milestones: 1.10.0, 1.11.0 Sep 3, 2019
@lunny
Copy link
Member

lunny commented Dec 14, 2019

Some migrations depends on how many rows of that table. It may timeout on some situations.

@techknowlogick techknowlogick removed the issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP label Dec 22, 2019
@techknowlogick techknowlogick removed this from the 1.11.0 milestone Dec 22, 2019
@stale
Copy link

stale bot commented Feb 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale stale bot added the issue/stale label Feb 20, 2020
@stale
Copy link

stale bot commented Mar 5, 2020

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale stale bot closed this as completed Mar 5, 2020
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail issue/stale type/bug
Projects
None yet