world.getLivingEntities() inside globalRegionScheduler.runAtFixedRate broken in dev/1.20.4 ?
Commandcracker opened this issue · comments
Expected behavior
No errors :D
Observed/Actual behavior
[21:43:41 ERROR]: Thread Region Scheduler Thread #0 failed main thread check: Accessing entity state off owning region's thread
java.lang.Throwable: null
at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:78) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at org.bukkit.craftbukkit.v1_20_R3.entity.CraftBee.getHandle(CraftBee.java:25) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at org.bukkit.craftbukkit.v1_20_R3.entity.CraftBee.getHandle(CraftBee.java:10) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity.isInWorld(CraftEntity.java:939) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity.isValid(CraftEntity.java:393) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor.lambda$getLivingEntities$2(CraftRegionAccessor.java:321) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
at org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor.getLivingEntities(CraftRegionAccessor.java:317) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at com.palmergames.bukkit.towny.tasks.MobRemovalTimerTask.run(MobRemovalTimerTask.java:96) ~[towny-0.100.1.5.jar:?]
at com.palmergames.bukkit.towny.scheduling.impl.FoliaTaskScheduler.lambda$runRepeating$6(FoliaTaskScheduler.java:87) ~[towny-0.100.1.5.jar:?]
at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler$GlobalScheduledTask.run(FoliaGlobalRegionScheduler.java:179) ~[folia-1.20.4.jar:?]
at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler.tick(FoliaGlobalRegionScheduler.java:37) ~[folia-1.20.4.jar:?]
at io.papermc.paper.threadedregions.RegionizedServer.globalTick(RegionizedServer.java:293) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at io.papermc.paper.threadedregions.RegionizedServer$GlobalTickTickHandle.tickRegion(RegionizedServer.java:148) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:404) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at java.lang.Thread.run(Thread.java:840) ~[?:?]
[21:43:41 WARN]: [Towny] Global task for Towny v0.100.1.5 generated an exception
java.lang.IllegalStateException: Accessing entity state off owning region's thread
at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:79) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at org.bukkit.craftbukkit.v1_20_R3.entity.CraftBee.getHandle(CraftBee.java:25) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at org.bukkit.craftbukkit.v1_20_R3.entity.CraftBee.getHandle(CraftBee.java:10) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity.isInWorld(CraftEntity.java:939) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity.isValid(CraftEntity.java:393) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor.lambda$getLivingEntities$2(CraftRegionAccessor.java:321) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
at org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor.getLivingEntities(CraftRegionAccessor.java:317) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at com.palmergames.bukkit.towny.tasks.MobRemovalTimerTask.run(MobRemovalTimerTask.java:96) ~[towny-0.100.1.5.jar:?]
at com.palmergames.bukkit.towny.scheduling.impl.FoliaTaskScheduler.lambda$runRepeating$6(FoliaTaskScheduler.java:87) ~[towny-0.100.1.5.jar:?]
at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler$GlobalScheduledTask.run(FoliaGlobalRegionScheduler.java:179) ~[folia-1.20.4.jar:?]
at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler.tick(FoliaGlobalRegionScheduler.java:37) ~[folia-1.20.4.jar:?]
at io.papermc.paper.threadedregions.RegionizedServer.globalTick(RegionizedServer.java:293) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at io.papermc.paper.threadedregions.RegionizedServer$GlobalTickTickHandle.tickRegion(RegionizedServer.java:148) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:404) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
at java.lang.Thread.run(Thread.java:840) ~[?:?]
Steps/models to reproduce
Use world.getLivingEntities()
inside globalRegionScheduler.runAtFixedRate
on dev/1.20.4
TownyAdvanced/Towny#7202
MobRemovalTimerTask.java:96
FoliaTaskScheduler.java:87
Plugin and Datapack List
Towny 0.100.1.5
Folia version
This server is running Folia version git-Folia-"7bc26ec" (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 7bc26ec on dev/1.20.4)
Other
It works on 1.20.2.
I'm running into this bug as well,It can be seen that this plugin has a bug on Folia 1.20.4
Global region cannot access any region state, which includes entities.
@Spottedleaf Towny has adapted already to the change so it's not a pressing matter any more. I am curious as to why it was working before the 1.20.4 versions. Did your team close a loophole?
Spottedleaf Towny has adapted already to the change so it's not a pressing matter any more. I am curious as to why it was working before the 1.20.4 versions. Did your team close a loophole?
more checks are added to protect the server from entering an unknown state, for which it needs to crash to escape safely without any data corruption
The more there are such checks, the less crashes caused by random plugin actions will happen
Edit: Or, in this case, spigot added new api which will require new checks