Towny Classic

Towny Classic

3.2k Downloads

Folia Accessing entity state off owning region's thread

Commandcracker opened this issue ยท 4 comments

commented

What steps will reproduce the problem?

Install Towny on Folia

What is the expected output?

No exceptions

Towny version

0.100.1.5

Server version

Folia version git-Folia-"4d78338" (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 4d78338 on dev/1.20.4)

Please use Pastebin.com to link the following files

[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) ~[?:?]
commented

This never appeared during the initial testing of the folia branch. At the moment we're a bit puzzled how we're supposed to get a list of LivingEntities in the world. It will be looked into though.

Please include your full server startup.

commented

It looks like a Folia bug, ill make an issue on there.

commented

I tried Towny on git-Folia-20 1.20.2 and everything worked fine, so it looks like something changed in 1.20.4.

That makes sense

commented

This never appeared during the initial testing of the folia branch. At the moment we're a bit puzzled how we're supposed to get a list of LivingEntities in the world. It will be looked into though.

Please include your full server startup.

There is nothing interesting in the log, as I just set up a clean server:

latest.log
[17:19:07] [ServerMain/INFO]: Environment: Environment[sessionHost=https://sessionserver.mojang.com, servicesHost=https://api.minecraftservices.com, name=PROD]
[17:19:07] [ServerMain/INFO]: Found new data pack file/bukkit, loading it automatically
[17:19:08] [ServerMain/INFO]: No existing world data, creating new world
[17:19:08] [ServerMain/INFO]: Loaded 1174 recipes
[17:19:08] [ServerMain/INFO]: Loaded 1271 advancements
[17:19:08] [Server thread/INFO]: Starting minecraft server version 1.20.4
[17:19:08] [Server thread/INFO]: Loading properties
[17:19:08] [Server thread/INFO]: This server is running Folia version git-Folia-"4d78338" (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 4d78338 on dev/1.20.4)
[17:19:09] [Server thread/INFO]: Server Ping Player Sample Count: 12
[17:19:09] [Server thread/INFO]: Using 4 threads for Netty based IO
[17:19:09] [Server thread/INFO]: [ChunkTaskScheduler] Chunk system is using 1 I/O threads, 8 worker threads, and gen parallelism of 8 threads
[17:19:09] [Server thread/WARN]: [!] The timings system cannot be enabled on Folia, and has been scheduled for removal from Paper in the future.
    We recommend installing the spark profiler as a replacement: https://spark.lucko.me/
    For more information please visit: https://github.com/PaperMC/Paper/issues/8948
[17:19:09] [Server thread/INFO]: [io.papermc.paper.threadedregions.TickRegions] Regionised ticking is enabled with 4 tick threads
[17:19:09] [Server thread/INFO]: Default game type: SURVIVAL
[17:19:09] [Server thread/INFO]: Generating keypair
[17:19:09] [Server thread/INFO]: Starting Minecraft server on *:25565
[17:19:09] [Server thread/INFO]: Using default channel type
[17:19:09] [Server thread/INFO]: Paper: Using Java compression from Velocity.
[17:19:09] [Server thread/INFO]: Paper: Using Java cipher from Velocity.
[17:19:09] [Server thread/INFO]: [Towny] Loading server plugin Towny v0.100.1.5
[17:19:09] [Server thread/INFO]: Preparing level "world"
[17:19:10] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
[17:19:10] [Server thread/INFO]: Time elapsed: 10 ms
[17:19:10] [Server thread/INFO]: Preparing start region for dimension minecraft:the_nether
[17:19:10] [Server thread/INFO]: Time elapsed: 1 ms
[17:19:10] [Server thread/INFO]: Preparing start region for dimension minecraft:the_end
[17:19:10] [Server thread/INFO]: Time elapsed: 2 ms
[17:19:10] [Server thread/INFO]: [Towny] Enabling Towny v0.100.1.5
[17:19:10] [Server thread/INFO]: ====================      Towny      ========================
[17:19:11] [Server thread/INFO]: [Towny] Successfully loaded translations for 42 languages.
[17:19:11] [Server thread/INFO]: [Towny] Config: Loaded 9 townblock types: shop, inn, arena, jail, default, bank, wilds, farm, embassy.
[17:19:11] [Server thread/INFO]: [Towny] Database: [Load] flatfile [Save] flatfile
[17:19:11] [Server thread/INFO]: [Towny] Database: Loaded in 18ms.
[17:19:11] [Server thread/INFO]: [Towny] Database: <50% of residents have stored UUIDs.
[17:19:11] [ForkJoinPool.commonPool-worker-1/INFO]: [Towny] Cleaning up old backups...
[17:19:11] [ForkJoinPool.commonPool-worker-1/INFO]: [Towny] Could not delete old backups.
[17:19:11] [ForkJoinPool.commonPool-worker-1/INFO]: [Towny] Making backup...
[17:19:11] [Folia Async Scheduler Thread #0/INFO]: [Towny] Time until a New Day: 18 hours, 40 minutes, 49 seconds
[17:19:11] [Folia Async Scheduler Thread #1/INFO]: [Towny] Checking for updates...
[17:19:11] [Server thread/INFO]: [Towny] Searching for third-party plugins...
[17:19:11] [Server thread/INFO]: [Towny] Plugins found: 
[17:19:11] [Server thread/INFO]: [Towny]   Permissions: TownyPerms, BukkitPermissions
[17:19:11] [Server thread/INFO]: [Towny]   Warning: No compatible Economy plugins found. Install
                           Vault.jar or Reserve.jar with any of the supported eco
                           systems. If you do not want an economy to be used, set
                           using_economy: false in your Towny config.yml.
[17:19:11] [ForkJoinPool.commonPool-worker-1/INFO]: [Towny] Towny flatfiles and settings successfully backed up.
[17:19:12] [Server thread/INFO]: =============================================================
[17:19:12] [Server thread/INFO]: [Towny] Version: 0.100.1.5 - Plugin Enabled
[17:19:12] [Server thread/INFO]: =============================================================
[17:19:12] [Server thread/INFO]: Done (3.197s)! For help, type "help"
[17:19:12] [Region Scheduler Thread #1/INFO]: Initialising world 'world' before it can be ticked...
[17:19:12] [Region Scheduler Thread #2/INFO]: Initialising world 'world_nether' before it can be ticked...
[17:19:12] [Region Scheduler Thread #3/INFO]: Initialising world 'world_the_end' before it can be ticked...
[17:19:12] [Folia Async Scheduler Thread #1/INFO]: [Towny] No new updates found.
[17:19:12] [Region Scheduler Thread #3/INFO]: Initialised world 'world_the_end'
[17:19:12] [Region Scheduler Thread #3/INFO]: Timings Reset
[17:19:13] [Region Scheduler Thread #2/INFO]: Initialised world 'world_nether'
[17:19:14] [Region Scheduler Thread #1/INFO]: Initialised world 'world'
[17:19:17] [Region Scheduler Thread #0/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.CraftStrider.getHandle(CraftStrider.java:77) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
	at org.bukkit.craftbukkit.v1_20_R3.entity.CraftStrider.getHandle(CraftStrider.java:8) ~[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) ~[?:?]
[17:19:17] [Region Scheduler Thread #0/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.CraftStrider.getHandle(CraftStrider.java:77) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
	at org.bukkit.craftbukkit.v1_20_R3.entity.CraftStrider.getHandle(CraftStrider.java:8) ~[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) ~[?:?]
[17:19:20] [Region Scheduler Thread #0/INFO]: Stopping the server
[17:19:20] [Region shutdown thread/INFO]: [RegionShutdownThread] Awaiting scheduler termination for 60s
[17:19:20] [Region shutdown thread/INFO]: [RegionShutdownThread] Scheduler halted
[17:19:20] [Region shutdown thread/INFO]: Stopping server
[17:19:20] [Region shutdown thread/INFO]: [Towny] Disabling Towny v0.100.1.5
[17:19:20] [Region shutdown thread/INFO]: ==============================================================
[17:19:20] [Region shutdown thread/INFO]: [Towny] Finishing File IO Tasks...
[17:19:20] [Region shutdown thread/INFO]: [Towny] Finishing Universe Tasks...
[17:19:20] [Region shutdown thread/INFO]: [Towny] Version: 0.100.1.5 - Plugin Disabled
[17:19:20] [Region shutdown thread/INFO]: =============================================================
[17:19:20] [Region shutdown thread/INFO]: [RegionShutdownThread] Halting chunk systems
[17:19:20] [Region shutdown thread/INFO]: [ChunkHolderManager] Waiting 60s for chunk system to halt for world 'world'
[17:19:20] [Region shutdown thread/INFO]: [ChunkHolderManager] Halted chunk system for world 'world'
[17:19:20] [Region shutdown thread/INFO]: [ChunkHolderManager] Waiting 60s for chunk system to halt for world 'world_nether'
[17:19:20] [Region shutdown thread/INFO]: [ChunkHolderManager] Halted chunk system for world 'world_nether'
[17:19:20] [Region shutdown thread/INFO]: [ChunkHolderManager] Waiting 60s for chunk system to halt for world 'world_the_end'
[17:19:20] [Region shutdown thread/INFO]: [ChunkHolderManager] Halted chunk system for world 'world_the_end'
[17:19:20] [Region shutdown thread/INFO]: [RegionShutdownThread] Halted chunk systems
[17:19:20] [Region shutdown thread/INFO]: [RegionShutdownThread] Saving chunks around region around chunk [0, 0] in world 'world'
[17:19:21] [Region shutdown thread/INFO]: [ChunkHolderManager] Saved 2025 block chunks, 529 entity chunks, 2 poi chunks in world 'world' in 0,85s
[17:19:21] [Region shutdown thread/INFO]: [RegionShutdownThread] Saving chunks around region around chunk [0, 0] in world 'world_nether'
[17:19:22] [Region shutdown thread/INFO]: [ChunkHolderManager] Saved 2025 block chunks, 529 entity chunks, 0 poi chunks in world 'world_nether' in 0,47s
[17:19:22] [Region shutdown thread/INFO]: [RegionShutdownThread] Saving chunks around region around chunk [0, 0] in world 'world_the_end'
[17:19:22] [Region shutdown thread/INFO]: [ChunkHolderManager] Saved 2025 block chunks, 529 entity chunks, 0 poi chunks in world 'world_the_end' in 0,18s
[17:19:22] [Region shutdown thread/INFO]: [RegionShutdownThread] Saving players
[17:19:22] [Region shutdown thread/INFO]: Flushing Chunk IO
[17:19:22] [Region shutdown thread/INFO]: Closing Thread Pool
[17:19:22] [Region shutdown thread/INFO]: Closing Server

I tried Towny on git-Folia-20 1.20.2 and everything worked fine, so it looks like something changed in 1.20.4.