Skip to content

MSSQL, Error: sync database struct error: mssql: Invalid object name 'SYS.INDEXES'. #13615

Closed
@harkirat777

Description

@harkirat777
  • Gitea version (or commit ref): 1.12.6 (same error on 1.13.0-rc2)
  • Git version: 2.15.1
  • Operating system: Microsoft Server 2012 R2
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL v2017
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

I am trying to install gitea 1.12.6 on SQL Server 2017. I have database and user using the following query:

CREATE DATABASE giteadb
ALTER DATABASE giteadb COLLATE SQL_Latin1_General_CP1_CS_AS

USE master
CREATE LOGIN giteauser WITH PASSWORD=N'giteapass', DEFAULT_DATABASE=giteadb, CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
ALTER AUTHORIZATION ON DATABASE::giteadb TO giteauser

When I click 'Install Gitea' from localhost:3000, a bunch of tables are generated in the database but then I get the below error.

...

Log

2020/11/18 09:31:03 ...dules/setting/log.go:279:newLogService() [I] Gitea Log Mode: File(File:info)
2020/11/18 09:31:03 ...les/setting/cache.go:70:newCacheService() [I] Cache Service Enabled
2020/11/18 09:31:03 ...les/setting/cache.go:81:newCacheService() [I] Last Commit Cache Service Enabled
2020/11/18 09:31:03 ...s/setting/session.go:63:newSessionService() [I] Session Service Enabled
2020/11/18 09:31:03 routers/init.go:63:initDBEngine() [I] Beginning ORM engine initialization.
2020/11/18 09:31:03 routers/init.go:70:initDBEngine() [I] ORM engine initialization attempt #1/10...
2020/11/18 09:31:03 ...rm/session_schema.go:25:Ping() [I] PING DATABASE mssql
2020/11/18 09:31:03 ...eue/queue_wrapped.go:75:setInternal() [W] [Attempt: 1] Failed to create queue: level for notification-service cfg: queue.LevelQueueConfiguration{ByteFIFOQueueConfiguration:queue.ByteFIFOQueueConfiguration{WorkerPoolConfiguration:queue.WorkerPoolConfiguration{QueueLength:20, BatchLength:20, BlockTimeout:1000000000, BoostTimeout:300000000000, BoostWorkers:5, MaxWorkers:6}, Workers:1, Name:"notification-service-level"}, DataDir:"D:\\gitea\\var\\lib\\gitea\\data\\queues\\notification-service"} error: The process cannot access the file because it is being used by another process.
2020/11/18 09:31:03 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] select * from sysobjects where id = object_id(N'version') and OBJECTPROPERTY(id, N'IsUserTable') = 1 [] - 3.9997ms
2020/11/18 09:31:03 ...m.io/xorm/core/db.go:277:ExecContext() [I] [SQL] IF NOT EXISTS (SELECT [name] FROM sys.tables WHERE [name] = 'version' ) CREATE TABLE [version] ([id] BIGINT PRIMARY KEY IDENTITY NOT NULL, [version] BIGINT NULL); [] - 12.0016ms
2020/11/18 09:31:03 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT "COLUMN_NAME" FROM "INFORMATION_SCHEMA"."COLUMNS" WHERE "TABLE_NAME" = ? AND "COLUMN_NAME" = ? [version id] - 32.998ms
2020/11/18 09:31:03 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT "COLUMN_NAME" FROM "INFORMATION_SCHEMA"."COLUMNS" WHERE "TABLE_NAME" = ? AND "COLUMN_NAME" = ? [version version] - 14.0031ms
2020/11/18 09:31:03 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT TOP 1 [id], [version] FROM [version] WHERE [id]=? [1] - 997.5µs
2020/11/18 09:31:03 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] INSERT INTO [version] ([version]) OUTPUT Inserted.id VALUES (?) [141] - 2.9998ms
2020/11/18 09:31:03 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] select name from sysobjects where xtype ='U' [] - 2.0005ms
2020/11/18 09:31:03 ...eue/queue_wrapped.go:75:setInternal() [W] [Attempt: 2] Failed to create queue: level for notification-service cfg: queue.LevelQueueConfiguration{ByteFIFOQueueConfiguration:queue.ByteFIFOQueueConfiguration{WorkerPoolConfiguration:queue.WorkerPoolConfiguration{QueueLength:20, BatchLength:20, BlockTimeout:1000000000, BoostTimeout:300000000000, BoostWorkers:5, MaxWorkers:6}, Workers:1, Name:"notification-service-level"}, DataDir:"D:\\gitea\\var\\lib\\gitea\\data\\queues\\notification-service"} error: The process cannot access the file because it is being used by another process.
2020/11/18 09:31:03 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] select a.name as name, b.name as ctype,a.max_length,a.precision,a.scale,a.is_nullable as nullable,
			  "default_is_null" = (CASE WHEN c.text is null THEN 1 ELSE 0 END),
		      replace(replace(isnull(c.text,''),'(',''),')','') as vdefault,
			  ISNULL(p.is_primary_key, 0), a.is_identity as is_identity
	          from sys.columns a 
			  left join sys.types b on a.user_type_id=b.user_type_id
	          left join sys.syscomments c on a.default_object_id=c.id
			  LEFT OUTER JOIN (SELECT i.object_id, ic.column_id, i.is_primary_key
				FROM sys.indexes i
			  LEFT JOIN sys.index_columns ic ON ic.object_id = i.object_id AND ic.index_id = i.index_id
				WHERE i.is_primary_key = 1
			) as p on p.object_id = a.object_id AND p.column_id = a.column_id
	          where a.object_id=object_id('user') [] - 88.9988ms
2020/11/18 09:31:03 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT
	IXS.NAME                    AS  [INDEX_NAME],
	C.NAME                      AS  [COLUMN_NAME],
	IXS.is_unique AS [IS_UNIQUE]
	FROM SYS.INDEXES IXS
	INNER JOIN SYS.INDEX_COLUMNS   IXCS
	ON IXS.OBJECT_ID=IXCS.OBJECT_ID  AND IXS.INDEX_ID = IXCS.INDEX_ID
	INNER   JOIN SYS.COLUMNS C  ON IXS.OBJECT_ID=C.OBJECT_ID
	AND IXCS.COLUMN_ID=C.COLUMN_ID
	WHERE IXS.TYPE_DESC='NONCLUSTERED' and OBJECT_NAME(IXS.OBJECT_ID) =?
	 [user] - 1.0002ms
2020/11/18 09:31:03 routers/init.go:76:initDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: sync database struct error: mssql: Invalid object name 'SYS.INDEXES'.
2020/11/18 09:31:03 routers/init.go:77:initDBEngine() [I] Backing off for 3 seconds
2020/11/18 09:31:03 ...eue/queue_wrapped.go:75:setInternal() [W] [Attempt: 3] Failed to create queue: level for notification-service cfg: queue.LevelQueueConfiguration{ByteFIFOQueueConfiguration:queue.ByteFIFOQueueConfiguration{WorkerPoolConfiguration:queue.WorkerPoolConfiguration{QueueLength:20, BatchLength:20, BlockTimeout:1000000000, BoostTimeout:300000000000, BoostWorkers:5, MaxWorkers:6}, Workers:1, Name:"notification-service-level"}, DataDir:"D:\\gitea\\var\\lib\\gitea\\data\\queues\\notification-service"} error: The process cannot access the file because it is being used by another process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugtype/upstreamThis is an issue in one of Gitea's dependencies and should be reported there

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions