Repository navigation
Fix double error reporting in eager watch mode. - #16900
Conversation
782abce to
964bb87
Compare
Signed-off-by: mefyl <[email protected]>
964bb87 to
ed76485
Compare
rgrinberg
left a comment
There was a problem hiding this comment.
What's the difference between this PR and the one that Ali made?
|
Ali pointed me to this issue and I did not notice he already attempted a fix, sorry; regarding your "I think we need a fix that doesn't raise the errors twice in the first place" feedback, my understanding is that we have two different goals running in parallel, and that they will both fail on the same error, so they need to somehow individually see this error to determine that they failed and why, hence the fact we raise it twice ? If not, I'm not sure how one of the two goals will come to a halt, but I might be missing something. |
|
Here it is for reference: #16491 |
|
I think there's two concerns:
Does your PR add deduplication to 2? That is what I object to. |
|
Do you think you could simplify the api before fixing the bug first? There's a bunch of stuff that we support that we have no need for. Setting multiple error handler to take one example. This also costing a fiber variable, which slows down everything else for nothing. There's other functions that can perhaps be fused to reduce the api surface. |
|
This patch definitely does deduplication after-the-fact, which IIUC is what you object to. However my understanding is that it was already relying on deduplication before (via the exception set), and we accidentally broke that by having two sets instead of one, thus deduplication doesn't happen between them. Maybe it's possible to change the design so that we report everything only once instead of deduplicating, but I need to dig into memo, which I never truly did so far. I'm keen with simplifying the API too (I'll do this in the background however, as this was intended as a quick win side quest). |
rgrinberg
left a comment
There was a problem hiding this comment.
Alright let's go with this hack for now.
In the future, let's spend some effort on reducing the entropy around this part of the codebase. It is quite hard to understand.
|
Indeed, I myself only scratched the surface so far and indeed it's a bit convoluted. |
Description
Enrich
MemoAPI to split the installation of an error handler and the run/collection of errors, so that running multiple goals in parallel can still share an error handler and eventually deduplicate them between goals.Related Issue and Motivation
Fixes #15609.
The root cause is pretty clear: we split the run of goals for several good reasons, but in the process we lost deduplication of errors between goals.
I tried several approaches to make the diff as minimal as possible; the most obvious & sensible one to me was to accumulate the errors in the handler itself. The whole point of it is to centralize the errors of every sub-computation, so deduplicating there seemed like a no brainer, but it ended up being a headache:
Scenario to trigger a phantom error in the error handler that is absent from the final report
``` - Run 1: A depends on B. B returns 0 and A returns 1, no errors. - B is invalidated. Both functions have internal state, so on the next computation A no longer needs B, while B now depends on A. - Run 2, building A: a. Memo tries to restore A from the cache. To do that, it first checks A's recorded dependency, B. B is out of date, so Memo recomputes it. b. B's new computation calls A, which is still being restored. That's a cycle, and B fails with Cycle_error. c. Because of the failure, B's error goes through report_and_collect_errors in compute, so the handler receives it. d. Since its dependency changed, A is recomputed. It doesn't call B anymore and returns Ok 0. ```I don't mind digging into this approach, which I think is fundamentally better, but it's going to take some decision making and some adjacent bug fixing. This fix is a bit more grunty, but it does the deed in a reasonable, if not elegant way, I think.
Checklist