Page 1 of 1

Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Tue Jul 14, 2015 18:16
by amadin
Server crashed as usual after 4-6 hours of work but.... I find in log this errors before this crash:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
16:54:22: ERROR[ServerThread]: ServerEnvironment::deactivateFarObjects(): Could not save object id=11271 to it's current block (-1134,-51,-22)
16:54:24: ERROR[ServerThread]: ServerEnvironment::deactivateFarObjects(): Could not save object id=11271 to it's current block (-1134,-61,-22)
16:54:26: ERROR[ServerThread]: ServerEnvironment::deactivateFarObjects(): Could not save object id=11271 to it's current block (-1134,-76,-22)
16:54:28: ERROR[ServerThread]: ServerEnvironment::deactivateFarObjects(): Could not save object id=11271 to it's current block (-1134,-94,-22)
16:54:30: ERROR[ServerThread]: ServerEnvironment::deactivateFarObjects(): Could not save object id=11271 to it's current block (-1134,-118,-22)
16:54:32: ERROR[ServerThread]: ServerEnvironment::deactivateFarObjects(): Could not save object id=11271 to it's current block (-1134,-144,-22)
16:54:34: ERROR[ServerThread]: ServerEnvironment::deactivateFarObjects(): Could not save object id=11271 to it's current block (-1134,-177,-22)
16:54:36: ERROR[ServerThread]: ServerEnvironment::deactivateFarObjects(): Could not save object id=11271 to it's current block (-1134,-214,-22)

But server still worked after this errors, after some time it was crashed:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
In thread 7f9fa1c6c700:
/build/minetest-KMJvg5/minetest-0.4.12+repack/src/inventory.cpp:629: ItemStack& InventoryList::getItem(irr::u32): Assertion 'i < m_size' failed.
Debug stacks:
DEBUG STACK FOR THREAD 7f9f9b5fe700:
#0  virtual void* EmergeThread::Thread()
(Leftover data: #1  MapBlock* ServerMap::loadBlock(v3s16))
(Leftover data: #2  void ServerMap::loadBlock(std::string*, v3s16, MapSector*, bool))
(Leftover data: #3  void ItemStack::deSerialize(std::istream&, IItemDefManager*))
DEBUG STACK FOR THREAD 7f9f9bfff700:
#0  virtual void* CurlFetchThread::Thread()
DEBUG STACK FOR THREAD 7f9fa1c6c700:
#0  virtual void* ServerThread::Thread()
#1  void Server::Receive()
#2  void Server::ProcessData(irr::u8*, irr::u32, irr::u16)
(Leftover data: #3  void ItemStack::deSerialize(std::istream&, IItemDefManager*))
(Leftover data: #4  void ItemStack::serialize(std::ostream&) const)
(Leftover data: #5  void ServerMap::loadBlock(std::string*, v3s16, MapSector*, bool))
(Leftover data: #6  void ItemStack::deSerialize(std::istream&, IItemDefManager*))
DEBUG STACK FOR THREAD 7f9fa86c7780:
#0  int main(int, char**)
#1  Dedicated server branch
#2  void dedicated_server_loop(Server&, bool&)
(Leftover data: #3  void Server::step(float))

Then auto-restart script (which checks the process "minetestserver" is running or not) as usual try to run it again:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
5: Bind failed: Адрес уже используется
5: Bind failed: Адрес уже используется
17:50:46: ERROR[ServerThread]: SQLite3 read statment failed to prepare: no such table: blocks

"Адрес уже используется" it translated as "Address already in use". After 5-6 hours this error was repeated then i stoped autorestart script and saw the size of map.sqlite is 0 byte. So last backup is 2 days ago. Online of my server was 20-30 peolpes. Now i'm very bad-tempered. Version of server 0.4.12+repack, debian jeesy 64-bit, only ssh.

Re: Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Tue Jul 14, 2015 19:21
by lag01
amadin wrote:...
"Адрес уже используется" it translated as "Address already in use".
...

I newer got map wiped like this, so cannot speak for sure.
Are you sure your script cannot accidentally run two "minetestserver" at the same time?

I use something like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
processname="minetestserver"
pidfile="/var/run/$processname.pid"

if [ ! "$(pidof $processname)" ]
then
    if [ ! -f "$pidfile" ]; then
        echo "$(date) Not started $processname!" >> /home/user/.minetest/minekeepup.txt
    else
        /usr/bin/tail -n 60 /home/user/.minetest/debug.txt >> /home/user/.minetest/minekeepup.txt
       /etc/init.d/minetest continue
        echo "$(date) Restarted $processname" >> /home/user/.minetest/minekeepup.txt
    fi
fi

/etc/init.d/minetest continue is my function, which start daemon without backup etc. and double checks if minetestserver not running.

Re: Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Wed Jul 15, 2015 10:28
by amadin
But crashed minetestserver may not delete .pid file.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
#!/bin/bash
RESTART="/etc/init.d/minetest start"
# Путь к pgrep команде
PGREP="/usr/bin/pgrep"
# имя демона,
DAEMON="minetestserver"
# поиск DAEMON pid
$PGREP ${DAEMON}
if [ $? -ne 0 ] # if minetestserver not running
then
 # перезапуск
cp -rp /home/user/worlds/world/players/* /home/user/worlds/world/players.safe/
cp -rp /home/user/worlds/world/map/map.sqlite /home/user/worlds/world/map.safe/map.sqlite
$RESTART
fi

/etc/init.d/minetest start - it is modified default script wich start and stop minetestserver using start-stop-daemon.

Re: Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Sat Jul 18, 2015 06:03
by amadin
lag01 wrote:
amadin wrote:...
"Адрес уже используется" it translated as "Address already in use".
...

I newer got map wiped like this, so cannot speak for sure.
Are you sure your script cannot accidentally run two "minetestserver" at the same time?

I use something like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
processname="minetestserver"
pidfile="/var/run/$processname.pid"

if [ ! "$(pidof $processname)" ]
then
    if [ ! -f "$pidfile" ]; then
        echo "$(date) Not started $processname!" >> /home/user/.minetest/minekeepup.txt
    else
        /usr/bin/tail -n 60 /home/user/.minetest/debug.txt >> /home/user/.minetest/minekeepup.txt
       /etc/init.d/minetest continue
        echo "$(date) Restarted $processname" >> /home/user/.minetest/minekeepup.txt
    fi
fi

/etc/init.d/minetest continue is my function, which start daemon without backup etc. and double checks if minetestserver not running.


I think I figured out what happened - http://wiki.minetest.net/Database_backends column "Reliability" for "SQLite3" - "db can corrupt if accessed while open". There is only one question - why script-autorestart tried to run is already running process?

Re: Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Sat Jul 18, 2015 13:22
by lag01
amadin wrote:I think I figured out what happened - http://wiki.minetest.net/Database_backends column "Reliability" for "SQLite3" - "db can corrupt if accessed while open". There is only one question - why script-autorestart tried to run is already running process?

Autorestart need to check if any process with name "minetestserver" is already running.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
mt_continue() {
    echo "Restoring $SERVICE...."
    if [ ! -f "$PIDFILE" ]; then
        echo "Not started!"
    else
        if [ "$(pidof $SERVICE)" ]; then
            echo "Already running!"
        else
            start-stop-daemon --start --chuid "$USERNAME:$USERNAME" --background --make-pidfile --pidfile $PIDFILE --exec $INVOCATION -- $OPTIONS
            echo "Done!"
        fi
    fi
}


But it can give you problems, if you want run many minetest games on one server.

Re: Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Sun Aug 16, 2015 10:17
by jogag
It also happened to me, my server crashed then ALL the world files (player files, env_meta.txt and map.sqlite) emptied. I re-opened the world and the map was re-generated, with NO previous buildings!
(Only one server instance open!)
I don't know what happened, but I have no server restart script.
A stupid crash wiped the entire world, and the player files.

Re: Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Sun Aug 16, 2015 18:38
by amadin
jogag wrote:It also happened to me, my server crashed then ALL the world files (player files, env_meta.txt and map.sqlite) emptied. I re-opened the world and the map was re-generated, with NO previous buildings!
(Only one server instance open!)
I don't know what happened, but I have no server restart script.
A stupid crash wiped the entire world, and the player files.

Don't use sqlite, use leveldb. I don't know why developers set sqlite by default because they know about this bug long ago - "Acceptable (db can corrupt if accessed while open)" http://wiki.minetest.net/Database_backends. Don't use redis too.

Re: Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Sun Aug 16, 2015 18:53
by ExeterDad
amadin wrote:
jogag wrote:It also happened to me, my server crashed then ALL the world files (player files, env_meta.txt and map.sqlite) emptied. I re-opened the world and the map was re-generated, with NO previous buildings!
(Only one server instance open!)
I don't know what happened, but I have no server restart script.
A stupid crash wiped the entire world, and the player files.

Don't use sqlite, use leveldb. I don't know why developers set sqlite by default because they know about this bug long ago - "Acceptable (db can corrupt if accessed while open)" http://wiki.minetest.net/Database_backends. Don't use redis too.

If a server looses power before it's shutdown properly all those files get blanked out every time for me. Not sure it's the fault of mysql.

Re: Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Sun Aug 16, 2015 19:49
by maikerumine
For this reason every day ibackup and offline manualy. Anything can happen.

Re: Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Mon Aug 17, 2015 07:00
by amadin
ExeterDad wrote:
amadin wrote:
jogag wrote:It also happened to me, my server crashed then ALL the world files (player files, env_meta.txt and map.sqlite) emptied. I re-opened the world and the map was re-generated, with NO previous buildings!
(Only one server instance open!)
I don't know what happened, but I have no server restart script.
A stupid crash wiped the entire world, and the player files.

Don't use sqlite, use leveldb. I don't know why developers set sqlite by default because they know about this bug long ago - "Acceptable (db can corrupt if accessed while open)" http://wiki.minetest.net/Database_backends. Don't use redis too.

If a server looses power before it's shutdown properly all those files get blanked out every time for me. Not sure it's the fault of mysql.

We speak about sqlite, not mysql. Server with 50-70 mods may crashed (without shutdown properly) every 6-12 hours.

Re: Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Mon Aug 17, 2015 10:20
by ExeterDad
Not sure why I wrote mysql in my last comment. I meant sqlite of course :)

So your saying player files are getting blanked merely with a crash, and no loss of power to the server hardware? If so, I've never seen that before.

Re: Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Mon Aug 17, 2015 12:31
by amadin
ExeterDad wrote:Not sure why I wrote mysql in my last comment. I meant sqlite of course :)

So your saying player files are getting blanked merely with a crash, and no loss of power to the server hardware? If so, I've never seen that before.

After most crashes all work fine

Re: Minetestserver erased map.sqlite, size 0 byte.

PostPosted: Thu Aug 20, 2015 16:27
by jogag
Ok, sqlite DBs are easily corruptible due to NO LOCK SYSTEM. LevelDB, instead, uses a lock file, but this can be a problem if your server stops without the time to delete that lock file. So if you get an error while opening a LevelDB-based world, and you see the "lock" word in the error, simply go in the world path, inside map.db and delete the "lock" file.