compact: build the successor in a private directory and publish it atomically
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, node.js
Direzione di ricerca
Start with okf/faces/lib/compact.js and read guardCompactPaths(), claimDir(), and the staging and cleanup flow. The issue also identifies Bundle.init and the sign callback as key points to trace. Add the three listed race tests, then verify that compaction refuses a changed destination and cleanup preserves replacement directories and files.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
compact() in okf/faces/lib/compact.js (branch feat/okf-autobee-v2) checks its paths once, then writes into them in place. Another process that writes into the out-dir or the staging path while a compaction runs can lose its files. The review of the compaction hardening (T13 to T18) found two such races. The owner accepted both for the first release, as a fast follow after the branch lands.
The two races
- The out-dir check expires before the store opens.
guardCompactPaths()refuses a non-empty out-dir before the face step. Compaction then materializes, stages and awaits thesigncallback. If another process creates the out-dir and writes a file into it during that window,claimDir()accepts the directory, andBundle.init(Corestore) clears it. The foreign file is gone, and compaction reports success. - Cleanup equates a path name with ownership. On a failure, compaction removes the stage when
ownStageis true, andclaimDir().release()removes the out-dir or the entries that it did not see at claim time. If another process replaced the stage directory, or added a file to the out-dir after the claim, cleanup deletes that directory or file.
Both races need a concurrent writer on the same paths. A single user on one machine who runs one compaction at a time does not meet them.
The full fix
- Build the successor in a private directory that compaction creates exclusively, for example
mkdtemp(<out-dir>.compact-build-), beside the out-dir. - Stage, ingest and verify there. Close the successor vault.
- Publish with an atomic rename onto the out-dir. On POSIX,
rename(2)of a directory fails withENOTEMPTYorEEXISTwhen the destination is not empty, so a changed destination is refused, never cleared. - Reopen the published vault at the out-dir and return it.
compact()then returns a vault that it reopened, not the one that it built. That is an API change for callers that hold the build path. - Cleanup removes only the private build directory and the stage that this run created. Record the device and inode of each created directory, and refuse to remove a path whose identity changed.
Tests to add
- A
signcallback that creates the out-dir and writes a file into it: compaction refuses, and the file stays. - A stage replaced between staging and a failure: the replacement stays.
- A file added to the out-dir after the claim, then an init failure: the file stays.
- Lingua principale
- JavaScript
- Stelle
- 0
- Fork
- 0
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di indexzero/hyperdown
-
okf: rename face to bundleAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
okf: align with upstream OKF v0.2 — vault→bundle vocabulary migration + conformance audit (ADR-009)Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
Tutte le issue di indexzero/hyperdown
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
bigcalendar/react-big-calendar#2823 ·
-
feature t-tooling
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
neutral:fix
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
documentation enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
OWASP/cve-lite-cli#1480 ·
I maintainer di solito rispondono entro 2 giorni