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

Make FailingSnapshotManager Thread Safe #70

Merged
merged 7 commits into from
Mar 30, 2024

Conversation

gabber235
Copy link
Contributor

Problem Description

When running multiple path searches at the same time from different threads, the FailingSnapshotManager throws the following error:

java.util.ConcurrentModificationException: null
	at java.util.HashMap.computeIfAbsent(HashMap.java:1221) ~[?:?]
	at org.patheloper.model.snapshot.FailingSnapshotManager.processChunkSnapshot(FailingSnapshotManager.java:108) ~[Typewriter.jar:?]
	at org.patheloper.model.snapshot.FailingSnapshotManager.getChunkSnapshot(FailingSnapshotManager.java:96) ~[Typewriter.jar:?]
	at org.patheloper.model.snapshot.FailingSnapshotManager.fetchBlock(FailingSnapshotManager.java:59) ~[Typewriter.jar:?]
	at org.patheloper.model.snapshot.FailingSnapshotManager.getBlock(FailingSnapshotManager.java:116) ~[Typewriter.jar:?]
	at org.patheloper.model.snapshot.FailingSnapshotManager$RequestingSnapshotManager.getBlock(FailingSnapshotManager.java:168) ~[Typewriter.jar:?]
	at org.patheloper.model.pathing.pathfinder.AbstractPathfinder.isBlockUnreachable(AbstractPathfinder.java:112) ~[Typewriter.jar:?]
	at org.patheloper.model.pathing.pathfinder.AbstractPathfinder.initialChecksFailed(AbstractPathfinder.java:104) ~[Typewriter.jar:?]
	at org.patheloper.model.pathing.pathfinder.AbstractPathfinder.findPath(AbstractPathfinder.java:71) ~[Typewriter.jar:?]
	at org.patheloper.model.pathing.pathfinder.AStarPathfinder.findPath(AStarPathfinder.java:34) ~[Typewriter.jar:?]

Proposed solution is to change the data structure of the SNAPSHOTS_MAP from a unsafe Map to a thread safe ConcurrentMap.

This pull request does just that.

Copy link
Member

@olijeffers0n olijeffers0n left a comment

Choose a reason for hiding this comment

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

Hi, thanks for this! Could you target our trunk branch with this PR please

@gabber235 gabber235 changed the base branch from production to trunk March 29, 2024 21:02
Copy link
Member

@olijeffers0n olijeffers0n left a comment

Choose a reason for hiding this comment

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

LGTM - @GodCipher can final approval and merge

Copy link
Member

@GodCipher GodCipher left a comment

Choose a reason for hiding this comment

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

Hi, thanks for the fix tho! Once the import is removed we will merge this into pathetic :)

@GodCipher GodCipher merged commit 0aefbc9 into patheloper:trunk Mar 30, 2024
2 checks passed
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.

None yet

3 participants