{"record":{"id":"681844047cacc2b9","repo":"benbjohnson/litestream","slug":"cannot-open-store-w","errorCode":null,"errorMessage":"cannot open store: %w","messagePattern":"cannot open store: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cmd/litestream/replicate.go","lineNumber":292,"sourceCode":"\t\t}\n\t\tc.Store.Heartbeat = litestream.NewHeartbeatClient(c.Config.HeartbeatURL, interval)\n\t}\n\n\t// Disable all background monitors when running once.\n\t// This must be done after config settings are applied.\n\tif c.once {\n\t\tc.Store.CompactionMonitorEnabled = false\n\t\tc.Store.L0RetentionCheckInterval = 0\n\t\tfor _, db := range dbs {\n\t\t\tdb.MonitorInterval = 0\n\t\t\tif db.Replica != nil {\n\t\t\t\tdb.Replica.MonitorEnabled = false\n\t\t\t}\n\t\t}\n\t}\n\n\tif err := c.Store.Open(ctx); err != nil {\n\t\treturn fmt.Errorf(\"cannot open store: %w\", err)\n\t}\n\n\tif !c.Store.RetentionEnabled {\n\t\tslog.Warn(\"retention disabled; cloud provider lifecycle policies must handle retention\",\n\t\t\t\"hint\", \"idle databases that stop receiving writes will not generate new snapshots and may lose backup coverage if cloud retention expires\")\n\t}\n\n\t// Start control server if socket is enabled\n\tif c.Config.Socket.Enabled {\n\t\tc.Server = litestream.NewServer(c.Store)\n\t\tc.Server.SocketPath = c.Config.Socket.Path\n\t\tc.Server.SocketPerms = c.Config.Socket.Permissions\n\t\tc.Server.PathExpander = expand\n\t\tc.Server.Version = Version\n\t\tif err := c.Server.Start(); err != nil {\n\t\t\tslog.Warn(\"failed to start control server\", \"error\", err)\n\t\t}\n\t}","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/replicate.go#L274-L310","documentation":"`Store.Open` initializes the replication store: opens/configures all databases from the config and starts their monitors. If any database fails to open (bad path, locked file, invalid replica config, storage client errors), Run wraps the failure with \"cannot open store\". This is the main startup failure point for the replicate command.","triggerScenarios":"Calling `litestream.ReplicateCommand.Run` where `c.Store.Open(ctx)` returns an error — e.g. configured DB file cannot be opened, a replica client fails to initialize (bad credentials/endpoint), or invalid config values.","commonSituations":"Wrong DB path in config file, S3 credentials missing/expired, unreachable storage endpoint at startup, malformed config causing invalid DB construction.","solutions":["Read the wrapped inner error for the root cause (permissions, missing file, storage auth)","Verify the config file DB paths exist and are readable by the litestream process","Test storage credentials/endpoint (e.g. `litestream ltx` or aws CLI against the bucket)","Validate the config with `litestream -config <file> ...` dry parsing before running"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"# pre-flight checks before starting litestream\n[ -f \"$DB_PATH\" ] || { echo \"db missing: $DB_PATH\" >&2; exit 1; }\n[ -r \"$DB_PATH\" ] && [ -w \"$DB_PATH\" ] || { echo \"db not rw\" >&2; exit 1; }\n# verify storage access (example for s3)\naws s3 ls \"s3://$BUCKET/\" >/dev/null || { echo \"storage auth failed\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"// Go library usage\ncmd := litestream.NewReplicateCommand()\nif err := cmd.Run(ctx); err != nil {\n    var storeErr *fmt.WrapError // inspect wrapped cause via errors.Unwrap chain\n    for e := err; e != nil; e = errors.Unwrap(e) {\n        log.Printf(\"cause: %v\", e)\n    }\n    return fmt.Errorf(\"store startup failed: %w\", err)\n}","preventionTips":["Run pre-flight checks on DB paths and storage credentials before startup","Validate config files with a dry run after every edit","Use secrets management so storage credentials are present at boot","Monitor startup logs — the wrapped inner error names the exact failing component"],"tags":["startup","store","config","storage"],"backgroundTag":"api-request-failed","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}