{"record":{"id":"d1193e02fba727a2","repo":"flipped-aurora/gin-vue-admin","slug":"error-d1193e","errorCode":null,"errorMessage":"无可用初始化过程，请检查初始化是否已执行完成","messagePattern":"无可用初始化过程，请检查初始化是否已执行完成","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/sys_initdb.go","lineNumber":102,"sourceCode":"\tname := i.InitializerName()\n\tif _, existed := cache[name]; existed {\n\t\tpanic(fmt.Sprintf(\"Name conflict on %s\", name))\n\t}\n\tni := orderedInitializer{order, i}\n\tinitializers = append(initializers, &ni)\n\tcache[name] = &ni\n}\n\n/* ---- * service * ---- */\n\ntype InitDBService struct{}\n\n// InitDB 创建数据库并初始化 总入口\nfunc (initDBService *InitDBService) InitDB(conf request.InitDB) (err error) {\n\tctx := context.TODO()\n\tctx = context.WithValue(ctx, \"adminPassword\", conf.AdminPassword)\n\tif len(initializers) == 0 {\n\t\treturn errors.New(\"无可用初始化过程，请检查初始化是否已执行完成\")\n\t}\n\tsort.Sort(&initializers) // 保证有依赖的 initializer 排在后面执行\n\t// Note: 若 initializer 只有单一依赖，可以写为 B=A+1, C=A+1; 由于 BC 之间没有依赖关系，所以谁先谁后并不影响初始化\n\t// 若存在多个依赖，可以写为 C=A+B, D=A+B+C, E=A+1;\n\t// C必然>A|B，因此在AB之后执行，D必然>A|B|C，因此在ABC后执行，而E只依赖A，顺序与CD无关，因此E与CD哪个先执行并不影响\n\tvar initHandler TypedDBInitHandler\n\tswitch conf.DBType {\n\tcase \"mysql\":\n\t\tinitHandler = NewMysqlInitHandler()\n\t\tctx = context.WithValue(ctx, \"dbtype\", \"mysql\")\n\tcase \"pgsql\":\n\t\tinitHandler = NewPgsqlInitHandler()\n\t\tctx = context.WithValue(ctx, \"dbtype\", \"pgsql\")\n\tcase \"sqlite\":\n\t\tinitHandler = NewSqliteInitHandler()\n\t\tctx = context.WithValue(ctx, \"dbtype\", \"sqlite\")\n\tcase \"mssql\":\n\t\tinitHandler = NewMssqlInitHandler()","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/sys_initdb.go#L84-L120","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Restart the application process and use the init API once — do not call InitDB again after it succeeded (initializers are cleared after success).","Verify the server binary includes the packages under server/source/ whose init() functions call registerInit; rebuild the full binary.","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.","If a custom initializer package was added, confirm its init() registration function actually runs in your build."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// in the API layer, before calling InitDB a second time:\nif systemServiceAlreadyInitialized() {\n\treturn errors.New(\"database already initialized\")\n}","typeGuard":null,"tryCatchPattern":"err := initDBService.InitDB(conf)\nif err != nil && strings.Contains(err.Error(), \"无可用初始化过程\") {\n\t// initializer registry empty: DB likely already initialized or binary incomplete\n\t// direct operator to restart/rebuild rather than retrying\n}","preventionTips":["Treat InitDB as one-shot: skip it when config.yaml already has DB settings.","Ensure the binary is built from the full source tree including server/source/* init() registrations.","Do not clear or bypass registerInit calls in custom builds.","Add a startup smoke test that the initializer registry is non-empty when init mode is enabled."],"tags":["go","initialization","configuration"],"backgroundTag":"initialization-not-executed","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}