8000 Protect against `document == null` in `_doc_detached()` by mattpap · Pull Request #14430 · bokeh/bokeh · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@mattpap
Copy link
Contributor
@mattpap mattpap commented Mar 20, 2025

For now this work around the problem, but I will need to investigate why we detach a detached model in the first place.

fixes #14429

@mattpap mattpap added this to the 3.8 milestone Mar 20, 2025
@mattpap mattpap moved this to In Progress in HoloViz planning Mar 20, 2025
@philippjfr
Copy link
Contributor

Seems high priority, can we backport to 3.7.1 and release relatively soon?

@bryevdv
Copy link
Member
bryevdv commented Mar 20, 2025

We can definitely have a 3.7.1 ASAP. If theres any handful of other tiny fix that can go in ~immediately, then that would be nice, but if not there's no reason to hold this up. Let's shoot for Monday at the latest? If any sort of test is possible that would be nice to have in place before a more in-depth follow-up.

@mattpap mattpap mentioned this pull request Mar 21, 2025
10 tasks
@mattpap
Copy link
Contributor Author
mattpap commented Mar 24, 2025

The underlying problem was that updating a figure means setv() in Toolbar._init_tools(), which triggers recomputation of all models. This happens during application of a patch, which interferes badly with the new partial eventual consistency of Document.all_models. Thus I finished the transition to full eventual consistency, which completes work started in 3.7. This way, adding new models will result in them being added to all_models and attach_document() called for all of them. However, removing models results in a deferred cleanup and calls to detach_document(). I need to update units tests, because there are a few that assume strong consistency when removing models.

@mattpap mattpap requested review from bryevdv and philippjfr March 24, 2025 21:28
@mattpap mattpap force-pushed the mattpap/14429_doc_detached branch from 94991d9 to 2f91161 Compare March 25, 2025 07:47
Copy link
Contributor
@hoxbro hoxbro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments. I'm unfamiliar with this code, so they may be a bit naive.

@bryevdv
Copy link
Member
bryevdv commented Mar 25, 2025

@mattpap what about putting the quick defensive "fix" in 3.7.1 and saving these more involved changes for 3.8?

Copy link
Member
@bryevdv bryevdv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll approve but I do think some quick manual testing of most/all the app examples is in order if that hasn't already been done. Also would good to know if this is the fix for https://discourse.bokeh.org/t/dynamically-create-tabs-with-figures-in-them/12368/2

@mattpap
Copy link
Contributor Author
mattpap commented Mar 25, 2025

what about putting the quick defensive "fix" in 3.7.1 and saving these more involved changes for 3.8?

That was my original goal. However, after spending time debugging the root cause, I can clearly see it's a mess what happens when a patch arrives that causes setv() during handling of the patch (e.g. document trying to detach freshly arrived models). Thus I think things could fail anyway in some other way, even with the workaround. This change effectively completes what was started in 3.7. I think the biggest mistake was to include those changes in 3.7 in the first place (incomplete and not well tested).

@mattpap
Copy link
Contributor Author
mattpap commented Mar 25, 2025

https://discourse.bokeh.org/t/dynamically-create-tabs-with-figures-in-them/12368/2

I didn't verify this, but it clearly looks like it's the same problem.

@mattpap mattpap merged commit 4035dcc into branch-3.8 Mar 25, 2025
24 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in HoloViz planning Mar 25, 2025
@mattpap mattpap deleted the mattpap/14429_doc_detached branch March 25, 2025 20:51
mattpap added a commit that referenced this pull request Mar 25, 2025
* Protect against `document == null` in `_doc_detached()`

* Make Document.all_models eventually consistent

* Allow to configure model re-computation behavior

* Update Document's unit tests
@github-actions
Copy link
github-actions bot commented Jul 9, 2025

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Replacing Plot in a layout fails due to detached Document

5 participants

0