{"record":{"id":"1a49df31842a0a53","repo":"thedotmack/claude-mem","slug":"backfill-marker-read-failed-treating-backfill-as","errorCode":null,"errorMessage":"Backfill marker read failed; treating backfill as complete to avoid duplicate sends","messagePattern":"Backfill marker read failed; treating backfill as complete to avoid duplicate sends","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/services/telemetry/backfill.ts","lineNumber":168,"sourceCode":" * backfilled installs re-run and pick up the enriched rollup keys — without it,\n * the one-shot marker would pin them forever to whatever shipped when they\n * first backfilled (the read_tokens / tokens_saved_vs_naive series would only\n * ever reach fresh installs).\n *\n * A corrupt marker file still counts as complete: a marker was written at some\n * point, and duplicate sends are worse than a gap (PostHog data cannot be\n * selectively deleted). A marker missing the `version` field is a legacy\n * version-1 marker.\n */\nfunction isBackfillComplete(): boolean {\n  try {\n    const marker = readJsonSafe<Partial<BackfillMarker> | null>(getBackfillMarkerPath(), null);\n    if (marker === null) return false;\n    const version = typeof marker.version === 'number' ? marker.version : 1;\n    return version >= BACKFILL_VERSION;\n  } catch (error) {\n    const err = error instanceof Error ? error : new Error(String(error));\n    logger.warn('SYSTEM', 'Backfill marker read failed; treating backfill as complete to avoid duplicate sends', {}, err);\n    return true;\n  }\n}\n\nfunction writeBackfillMarker(marker: BackfillMarker): void {\n  const dataDir = resolveDataDir();\n  mkdirSync(dataDir, { recursive: true });\n  writeFileSync(getBackfillMarkerPath(), JSON.stringify(marker, null, 2) + '\\n');\n}\n\n/**\n * Per-day anonymous activity rollups, bucketed by UTC day. Only whole UTC\n * days inside `installDay <= day <= lastFullDay` are included, comparing\n * day strings (YYYY-MM-DD compares lexicographically) — never raw epochs, so\n * no partial day can ever ship. Rows below PROJECT_EPOCH_FLOOR are ignored.\n *\n * Each query block is independently best-effort (a missing table/column on an\n * older install skips that block's keys, never throws) — same pattern as","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/services/telemetry/backfill.ts#L150-L186","documentation":"isBackfillComplete() reads the marker file via readJsonSafe, which already maps missing or corrupt-JSON files to null; this catch fires only on hard IO errors (EACCES, EPERM, EIO). Because PostHog events cannot be selectively deleted, the fail-safe default is 'backfill complete' — skip it — since a telemetry gap is preferred over duplicate sends.","triggerScenarios":"The marker file exists but is unreadable: permission changes, the file locked by antivirus or backup software (common on Windows), a failing disk, or exotic filesystem errors.","commonSituations":"Data dir restored with wrong ownership; enterprise AV holding files; data dir on a NAS.","solutions":["Fix read permissions on the marker file inside the claude-mem data dir","If the file was hand-edited, verify it is valid JSON with jq","If the marker is truly lost and duplicate analytics are acceptable, delete it so the deterministic backfill reruns","Otherwise take no action — the historical backfill is simply skipped"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the data dir readable and writable by the service user","Exclude the data dir from antivirus and backup file locks","Never hand-edit the marker; delete it to force a deterministic rerun"],"tags":["telemetry","backfill","marker-file","io-error"],"backgroundTag":"state-file-read-failed","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","contentChangedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}