Do not ensure write access when there are no CHs/LMs to prepare #2500
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2498.
I probably introduced this bug when I was working on #2481. When we call
GraphHopper#load
and preparations are only loaded so there is nothing else to prepare we need no write access. I therefore put back theensureWriteAccess
calls that we just removed to partially fix the bug in 674828b, but under the condition that there are actually things to prepare.Closing the location index, names and way geometry storage is done unconditionally, because they aren't needed in any case (neither if there are CHs to prepare, nor if there are no CHs to prepare). We can even close the way geometry and names before the LM preparation (unless there are no custom profiles), which saves some memory if the import only includes LM.
@michaz, @oli0044 does this fix the problem you were running into? I still think we should also remove the
setAllowWrites
and lock file stuff, but I'd like to do this as a follow up and possibly at a later time if this PR fixes the actual bug for now. As a minimum requirement we should keep the lock file to prevent running twoimport
commands simultaneously, see #2498 (comment).