{"record":{"id":"5567383abbe2db59","repo":"v2rayA/v2rayA","slug":"failed-to-open-boltdb-w","errorCode":null,"errorMessage":"failed to open BoltDB: %w","messagePattern":"failed to open BoltDB: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/db/migrate.go","lineNumber":42,"sourceCode":"\n\t// Check if BoltDB file exists\n\tif _, err := os.Stat(boltPath); os.IsNotExist(err) {\n\t\tlog.Info(\"No BoltDB file found at %s, skipping migration\", boltPath)\n\t\treturn nil\n\t}\n\n\t// Check if SQLite already exists (migration already done or fresh start)\n\tif _, err := os.Stat(sqlitePath); err == nil {\n\t\tlog.Info(\"SQLite database already exists at %s, skipping migration\", sqlitePath)\n\t\treturn nil\n\t}\n\n\tlog.Warn(\"Migrating from BoltDB to SQLite...\")\n\n\t// Open BoltDB (read-only)\n\tboltDB, err := bbolt.Open(boltPath, 0600, &bbolt.Options{ReadOnly: true})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open BoltDB: %w\", err)\n\t}\n\tdefer boltDB.Close()\n\n\t// Create a fresh SQLite database independently (do NOT use GetDB)\n\tsqldb, err := createSQLiteDB(sqlitePath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create SQLite database for migration: %w\", err)\n\t}\n\tdefer sqldb.Close()\n\n\t// Perform migration in a single transaction\n\ttx, err := sqldb.Begin()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to begin SQLite transaction: %w\", err)\n\t}\n\tdefer func() {\n\t\tif p := recover(); p != nil {\n\t\t\t_ = tx.Rollback()","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/v2rayA/v2rayA/blob/71e5442fc548c05680ee55eae943e6c0afe9ac51/service/db/migrate.go#L24-L60","documentation":"Raised in MigrateFromBoltDB when bbolt.Open in read-only mode fails on the detected BoltDB file: the file exists (stat succeeded) but cannot be opened — it may be locked by another process, not a valid BoltDB database, or unreadable. Migration from BoltDB to SQLite aborts.","triggerScenarios":"Thrown at service/db/migrate.go:42 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Stop other v2rayA instances holding the BoltDB lock","Check file permissions on the .db file","Remove the stale BoltDB file if migration is not needed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"71e5442fc548c05680ee55eae943e6c0afe9ac51","analyzedAt":"2026-09-05T20:04:37.459Z","contentChangedAt":"2026-09-05T20:04:37.459Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}