Make soft_error! return Ok in OSS builds and remove .unwrap() at call#1276
Make soft_error! return Ok in OSS builds and remove .unwrap() at call#1276dkranchii wants to merge 2 commits into
Conversation
|
@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D98698555. (Because this pull request was imported automatically, there will not be any future comments.) |
|
Thanks for the PR. There's another report of this issue earlier, but I haven't had time to look into it. Regarding the actual soft_error function, it's currently used in buck2 in two ways. I think ideally we should just parametrize soft_error function so that we have both types of behavior, and then use the kind that doesn’t cause hard errors for the logging purposes externally as well. Let me know if that sounds good to you. |
|
@scottcao Thanks, that makes sense. |
|
@scottcao Thanks for the feedback! I've updated the PR to parameterize the behavior based on the existing How it works now:
|
|
@copilot resolve the merge conflicts in this pull request |
Only treat deprecation soft errors as hard errors in OSS builds. Non-deprecation soft errors (used for logging) now return Ok in OSS, matching FB internal behavior and preventing panics at .unwrap() sites. Made-with: Cursor
4387ea5 to
0a5ca11
Compare
|
@scottcao can you review this pr. thanks!! |
|
We hit this on the OSS side and would benefit from this PR shipping. Our default build path is Remote Execution against a Buildbarn cluster. Local Buck2 on macOS and on our Linux CI runners is a deliberately preserved fallback for when the RE pool, network, or certs are unavailable. The materializer panics in #1274 are what make that fallback fragile. We have not reproduced them under RE. Today the fallback runs without SQLite materializer state at all because of this issue: we set |
Summary
soft_error!was designed to log non-critical errors and allow execution to continue. However, in open source builds,handle_soft_errorunconditionally returnedErr(err)instead ofOk(err), turning every soft error into a hard error. Combined with.unwrap()calls at multiple call sites, this caused panics/crashes for OSS users on non-critical failures like sqlite write errors or vacant path lookups.Changes
app/buck2_env/src/soft_error.rsis_open_sourcebranch that forced all soft errors to returnErrin OSS builds.soft_error!now returnsOk(err)uniformly, matching FB internal behavior. TheBUCK2_HARD_ERRORenv var still works for users who want to opt into hard errors.app/buck2_execute_impl/src/materializers/deferred/artifact_tree.rs.unwrap()withlet _unused =oncleanup_finished_vacantsoft error.app/buck2_execute_impl/src/materializers/deferred/command_processor.rs.unwrap()withlet _unused =on 4 soft error call sites:clean_stale_no_config,materializer_materialize_error,has_artifact_update_time, and dynamicerror_nameinon_materialization.app/buck2_execute_impl/src/sqlite/incremental_state_db.rs.unwrap()withlet _unused =oninsert_to_incremental_dbanddelete_from_incremental_dbsoft errors.Impact
BUCK2_HARD_ERRORenv var continues to work as an opt-in escape hatch.Ok(err)).Fixes
ArtifactTree::cleanup_finishedpanics in open source builds #1274