[1.21.1 Fabric] Lithium causes the server to deadlock internally when generating structures from Repurposed Structures
TelepathicGrunt opened this issue ยท 12 comments
Version Information
lithium-fabric-0.14.3-snapshot+mc1.21.1-build.92
Expected Behavior
I am the dev of Repurposed Structures mod that spawns additional structures in the world. It is expected that my structures generate without issues or any deadlocking.
Actual Behavior
A user reported to me that their game is deadlocking where chunks stop loading and server logic stop running. After a long and tedious time of disabling mods, I narrowed down the issue to Lithium. Disabling Lithium stops the deadlocking
TelepathicGrunt/RepurposedStructures#369
Reproduction Steps
- Put on Lithium and Repurposed Structures
- Create a world with seed 2438457204829392124
- Teleport to 800, 120, 200
- Move towards 1000, 120, 200
- Notice that chunks stop loading. Mobs stop working.
- Check latest.log to see no crash or errors.
- Do a thread dump like this https://pastebin.com/raw/bNaTw5n4 and you will see no worldgen threads are running code. Just the server thread was trying to grab a chunk and is locked up waiting on that chunk.
- Repeat by disabling either mod and see the issue does not happen.
Confirmed that it is the same chunk that it is accessing. Recently I noticed that Neoforge has a patch for exactly this case, so it might actually be unrelated to lithium
I think the comment here hints at a chunk loading operation loading the same chunk. method_12206 is runPostLoad in Mojmap. It appears entities that are riding other entities are loaded in, triggering a game event, triggering a vibration listener, triggering a chunk access.
This might be related to lithium's dispatcher optimization
If the user has manually enabled the option mixin.world.game_events.dispatch
, which is disabled by default in 0.14.3, I suggest disabling that option for now.
The Underground Bastion structure does spawn Skeleton Horsemen as part of worldgen:
It doesn't really make a difference whether the chunk is reloaded or being generated I think. I guess you have tested this structure without lithium already. Can you quickly confirm whether the dispatcher setting is enabled in the lithium.properties file?
The chunk in question is xz 57,20. The chunk that is receiving the game event is xz 57,19. The passenger (skeleton) is in 57,20 and the vibration listener is a sculk sensor in 57,19. I don't believe this is related to lithium, will test without.
@TelepathicGrunt GenerationChunkHolder has the additional field public LevelChunk currentlyLoading;
The fix is kind of a hack, since it allows chunk accesses before the chunk is actually loaded. The actual fix for your issue would be to prevent loading entities causing game events
Since this bug has also been bothering me, I will create a small bugfix mod that fixes this