Fix deep-chain recheck panic in the MAX_EPOCHS fallback#4188
Open
kinto0 wants to merge 2 commits into
Open
Conversation
…oad the correct commit data. Differential Revision: D112566493
Summary: An export change propagating through a dependency chain deeper than the 100-epoch cap panicked at commit with `Transaction has uncommitted changes` (facebook#4171). The fine-grained recheck path advances one dependency edge per epoch, so a long chain exhausts the cap before the change reaches the top importer. The coarse fallback was meant to invalidate the whole affected closure and recompute it, but it seeded `invalidate_rdeps` from `changed` — which the final loop iteration had already drained — making it a no-op. A single `run_step` then left `changed`/`dirty` populated, tripping the `commit_transaction` invariant. Seed the coarse invalidation from the pending `dirty` frontier instead, then recompute to a fixpoint via `stabilize_after_invalidate`. This converges quickly because lookups pull their dependencies: once the closure is invalidated, a couple of `run_step`s recompute it with correct values and drain the bookkeeping the commit invariant requires. A bounded loop with a final residual-clear keeps a pathological oscillation from hanging or committing inconsistent state. Differential Revision: D112591162
Contributor
|
@kinto0 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D112591162. |
kinto0
commented
Jul 17, 2026
Comment on lines
+2162
to
+2171
| // Even coarse invalidation did not stabilize (a pathological oscillation). Clear the | ||
| // residual `changed`/`dirty` so the transaction commits in a consistent state | ||
| // (last-computed values) rather than tripping a `commit_transaction` assertion. | ||
| tracing::warn!( | ||
| "Exceeded maximum epochs ({MAX_EPOCHS}) without stabilizing. \ | ||
| This may indicate an unexpected dependency pattern. Forcing invalidation." | ||
| "Recheck did not stabilize within {} epochs; clearing residual state to commit consistently.", | ||
| 2 * MAX_EPOCHS | ||
| ); | ||
| let changed = mem::take(&mut *self.data.changed.lock()); | ||
| self.invalidate_rdeps(changed.into_map(|(m, _)| m)); | ||
| self.run_step(handles, require, custom_thread_pool) | ||
| self.data.changed.lock().clear(); | ||
| self.data.dirty.lock().clear(); | ||
| Ok(()) |
Contributor
Author
There was a problem hiding this comment.
this will hide bugs - we can't have this fallback
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
An export change propagating through a dependency chain deeper than the
100-epoch cap panicked at commit with
Transaction has uncommitted changes(#4171). The fine-grained recheck
path advances one dependency edge per epoch, so a long chain exhausts the cap
before the change reaches the top importer.
The coarse fallback was meant to invalidate the whole affected closure and
recompute it, but it seeded
invalidate_rdepsfromchanged— which the finalloop iteration had already drained — making it a no-op. A single
run_stepthen left
changed/dirtypopulated, tripping thecommit_transactioninvariant.
Seed the coarse invalidation from the pending
dirtyfrontier instead, thenrecompute to a fixpoint via
stabilize_after_invalidate. This convergesquickly because lookups pull their dependencies: once the closure is
invalidated, a couple of
run_steps recompute it with correct values anddrain the bookkeeping the commit invariant requires. A bounded loop with a
final residual-clear keeps a pathological oscillation from hanging or
committing inconsistent state.
Differential Revision: D112591162