{"record":{"id":"466f1c81e863380c","repo":"weaviate/weaviate","slug":"cleanup","errorCode":null,"errorMessage":"cleanup","messagePattern":"cleanup","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/vector/hnsw/compact/compactor.go","lineNumber":158,"sourceCode":"// shouldAbort is polled at safe points (between files, between merged\n// nodes); when it returns true, RunCycle aborts and returns\n// ErrCompactionAborted. The polls are coarse-grained: a single in-flight\n// file conversion or merge step finishes before the abort takes effect,\n// which is by design — abandoning a SafeFileWriter mid-Commit could leave\n// behind partial output. The atomic-rename pattern (Commit / defer Abort)\n// guarantees no source file is deleted unless its replacement was fully\n// written, so an abort produces no on-disk regressions: the next cycle\n// will pick up where this one left off.\n//\n// shouldAbort may be nil, in which case the cycle runs to completion.\nfunc (c *Compactor) RunCycle(shouldAbort func() bool) (Action, error) {\n\tif isAborted(shouldAbort) {\n\t\treturn ActionNone, ErrCompactionAborted\n\t}\n\n\t// Step 1: Cleanup orphaned temp files and detect overlaps\n\tif err := c.cleanup(); err != nil {\n\t\treturn ActionNone, errors.Wrap(err, \"cleanup\")\n\t}\n\n\t// Step 2: Discover files\n\tdiscovery := NewFileDiscoveryWithFS(c.config.Dir, c.fs)\n\tstate, err := discovery.Scan()\n\tif err != nil {\n\t\treturn ActionNone, errors.Wrap(err, \"file discovery\")\n\t}\n\n\t// Step 3: Resolve overlaps (delete contained files)\n\tif err := c.resolveOverlaps(state); err != nil {\n\t\treturn ActionNone, errors.Wrap(err, \"resolve overlaps\")\n\t}\n\n\t// Step 4: Convert raw/condensed files to sorted\n\tif err := c.convertToSorted(state, shouldAbort); err != nil {\n\t\treturn ActionNone, errors.Wrap(err, \"convert to sorted\")\n\t}","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/vector/hnsw/compact/compactor.go#L140-L176","documentation":"Step 1 of a compaction RunCycle failed: removing orphaned temp files and detecting commit-log overlaps errored. This runs before any file discovery or merging, so the cycle aborts with no on-disk changes; a failed cleanup usually means an fs error on the commit log directory (permissions, I/O) rather than data corruption.","triggerScenarios":"Thrown at adapters/repos/db/vector/hnsw/compact/compactor.go:158 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check permissions and health of the commit log directory and retry — the next cycle re-runs cleanup idempotently","Remove stale *.tmp files manually if the process lacks rights to do so","Look for concurrent processes (backup, antivirus) holding or creating files in the directory"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}