Tiiffi/mcrcon

Possible race-condition, decode_packet hangs, 100% CPU usage, very frequently

MadMartian opened this issue · 1 comments

When attempting to execute command /save-off my script freezes with 100% CPU usage very frequently. When I abort the script with the good old interrupt signal it reveals this:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/mcrcon-0.0.0-py3.6.egg/mcrcon.py", line 52, in receive_packet
  File "/usr/local/lib/python3.6/site-packages/mcrcon-0.0.0-py3.6.egg/mcrcon.py", line 23, in decode_packet
mcrcon.IncompletePacket: 14

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./backup.py", line 17, in <module>
    rcon.backup(backup_output)
  File "/usr/local/games/minecraft/mmm.py", line 54, in backup
    mcrcon.command(self.sock, '/save-off')
  File "/usr/local/lib/python3.6/site-packages/mcrcon-0.0.0-py3.6.egg/mcrcon.py", line 86, in command
  File "/usr/local/lib/python3.6/site-packages/mcrcon-0.0.0-py3.6.egg/mcrcon.py", line 55, in receive_packet
KeyboardInterrupt

mmm.py is a utility module I wrote that depends on mcrcon. This is part of a script I configured, backup.py, to run nightly backups via cron (i.e. /save-off, do the backup using rsync, /save-on).

The script eventually runs through to completion but only after abort and reattempt several times making it unusable as a cron job. I would presume the response from the RCon server when calling /save-off is non-deterministic and causing decode_packet to choke.

Upon examining the source code in Minecraft, it appears prone to race condition:

        RConConsoleSource.instance.resetLog();
        this.commandManager.executeCommand(RConConsoleSource.instance, commandString);
        return RConConsoleSource.instance.getLogContents();

It executes the command and then hopes that the command will fill the log with some output (what if some other command does that?). This code is very bad so I wouldn't be surprised if a reliable resolution isn't possible.

Hello,

I think you got wrong git project. This one is written in C and the problem you are describing seems to be Python code.

I believe this issue should be reported on https://github.com/barneygale/MCRcon