MineMaarten / PneumaticCraft

PneumaticCraft source
Other
84 stars 50 forks source link

Stall with Multiplayer/Amadron Orders #747

Closed utoc closed 7 years ago

utoc commented 8 years ago

Hello!

I've got an issue to report using PneumaticCraft-1.7.10-1.1.18-140 with a multiplayer environment. A user recently placed an order using Amadron and was kicked offline and unable to reconnect.

I ordered something with the PneumaticCraft Amadron tablet, and now I crash a couple of seconds after login with a timeout error. I am unable to interact with anything in this short time span. Nothing else is shown on my side, but perhaps there is something in the server log. At this point I am unable to play.

Fortunately, Sampler by sfPlayer made a stall report so we have something to go on:

Stall report from 2015-10-30 20:20:34, 42 threads, stalled for at least 30000 ms.

"Server thread" #36 prio=5
RUNNABLE
    at java.util.HashMap$TreeNode.split(HashMap.java:2126)
    at java.util.HashMap.resize(HashMap.java:713)
    at java.util.HashMap.putVal(HashMap.java:662)
    at java.util.HashMap.put(HashMap.java:611)
    at java.util.HashSet.add(HashSet.java:219)
    at net.minecraft.util.IntHashMap.func_76038_a(SourceFile:64)
    at net.minecraft.pathfinding.PathFinderDrone.openPoint(PathFinderDrone.java:235)
    at net.minecraft.pathfinding.PathFinderDrone.getSafePoint(PathFinderDrone.java:221)
    at net.minecraft.pathfinding.PathFinderDrone.findPathOptions(PathFinderDrone.java:163)
    at net.minecraft.pathfinding.PathFinderDrone.addToPath(PathFinderDrone.java:122)
    at net.minecraft.pathfinding.PathFinderDrone.createEntityPathTo(PathFinderDrone.java:94)
    at net.minecraft.pathfinding.PathFinderDrone.createEntityPathTo(PathFinderDrone.java:66)
    at pneumaticCraft.common.ai.EntityPathNavigateDrone.getEntityPathToXYZ(EntityPathNavigateDrone.java:92)
    at pneumaticCraft.common.ai.EntityPathNavigateDrone.func_75488_a(EntityPathNavigateDrone.java:45)
    at net.minecraft.pathfinding.PathNavigate.func_75492_a(SourceFile:85)
    at pneumaticCraft.common.ai.EntityPathNavigateDrone.moveToXYZ(EntityPathNavigateDrone.java:177)
    at pneumaticCraft.common.ai.DroneAIBlockInteraction.func_75253_b(DroneAIBlockInteraction.java:150)
    at pneumaticCraft.common.ai.DroneAIManager.onUpdateTasks(DroneAIManager.java:348)
    at pneumaticCraft.common.entity.living.EntityDrone.func_70071_h_(EntityDrone.java:340)
    at net.minecraft.world.World.func_72866_a(World.java:2070)
    at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:648)
    at net.minecraft.world.World.func_72870_g(World.java:2034)
    at net.minecraft.world.World.func_72939_s(World.java:1887)
    at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:489)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:636)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)

Full mod list here: https://www.reddit.com/r/BBQSauce/wiki/modlist

This is happening everytime they login at this point and I am willing to bet that its chunk related. Do you have any suggestions for how to cancel all Amadron orders or otherwise nuke the disobedient drone from orbit?

Mordenkainen commented 8 years ago

I was inside a Compact Machine at the time, so perhaps that interfered with the drones pathfinding?

I tried this in singleplayer and while I didn't have a crash, I did have a 5-10 second lag just before the drone teleported in.

utoc commented 8 years ago

I was able to disable the drone with that handy config setting: B:"Stop Drone AI"=false

Thanks for including that!

This happened because CompactMachines are completely sealed and players/items cannot break through those blocks to get inside. Would you consider a dimension blacklist for Amadon or perhaps a dimension whitelist? Or.. And this may be the easiest way, but require access to level 15 sunlight? CompactMachines all have Level 13 SL at all times.

MineMaarten commented 8 years ago

The same situation could be reproduced just by placing an order when in a sealed room. Yes, this will make the Drone try every route it can to try to find a valid path, stalling the server for maybe half a second, but after that it should teleport instead and everything should be fine...

utoc commented 8 years ago

I think the problem is that in SMP, the user time outs before the drone gives up and it ends up in an endless cycle each time the chunks with the drone are reloaded.

MineMaarten commented 8 years ago

Unlikely but plausible, in case of when MANY drones pathfind at the same time, which may have happened with a big Amadron order... In any case there isn't a solution I can think of that would not require an entire pathfinding implementation for drones (as opposed to the Vanilla system used currently). It's not something I plan on doing as it will create more problems than it will solve. Also the suggestion to allow blacklisting of dimensions is not really effective because of what I said in last post..

If many orders indeed is the cause, I might look at a way of gradually spawning in the drones instead of all at once.

Mordenkainen commented 8 years ago

What about a config option for the Amadron order drones to automatically teleport by default.

This way server owners have the option to avoid the issue by negating the pathfinding aspect alltogether.

In this case it was not a large order, just 5 PCB Blueprints.

I think the issue may have something to do with the fact that CM has special handling for entities that end up outside a room, and since the drone spawned outside, CM may have been trying to relocate it at the same time it was trying to teleport/pathfind.

MineMaarten commented 8 years ago

What about a config option for the Amadron order drones to automatically teleport by default.

This would be like "just insta-spawn the items instead of using drones". It's that immersion that makes the feature be cool :(.

I don't know that about CM. I do know that drones will take 2-3 seconds to 'initiate' the teleporting (intentional penalty for the cheatyness of the teleporting. This doesn't block the server though, only the real pathfinding that happens before this does).

utoc commented 8 years ago

CM punishes non-Creative player entities by giving them a few debuffs and if they hit Y0, they're sent back to world spawn location. The drone, after disabling AI, when I found it was sitting at Y0 but with full health... I don't think it was effected in the same way as non-creative player entities.

If you could increase the MC client timeout, you could keep the player from timing out and therefore the server stall wouldn't matter because the player would never disconnect and thus the loop wouldn't begin.

Mordenkainen commented 8 years ago

I agree that the option would break the immersion, but it looks like the alternative in this case was to cause a section of one of the dimensions to make it so players who enter it could no longer play until all drones on the server were stopped, and the problematic drone was located and destroyed.

It was good the @utoc was able to do this, but many server owners may not be that savvy and may resort to deleting the offending dimension and the player files of the players in it.

In my opinion I would sacrifice a little immersion if the alternative was not being able to play or losing all my stuff. (In this case the dimension in question contained everything I owned, my AE autocrafting system, and my entire EE3 EMC stockpile of ~2.3 billion EMC)