{"record":{"id":"e36f5d2bcd379964","repo":"googleapis/mcp-toolbox","slug":"unable-to-connect-successfully-w-e36f5d","errorCode":null,"errorMessage":"unable to connect successfully: %w","messagePattern":"unable to connect successfully: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/sqlite/sqlite.go","lineNumber":70,"sourceCode":"\tType         string `yaml:\"type\" validate:\"required\"`\n\tDatabase     string `yaml:\"database\" validate:\"required\"` // Path to SQLite database file\n\tSQLCommenter *bool  `yaml:\"sqlCommenter\"`\n}\n\nfunc (r Config) SourceConfigType() string {\n\treturn SourceType\n}\n\nfunc (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {\n\tdb, err := initSQLiteConnection(ctx, tracer, r.Name, r.Database)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create db connection: %w\", err)\n\t}\n\n\terr = db.PingContext(context.Background())\n\tif err != nil {\n\t\tdb.Close()\n\t\treturn nil, fmt.Errorf(\"unable to connect successfully: %w\", err)\n\t}\n\n\ts := &Source{\n\t\tConfig: r,\n\t\tDb:     db,\n\t}\n\treturn s, nil\n}\n\nvar _ sources.Source = &Source{}\n\ntype Source struct {\n\tConfig\n\tDb *sql.DB\n}\n\nfunc (s *Source) IsReadOnly() bool {\n\treturn false","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/sqlite/sqlite.go#L52-L88","documentation":"sqlite Config.Initialize (internal/sources/sqlite/sqlite.go:70) pings the newly opened database with db.PingContext to confirm a real connection works. On failure the db is closed and the error is wrapped as \"unable to connect successfully\". For SQLite this usually means the file cannot actually be accessed (locked, unreadable, or a connection-time pragma failure).","triggerScenarios":"Initialize called where db.PingContext fails after Open: database file locked by another process holding an exclusive lock, file unreadable/corrupt, or a driver-level failure establishing the first connection.","commonSituations":"Another process holds a write lock (e.g. a separate toolbox instance or sqlite3 CLI in a transaction); db file corrupted; NFS-mounted SQLite file with locking problems; disk full during journal creation.","solutions":["Check for other processes holding locks: lsof /path/to/db.sqlite3, and close them","Verify file integrity: run `sqlite3 /path/to/db.sqlite3 'PRAGMA integrity_check;'`","Ensure the filesystem supports SQLite locking properly (avoid NFS for live db files)","Check free disk space — SQLite needs room for its journal/WAL files"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// before starting toolbox\nout, err := exec.Command(\"sqlite3\", dbPath, \"PRAGMA integrity_check;\").Output()\nif err != nil || !strings.Contains(string(out), \"ok\") { log.Fatal(\"sqlite db not healthy or locked\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run a single toolbox process per sqlite file to avoid lock contention","Enable WAL mode for concurrent readers","Avoid storing live SQLite databases on NFS","Run PRAGMA integrity_check after crashes"],"tags":["sqlite","ping","database-locked"],"backgroundTag":"database-locked","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}