{"record":{"id":"bfcb7cdd36444d96","repo":"thanos-io/thanos","slug":"wal-dir-is-not-accessible-is-this-dir-a-tsdb-dire","errorCode":null,"errorMessage":"WAL dir is not accessible. Is this dir a TSDB directory? If yes it is shared with TSDB?","messagePattern":"WAL dir is not accessible\\. Is this dir a TSDB directory\\? If yes it is shared with TSDB\\?","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/promclient/promclient.go","lineNumber":156,"sourceCode":"\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, resp.StatusCode, errors.Wrap(err, \"read body\")\n\t}\n\tif resp.StatusCode/100 != 2 {\n\t\treturn nil, resp.StatusCode, errors.Errorf(\"expected 2xx response, got %d. Body: %v\", resp.StatusCode, string(body))\n\t}\n\treturn body, resp.StatusCode, nil\n}\n\n// IsWALDirAccessible returns no error if WAL dir can be found. This helps to tell\n// if we have access to Prometheus TSDB directory.\nfunc IsWALDirAccessible(dir string) error {\n\tconst errMsg = \"WAL dir is not accessible. Is this dir a TSDB directory? If yes it is shared with TSDB?\"\n\n\tf, err := os.Stat(filepath.Join(dir, \"wal\"))\n\tif err != nil {\n\t\treturn errors.Wrap(err, errMsg)\n\t}\n\n\tif !f.IsDir() {\n\t\treturn errors.New(errMsg)\n\t}\n\n\treturn nil\n}\n\n// IsDirAccessible returns no error if dir can be found.\nfunc IsDirAccessible(dir string) error {\n\tconst errMsg = \"Dir is not accessible.\"\n\n\tf, err := os.Stat(dir)\n\tif err != nil {\n\t\treturn errors.Wrap(err, errMsg)\n\t}\n","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/promclient/promclient.go#L138-L174","documentation":"IsWALDirAccessible checks that <dir>/wal exists and is a directory (i.e. the path looks like a live Prometheus TSDB directory). When os.Stat fails (missing path, permission problem), the stat error is wrapped with this message explaining the directory is not a usable TSDB/WAL directory.","triggerScenarios":"os.Stat(filepath.Join(dir, \"wal\")) returns an error — the 'wal' subdirectory does not exist under the given dir, or the process lacks permission to stat it. Called from runSidecar when validating --tsdb.path and from an anonymous caller (e.g. tools/bucket verification of a local dir).","commonSituations":"Thanos sidecar started with --tsdb.path pointing at a directory that is not the Prometheus data dir (empty volume, wrong mount), Prometheus not yet started so wal/ is absent, or the container lacks read access to the mounted path.","solutions":["Point --tsdb.path at the real Prometheus --storage.tsdb.path","Verify the wal/ subdirectory exists: ls <dir>/wal","Fix filesystem permissions so the sidecar user can read the TSDB dir","Ensure Prometheus is running and has initialized its data directory before the sidecar","Check volume mounts in containers/Kubernetes (correct PVC attached)"],"exampleFix":"// before\nthanos sidecar --tsdb.path=/data\n// after: verify dir first\nls /data/wal || echo \"not a TSDB dir\"\nthanos sidecar --tsdb.path=/prometheus   # where Prometheus stores data (contains wal/)","handlingStrategy":"validation","validationCode":"func walDirLooksValid(dir string) error {\n    info, err := os.Stat(filepath.Join(dir, \"wal\"))\n    if err != nil {\n        return fmt.Errorf(\"%s/wal not statable: %w\", dir, err)\n    }\n    if !info.IsDir() {\n        return fmt.Errorf(\"%s/wal is not a directory\", dir)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := promclient.IsWALDirAccessible(tsdbPath); err != nil {\n    log.Fatalf(\"invalid --tsdb.path: %v\", err)\n}","preventionTips":["Always pass the same value Prometheus uses for --storage.tsdb.path","Check volume mounts are correct before starting the sidecar","Ensure Prometheus initializes the data dir before dependent processes","Verify read permissions for the sidecar's user"],"tags":["filesystem","tsdb","sidecar","directory"],"backgroundTag":"directory-not-found","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}