-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Concurrency issues in GraphUpdaters #2545
Comments
Here are other observations I made while reviewing the GraphUpdater code:
|
@laurentg could you give some feedback or comments on my observations above about GraphUpdaters? |
Taking another look at this one as we've been working with GraphUpdaters. Setup methods are now run sequentially in a single thread since commit 544e1b1, and Javadoc makes it more clear what runs sequentially (the setup methods) and what runs in parallel (the run methods, after setup is complete). So the original issue is resolved, but I would like to keep this issue open until all the other points identified in the code audit (in #2545 (comment) above) are checked out and resolved. |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days |
On the opentripplanner-users mailing list, Combitrip reports a ConcurrentModificationException when starting up a GBFS bike rental updater:
This led me to do a broad review of the GraphUpdater code and I have found several potential concurrency problems. Before going into detail on those, I will diagnose the particular exception that was reported. Based on the stack trace, we are modifying the map of vertices in the Graph while we are iterating over it.
The iteration over the vertices is happening because the BikeRentalUpdater has its own SimpleStreetSplitter, which creates its own HashGridSpatialIndex of every edge in the graph. The Graph provides a list of all its edges by concatenating the edge lists of all its vertices.
The modification of this vertex collection cannot be pinpointed from the stack trace, but since this is happening during graph updater startup, we might suspect the creation of bike rental vertices or other dynamically inserted vertices.
At first it was hard to imagine how these could be happening at the same time, because I had assumed that nothing multithreaded was going on here. But after a closer look I see that while the setup() and run() methods of each GraphUpdater are run sequentially, if there are multiple GraphUpdaters their setup() methods are being run simultaneously in different threads. Concurrent execution of the setup() methods seems unnecessary - we should probably ensure that all setup code runs single threaded and only when all setup has completed will the fetching/updating code be run concurrently in separate threads.
The text was updated successfully, but these errors were encountered: