flipped-aurora/gin-vue-admin · error

无可用初始化过程,请检查初始化是否已执行完成

Error message

无可用初始化过程,请检查初始化是否已执行完成

What it means

InitDB is the master entry for first-time database creation. The set of initializers is populated by init() functions in source packages via registerInit; if that registration never happened, the initializer list is empty and InitDB aborts with this Chinese-language error telling the operator to check that initialization ran completely. It protects against starting the init flow with no migration/table-initialization steps registered.

Source

Thrown at server/service/system/sys_initdb.go:102

	name := i.InitializerName()
	if _, existed := cache[name]; existed {
		panic(fmt.Sprintf("Name conflict on %s", name))
	}
	ni := orderedInitializer{order, i}
	initializers = append(initializers, &ni)
	cache[name] = &ni
}

/* ---- * service * ---- */

type InitDBService struct{}

// InitDB 创建数据库并初始化 总入口
func (initDBService *InitDBService) InitDB(conf request.InitDB) (err error) {
	ctx := context.TODO()
	ctx = context.WithValue(ctx, "adminPassword", conf.AdminPassword)
	if len(initializers) == 0 {
		return errors.New("无可用初始化过程,请检查初始化是否已执行完成")
	}
	sort.Sort(&initializers) // 保证有依赖的 initializer 排在后面执行
	// Note: 若 initializer 只有单一依赖,可以写为 B=A+1, C=A+1; 由于 BC 之间没有依赖关系,所以谁先谁后并不影响初始化
	// 若存在多个依赖,可以写为 C=A+B, D=A+B+C, E=A+1;
	// C必然>A|B,因此在AB之后执行,D必然>A|B|C,因此在ABC后执行,而E只依赖A,顺序与CD无关,因此E与CD哪个先执行并不影响
	var initHandler TypedDBInitHandler
	switch conf.DBType {
	case "mysql":
		initHandler = NewMysqlInitHandler()
		ctx = context.WithValue(ctx, "dbtype", "mysql")
	case "pgsql":
		initHandler = NewPgsqlInitHandler()
		ctx = context.WithValue(ctx, "dbtype", "pgsql")
	case "sqlite":
		initHandler = NewSqliteInitHandler()
		ctx = context.WithValue(ctx, "dbtype", "sqlite")
	case "mssql":
		initHandler = NewMssqlInitHandler()

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Restart the application process and use the init API once — do not call InitDB again after it succeeded (initializers are cleared after success).
  2. Verify the server binary includes the packages under server/source/ whose init() functions call registerInit; rebuild the full binary.
  3. Check you hit the intended init endpoint/flow; if the DB was already initialized (config.yaml written), skip re-initialization and start the server normally.
  4. If a custom initializer package was added, confirm its init() registration function actually runs in your build.
Defensive patterns

Strategy: validation

Validate before calling

// in the API layer, before calling InitDB a second time:
if systemServiceAlreadyInitialized() {
	return errors.New("database already initialized")
}

Try / catch

err := initDBService.InitDB(conf)
if err != nil && strings.Contains(err.Error(), "无可用初始化过程") {
	// initializer registry empty: DB likely already initialized or binary incomplete
	// direct operator to restart/rebuild rather than retrying
}

Prevention

When it happens

Trigger: Calling InitDBService.InitDB(conf) when the global `initializers` slice is empty — i.e. no SubInitializer was registered through registerInit by any source/*/init() before the call.

Common situations: Re-running InitDB after a successful initialization: sys_initdb.go clears `initializers` at the end of a successful run (initializers = initSlice{}), so a second call hits this error; build tags or a binary stripped of the packages whose init() functions register initializers; custom builds that removed initializer source files.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/d1193e02fba727a2. Report an issue: GitHub.