Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Status.PRESENT after synchronous preload #950

Merged
merged 6 commits into from
Dec 5, 2024
Merged

Set Status.PRESENT after synchronous preload #950

merged 6 commits into from
Dec 5, 2024

Conversation

ansoncfit
Copy link
Member

@ansoncfit ansoncfit commented Oct 26, 2024

This PR fixes #949, a longstanding issue (possibly since #746).

We have two pathways for loading transport network data on a worker: preloadData (asynchronously, for single-point tasks) and synchronousPreload (for regional tasks). Once data are loaded in an AsyncLoader, they should be marked with Status.PRESENT. The async pathway was doing this correctly. But once a worker switched to a regional task, it would switch the status to LOADING and never switch it back to PRESENT.

This PR factors out a setComplete method and calls it in both pathways.

@abyrd
Copy link
Member

abyrd commented Oct 28, 2024

Thanks @ansoncfit for identifying this problem and tracking down the cause! The proposed fix already looks good, but I have a sense we could reduce code duplication slightly, and reduce the risk of similar future problems by moving the synchronousPreload logic up into the AsyncLoader abstract class as a public getSynchronous() method, which is then also called by the runnable inside get(). This would have all code paths calling the exact same instance of the crucial buildValue / setComplete sequence, so it can't be done wrong in any future extensions of AsyncLoader. I'll give it some thought tomorrow and propose a patch.

abyrd added 3 commits October 31, 2024 22:00
The nonblocking version of get just runs getBlocking in a thread.
NetworkPreloader has corresponding preload and preloadBlocking methods.
Method comments said it was called in the buildValue implementation
methods but it was actually only ever called in AsyncLoader error
handling code.
@abyrd
Copy link
Member

abyrd commented Oct 31, 2024

What do you think of the approach shown in the three commits I just pushed to this branch? The NetworkPreloader has blocking and nonblocking preload methods, which call blocking and nonblocking methods on the base class. Then the nonblocking method on the base class just runs the blocking method in a background thread. So everything leads down to a single blocking get method that always includes the logic to mark the element present.

This should provide identical behavior to your version before my changes, I just find the version where everything converges on a single method to be a little less susceptible to similar problems in the future.

The question arises whether the try/catch error handling code should be inside getBlocking, which would make it apply to both preload and preloadSynchronous. Errors in either case would then set the status to ERROR. This would be more consistent but would interfere with the way we currently shuttle regional task exception messages back to the backend. So I just added some comments clarifying how it works currently.

Just to keep behavior more similar to previous versions.
This could be changed in the future if we do a more significant refactor
of how exceptions are handled and passed up to the backend.
@abyrd
Copy link
Member

abyrd commented Oct 31, 2024

Well, actually there was one small difference in behavior: the status was being set to "Starting..." just before a synchronous load begins. I moved it back just to keep behavior mostly identical to previous versions. This could be changed in the future if we do a more significant refactor of how exceptions are handled and passed up to the backend.

@ansoncfit ansoncfit enabled auto-merge (squash) November 1, 2024 12:44
Copy link
Member Author

@ansoncfit ansoncfit left a comment

Choose a reason for hiding this comment

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

Thanks for the revisions. I agree with having both paths converge on a single method.

I will make sure we test workers switching between scenarios and single-point/regional tasks on staging before our next release.

Let's go ahead and merge this PR (I would mark it as approved, but GH doesn't give me the option as the original author).

trevorgerhardt
trevorgerhardt previously approved these changes Nov 2, 2024
Copy link
Member

@trevorgerhardt trevorgerhardt left a comment

Choose a reason for hiding this comment

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

Looks good to me, can be merged once the conflict is resolved 👍

@ansoncfit ansoncfit disabled auto-merge December 5, 2024 03:16
@ansoncfit ansoncfit merged commit 5648f0b into dev Dec 5, 2024
3 checks passed
@ansoncfit ansoncfit deleted the fix-preload branch December 5, 2024 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stalled single-point analysis after worker handles regional tasks
3 participants