Repository navigation
Description
Certification leaves the shared post-export scorer open when one of its stages fails. _certify_us_build in tools/build_us_fiscal_refresh_release.py opens the scorer before the reform-coverage smoke (line 19915). It closes it through _close_post_export_scorer after the Medicare IRMAA holdout (line 20077). No try in _certify_us_build covers the stages between, and the caller's handler doesn't close the scorer, so an exception that escapes any of them skips close().
Since #1772, a refused batch file in the merged baseline pass takes that path too. Before it, that pass fell back to each stage's own pass, so a file that failed one read there got a second read, and certification could still finish and close the scorer. A refused batch file in any other pass already took that path.
Effect today
tools/certify_us_national_build.pyruns certification, and no other command does. On a failure,_certify_main_with_close_outcallstelemetry.fail(line 15384) and raises the error again, and the process exits.- At exit, the scorer's
weakref.finalize(line 5979) removes its batch directory, since a finalizer runs at exit by default. A first SIGTERM goes throughraise_on_sigtermand exits 143, with the same cleanup. - A SIGKILL or an out-of-memory kill during scoring leaves the
post-export-batches-*directory behind, and a fix on the failure path can't change that. Certifying the same--outagain removes it in_place_build_for_certification(lines 15210 to 15216). docs/us-release-build-rule.mdputs the batch files at about as much disk as the exported H5. Today they hold that disk from the failure until the process exits, and a kill in that window, such as a second SIGTERM, leaves them behind.- The fix removes them at the failure, so a kill after it leaves nothing. The scorer's constructor already cleans up this way when writing the batch files fails (lines 5986 to 5988).
Fix
- On the failure path, close the scorer in an
except BaseException:block, suppress anExceptionfromclose()itself, and raise the original error again. close()removes the batch files last, after_finish_open_reform(), so the block also calls the scorer's_remove_batch_files()after it. After aclose()that succeeded, that call does nothing.- A
try/finallywould raise an error fromclose()in place of the original, which would survive only as its__context__.telemetry.failwould then record the close error, and a SIGTERM whose cleanup failed would exit 1 where it now exits 143. - A test makes a stage fail with an error that propagates, and checks that the scorer closed while it still holds the exception. The smoke, reform validation and demographics propagate any error. The holdouts record an ordinary scoring error as unavailable and propagate a refused batch file.
- The certification tests' stub scorer records
close(), and a test with a real scorer can check that its batch directory has gone. - Report held-out SNAP caseload composition and take-up at certification (#647) #1714 adds a stage inside this span on its own branch, and another open PR changes the scorer's open call. I'll make the fix once both changes reach main, so that it rebases once.
Activity