Close all `Build_log` file descriptors just after sandbox finishes
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 67
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
On Windows, one cannot move a directory if it has files opened inside. A similar case occurs with ZFS. Ensure that all Build_log file descriptors are closed before promoting the temporary build directory and the log file it contains as definitive build result.
We can either ensure that all tail'ers have finished reading before closing the log file and moving the directory, or pause the tail'ers and resume reading from the moved log file.
I'm still struggling on it, it's not easy, I think I always end up in some sort of deadlock where the tail'ers and the Db_store layer are waiting on each other reciprocally.
I added a test for a very simple spec file that fails on ZFS (so I presume windows too iiuc) with the expected failure and the spec file -- now I'll look through the code to see why it's not working :))
Originally posted by @patricoferris in https://github.com/ocurrent/obuilder/issues/98#issuecomment-1007474573
A workaround this issue is to let the store select the location of the log file and never move it, which I have implemented for the Windows backend.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with test/specs/build-log.spec and the linked expected-failure run, then trace how Build_log tailers and the Db_store layer interact. Compare the Windows backend workaround with the intended directory promotion flow. Done means all Build_log descriptors are closed before the temporary directory and log are promoted, without deadlock, and the ZFS test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100