Allay icon indicating copy to clipboard operation
Allay copied to clipboard

bug: an concurrent error when there are a lot of entities

Open smartcmd opened this issue 1 year ago • 1 comments

java.util.concurrent.CompletionException: java.util.concurrent.CompletionException: java.lang.IllegalStateException: Trying to set a chunk (-276,-94) which is already loaded
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) ~[?:?]
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[?:?]
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[?:?]
	at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:540) ~[?:?]
	at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:567) ~[?:?]
	at java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:670) ~[?:?]
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:160) ~[?:?]
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:174) ~[?:?]
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233) ~[?:?]
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:765) ~[?:?]
	at org.allaymc.server.world.service.AllayEntityPhysicsService.tick(AllayEntityPhysicsService.java:70) ~[classes/:?]
	at org.allaymc.server.world.AllayDimension.tick(AllayDimension.java:59) ~[classes/:?]
	at org.allaymc.server.world.AllayWorld.lambda$tick$2(AllayWorld.java:151) ~[classes/:?]
	at it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap$1.forEach(Int2ObjectOpenHashMap.java:1214) ~[fastutil-8.5.13.jar:?]
	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1116) ~[?:?]
	at org.allaymc.server.world.AllayWorld.tick(AllayWorld.java:151) ~[classes/:?]
	at org.allaymc.server.world.AllayWorld.lambda$new$0(AllayWorld.java:68) ~[classes/:?]
	at org.allaymc.api.utils.GameLoop.startLoop(GameLoop.java:70) ~[classes/:?]
	at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: java.util.concurrent.CompletionException: java.lang.IllegalStateException: Trying to set a chunk (-276,-94) which is already loaded
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:649) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:614) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:653) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
	... 1 more
Caused by: java.lang.IllegalStateException: Trying to set a chunk (-276,-94) which is already loaded
	at org.allaymc.server.world.service.AllayChunkService.setChunk(AllayChunkService.java:113) ~[classes/:?]
	at org.allaymc.server.world.service.AllayChunkService.lambda$loadChunk$6(AllayChunkService.java:182) ~[classes/:?]
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:614) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:653) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
	... 1 more

smartcmd avatar Feb 11 '24 18:02 smartcmd

Fixed in this commit but using synchronized is not very good, we need to think about the best solution

IWareQ avatar Feb 27 '24 08:02 IWareQ