MightyPirates / OpenComputers

Home of the OpenComputers mod for Minecraft.
https://oc.cil.li
Other
1.59k stars 431 forks source link

Spontaneous shutdown of computers #3225

Closed ewwhash closed 4 years ago

ewwhash commented 4 years ago

Computers(Drones, microcontrollers, robots) shutdown when player don't load chunk(with computers) more than ~15 minutes or server restart/enter to the world. Supposedly, problem has here https://github.com/MightyPirates/OpenComputers/blob/master-MC1.7.10/src/main/scala/li/cil/oc/common/SaveHandler.scala#L211, when it save the world, it deletes all files. Computers shut down from version 1.7.3. Architecture is not LuaJ, it is important!

payonel commented 4 years ago

i am not sure of your repro

  1. mc on server
  2. create computer
  3. put files on disk
  4. leave computer running
  5. walk away from computer and chunks for 15 minutes

result: computer shuts down and files are deleted?

what about 1.7.3? is this a regression?

ewwhash commented 4 years ago

Files not deleting. To be honest, that's not my link of SaveHandler.scala, it said the guy who fixed it(He did not give details). Computers shut down between 1.7.3 - 1.7.5 versions. Server core/MC version is not affected, it is on all versions. I think, @Fingercomp have ideas about that.

payonel commented 4 years ago

I cannot hit this

multiplayer world built a machine, ran a loop that prints a date string to the host server log every second move away from it until it unloads walk in and out of chunk boundary to load it i wanted just outside its chunk range stop + start server walked back into chunk range, and right away the pc keeps printing to server log i'll now wait with the server running and just outside chunk range for ~15 minutes, but i suspect this'll work just fine

payonel commented 4 years ago

nope - stood outside the chunk range for 18 minutes, walked in, and immediately the pc script started running again

ewwhash commented 4 years ago

https://github.com/MightyPirates/OpenComputers/issues/2999 same

payonel commented 4 years ago

@BrightYC you have the same stack trace in your log?

payonel commented 4 years ago

AND can you repro this a test world? just make a new world, place a computer and try repro

radioegor146 commented 4 years ago

Well, the bug is probably in the logic of https://github.com/MightyPirates/OpenComputers/blob/master-MC1.7.10/src/main/scala/li/cil/oc/common/SaveHandler.scala#L203

It can be caused in (for example) in this flow:

  1. When computer's TileEntity is saved (because of chunk unload for example) the computer's chunk directory is added into chunkDirs queue
  2. And then, after TimeToHoldOntoOldSaves + 1 seconds or more the server saves the world, which causes cleanSaveData to be executed and the data of all computers in this chunk is deleted.

I had personally fixed it by just removing the chunkDirs cleanup process.

radioegor146 commented 4 years ago

Also, the reason why you couldn't repro it is that your server never saves the world while running (but some cores like Thermos, Cauldron, etc. can do it from Bukkit plugins for example)

payonel commented 4 years ago

ah, that is very helpful, thank you @radioegor146 . i appreciate this very much! I'll work to repro this and review your approach. Clarification, you're saying you only removed this code?

    while (!chunkDirs.isEmpty) {
      val chunkPath = chunkDirs.poll()
      if (chunkPath.exists && chunkPath.isDirectory && chunkPath.list() != null) {
        for (file <- chunkPath.listFiles() if System.currentTimeMillis() - file.lastModified() > TimeToHoldOntoOldSaves) file.delete()
      }
    }
radioegor146 commented 4 years ago

Yep, exactly. Btw, I even do not know for what reason you should delete the persistence of computers. Sounds like some very strange optimization (?)

lfreew1ndl commented 4 years ago

so any updates? because of this bug, we cannot create public programs. I mean programs on public warps.

SnaveSutit commented 4 years ago

I'm having the same issue, except my files aren't being deleted. My computers just shut down when unloaded then loaded again

lfreew1ndl commented 4 years ago

yes, my files aren't being deleted too. I mean that I programs for example shops, casinos, banks and etc are useless because of this bug.

adriaanvanzyl commented 4 years ago

I have exactly the same problem as this

My computers shut down by themselves when I close my game or move away from the computer chunks for an extended period.

I would leave them running, and when I come back to them, they are ALL turned off and sometimes they erase the hard disks.

I have seen various reports of this issue but it seems that no one has been able to figure out why this is happening.

I should mention that the analyzer and logs yield no errors as to why the computers have turned off.

Artmoneyse commented 4 years ago

[08:13:38] [Server thread/ERROR]: Unexpected error loading a state of computer at (-536.5, 80.5, -353.5). State: Paused. Unless you're upgrading/downgrading across a major version, please report this! Thank you. java.lang.Exception: li.cil.repack.com.naef.jnlua.LuaRuntimeException: could not read data at li.cil.oc.server.machine.luac.NativeLuaArchitecture.load(NativeLuaArchitecture.scala:351) ~[NativeLuaArchitecture.class:?] at li.cil.oc.server.machine.Machine.liftedTree1$1(Machine.scala:747) [Machine.class:?] at li.cil.oc.server.machine.Machine.load(Machine.scala:746) [Machine.class:?] at li.cil.oc.common.tileentity.traits.Computer$class.readFromNBTForServer(Computer.scala:158) [Computer$class.class:?] at li.cil.oc.common.tileentity.Case.li$cil$oc$common$tileentity$traits$Colored$$super$readFromNBTForServer(Case.scala:27) [Case.class:?] at li.cil.oc.common.tileentity.traits.Colored$class.readFromNBTForServer(Colored.scala:33) [Colored$class.class:?] at li.cil.oc.common.tileentity.Case.readFromNBTForServer(Case.scala:85) [Case.class:?] at li.cil.oc.common.tileentity.traits.TileEntity$class.readFromNBT(TileEntity.scala:80) [TileEntity$class.class:?] at li.cil.oc.common.tileentity.Case.func_145839_a(Case.scala:27) [Case.class:?] at net.minecraft.tileentity.TileEntity.func_145827_c(TileEntity.java:134) [aor.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.loadEntities(AnvilChunkLoader.java:525) [aqk.class:?] at net.minecraftforge.common.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:44) [ChunkIOProvider.class:1.7.10-1614-BMO-Edition] at net.minecraftforge.common.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:15) [ChunkIOProvider.class:1.7.10-1614-BMO-Edition] at net.minecraftforge.common.util.AsynchronousExecutor$Task.finish(AsynchronousExecutor.java:189) [AsynchronousExecutor$Task.class:1.7.10-1614-BMO-Edition] at net.minecraftforge.common.util.AsynchronousExecutor$Task.get(AsynchronousExecutor.java:165) [AsynchronousExecutor$Task.class:1.7.10-1614-BMO-Edition] at net.minecraftforge.common.util.AsynchronousExecutor.skipQueue(AsynchronousExecutor.java:341) [AsynchronousExecutor.class:1.7.10-1614-BMO-Edition] at net.minecraftforge.common.util.AsynchronousExecutor.getSkipQueue(AsynchronousExecutor.java:302) [AsynchronousExecutor.class:1.7.10-1614-BMO-Edition] at net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:12) [ChunkIOExecutor.class:1.7.10-1614-BMO-Edition] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:212) [ms.class:?] at net.minecraft.world.gen.ChunkProviderServer.func_73158_c(ChunkProviderServer.java:185) [ms.class:?] at net.minecraft.server.management.ServerConfigurationManager.func_72375_a(ServerConfigurationManager.java:311) [oi.class:?] at net.minecraft.server.management.ServerConfigurationManager.func_72377_c(ServerConfigurationManager.java:394) [oi.class:?] at net.minecraft.server.management.ServerConfigurationManager.initializeConnectionToPlayer(ServerConfigurationManager.java:229) [oi.class:?] at cpw.mods.fml.common.network.handshake.NetworkDispatcher.completeServerSideConnection(NetworkDispatcher.java:201) [NetworkDispatcher.class:1.7.10-1614-BMO-Edition] at cpw.mods.fml.common.network.handshake.NetworkDispatcher.completeHandshake(NetworkDispatcher.java:476) [NetworkDispatcher.class:1.7.10-1614-BMO-Edition] at cpw.mods.fml.common.network.internal.HandshakeCompletionHandler.channelRead0(HandshakeCompletionHandler.java:21) [HandshakeCompletionHandler.class:1.7.10-1614-BMO-Edition] at cpw.mods.fml.common.network.internal.HandshakeCompletionHandler.channelRead0(HandshakeCompletionHandler.java:11) [HandshakeCompletionHandler.class:1.7.10-1614-BMO-Edition] at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:98) [SimpleChannelInboundHandler.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [MessageToMessageDecoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) [MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?] at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?] at cpw.mods.fml.common.network.internal.FMLProxyPacket.func_148833_a(FMLProxyPacket.java:77) [FMLProxyPacket.class:1.7.10-1614-BMO-Edition] at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:245) [ej.class:?] at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:181) [nc.class:?] at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:1046) [MinecraftServer.class:?] at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:432) [lt.class:?] at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:863) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:708) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_171] Caused by: li.cil.repack.com.naef.jnlua.LuaRuntimeException: could not read data at li.cil.repack.com.naef.jnlua.LuaState.lua_pcall(Native Method) ~[LuaState.class:?] at li.cil.repack.com.naef.jnlua.LuaState.call(LuaState.java:681) ~[LuaState.class:?] at li.cil.oc.server.machine.luac.PersistenceAPI.unpersist(PersistenceAPI.scala:164) ~[PersistenceAPI.class:?] at li.cil.oc.server.machine.luac.NativeLuaArchitecture.load(NativeLuaArchitecture.scala:356) ~[NativeLuaArchitecture.class:?] ... 43 more