compact: build the successor in a private directory and publish it atomically
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, node.js
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- JavaScript
- Star
- 0
- Fork
- 0
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của indexzero/hyperdown
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
okf: align with upstream OKF v0.2 — vault→bundle vocabulary migration + conformance audit (ADR-009)Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Tất cả issue của indexzero/hyperdown
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
wazuh/wazuh-documentation#10584 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 94/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
InukaAsith/TwinDesk#84 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Graphify-Labs/graphify#4860 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
CommandCodeAI/command-code#1088 ·
Maintainer thường phản hồi trong vòng 2 ngày