joe7575 / signs_bot

A Minetest robot controlled by signs
GNU General Public License v3.0
5 stars 7 forks source link

[WIP] Fix disconnected Bots after Server-Crash #21

Closed nixnoxus closed 2 years ago

nixnoxus commented 2 years ago

If the signs_bot is running during a server crash, it will stand disconnected from the box afer a server restart. The box will then start a new bot, which may be affected by the disconnected one.

I can reproduce this behavior as follows:

repeat 20 move 1 end exit

- turn on the box, wait about 4 seconds and then kill the server

~$ kill -kill $(pidof minetest)

- after the restart you have a new and the old bot.

This PR fixes the problem by calling the new function `tubelib2.save_mem(base_pos)` (see  https://github.com/joe7575/tubelib2/pull/14) after each change of `mem.robot_pos`.

Besides the above setup i have also tested it with this program:

turn_left

repeat 20 backward end exit



I am not sure yet to what extent this will affect the performance. Therefore [WIP]

*Edit*
Sorry for the early [WIP]-PR. I just wanted to make sure with the description here that not several issues get mixed up.
joe7575 commented 2 years ago

This is maybe a workaround but no solution. The main reason for tubelib2.storage.lua is not to serialize and store all data with each change of data. This is one of the reasons why huge installations of machines like in TechPack or Techage are also possible on small servers. You should fix the root cause of the server crashes and not try to bypass them .

nixnoxus commented 2 years ago

I think that both problems should be fixed. Server crashes can never be completely excluded and if then the world data with the mod storage no longer match is very annoying.

I'm still trying to investigate the effect on performance. Maybe saving the bot position in the meta data of the box would be a more performant solution.

joe7575 commented 2 years ago

A server crash logically can't be predicted. Thus, to keep all data always consistent to be prepared for a crash is impossible. However, to remove artefacts after a server crash should not be a big deal. You could try to use minetest.register_lbm to remove artefacts.