A partial build output at the target destroys or strands the good .prev DB
bug
Found reviewing #633 (round 7). Data loss, verified both branches.
`_clear_build_target`'s orphan recovery only fires when the target is absent or a
symlink. A killed `semsql make` leaves a **partial real file** at the target,
which takes neither path:
```
partial >= min_size -> DbEnsureResult(usable=True, built=False) | builds=0 | good .prev survived: True
partial < min_size -> DbEnsureResult(usable=False, built=False) | builds=1 | good .prev survived: False
```
- **partial ≥ min_size**: the partial is silently accepted as the DB (no build
runs at all) while the good DB stays stranded at `.prev`.
- **partial < min_size**: `os.remove(kept)` deletes the good `.prev` before
`os.replace(db_path, kept)` moves the partial into its place. The build then
fails and the code prints *"Restored the previous ncbitaxon.db after the failed
build"* — having restored the partial. The good 13 GB DB is gone, with a
message claiming the opposite.
`_clear_build_target` should never overwrite a usable `.prev` with an unusable
target, and should treat "partial file at the target + usable .prev" as the
recovery case it already handles for "absent target + .prev".
Related: the `except BaseException` comment claims SIGTERM protection. Python
installs no SIGTERM handler, so the process dies without unwinding and the
`finally`/`except` never runs — this is the ordinary interrupted-build path, not
an exotic one, and the comment should not imply otherwise.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
0 条评论