Why are locks needed for graph loading?

Hello :slight_smile:

I have a question regarding graph loading.

I had the following workflow in mind:

  1. create the graph from an osm file (using GraphHopper#importAndClose)
  2. load multiple hopper instances in different threads (using GraphHopper#load)

Since in 2. I do not any modifications on the graph (I guess?), I expected this to work fine. However, sometimes I get the To avoid reading partial data we need to obtain the read lock Exception. Can you explain why those locks are needed?

@karussell already stated that

If you want to run multiple GH in one JVM (or from different JVMs) you need to ensure that either the import is done fully from one instance alone OR you use different graphHopperLocation’s

I’ll probably use one of the two approaches but I need to document (and want to understand) why it’s not possible to just simultaneously read the graphs.

I would be grateful for your help

Regards
Lukas

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.