{"record":{"id":"24f8c382762468e6","repo":"AlistGo/alist","slug":"index-is-running","errorCode":null,"errorMessage":"index is running","messagePattern":"index is running","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/search/search.go","lineNumber":31,"sourceCode":")\n\nvar instance searcher.Searcher = nil\n\n// Init or reset index\nfunc Init(mode string) error {\n\tif instance != nil {\n\t\t// unchanged, do nothing\n\t\tif instance.Config().Name == mode {\n\t\t\treturn nil\n\t\t}\n\t\terr := instance.Release(context.Background())\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"release instance err: %+v\", err)\n\t\t}\n\t\tinstance = nil\n\t}\n\tif Running() {\n\t\treturn fmt.Errorf(\"index is running\")\n\t}\n\tif mode == \"none\" {\n\t\tlog.Warnf(\"not enable search\")\n\t\treturn nil\n\t}\n\ts, ok := searcher.NewMap[mode]\n\tif !ok {\n\t\treturn fmt.Errorf(\"not support index: %s\", mode)\n\t}\n\ti, err := s()\n\tif err != nil {\n\t\tlog.Errorf(\"init searcher error: %+v\", err)\n\t} else {\n\t\tinstance = i\n\t}\n\treturn err\n}\n","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/internal/search/search.go#L13-L49","documentation":"search.Init(mode) refuses to (re)initialize the search backend while an indexing/build operation is in progress (search.Running() is true). This prevents swapping the searcher instance under a running index job.","triggerScenarios":"Calling search.Init (e.g. via the admin API/setting change of the search config) while a bulk index build (BuildIndex over storages) is still running, or a previous index run never terminated.","commonSituations":"Admin changes the search driver in settings during a large initial index build; a stuck index job leaves Running() true indefinitely.","solutions":["Wait for the current indexing run to finish, then re-apply the settings change","Check logs/job status for a hung index job and stop it cleanly","Restart the AList process if the running flag is stuck after a crash","Set search config before triggering large index builds to avoid the race"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if search.Running() {\n    // defer config change until the current index build completes\n    return errors.New(\"defer: index build in progress\")\n}","typeGuard":null,"tryCatchPattern":"err := search.Init(newMode)\nif err != nil && strings.Contains(err.Error(), \"index is running\") {\n    // schedule retry after the build finishes instead of failing the settings update\n}","preventionTips":["Change search settings only when no index build is scheduled/running","Run initial full index builds during maintenance windows","Monitor index job completion before driver swaps"],"tags":["go","search","concurrency","configuration"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}