Minetestserver erased map.sqlite, size 0 byte.

amadin
Member
 
Posts: 471
Joined: Tue Jun 16, 2015 16:23
GitHub: Amadin

Minetestserver erased map.sqlite, size 0 byte.

by amadin » Tue Jul 14, 2015 18:16

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.
Last edited by amadin on Wed Jul 15, 2015 10:46, edited 1 time in total.
 

User avatar
lag01
Member
 
Posts: 190
Joined: Sun Mar 16, 2014 03:41
GitHub: AndrejIT
IRC: lag01
In-game: lag

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

by lag01 » Tue Jul 14, 2015 19:21

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.
 

amadin
Member
 
Posts: 471
Joined: Tue Jun 16, 2015 16:23
GitHub: Amadin

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

by amadin » Wed Jul 15, 2015 10:28

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.
 

amadin
Member
 
Posts: 471
Joined: Tue Jun 16, 2015 16:23
GitHub: Amadin

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

by amadin » Sat Jul 18, 2015 06:03

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?
 

User avatar
lag01
Member
 
Posts: 190
Joined: Sun Mar 16, 2014 03:41
GitHub: AndrejIT
IRC: lag01
In-game: lag

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

by lag01 » Sat Jul 18, 2015 13:22

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.
 

User avatar
jogag
Member
 
Posts: 106
Joined: Wed Aug 12, 2015 18:32
GitHub: jogag
IRC: jogag
In-game: jogag

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

by jogag » Sun Aug 16, 2015 10:17

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.
 

amadin
Member
 
Posts: 471
Joined: Tue Jun 16, 2015 16:23
GitHub: Amadin

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

by amadin » Sun Aug 16, 2015 18:38

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.
 

User avatar
ExeterDad
Member
 
Posts: 1121
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad

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

by ExeterDad » Sun Aug 16, 2015 18:53

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.
٩(̾●̮̮̃̾•̃̾)۶

Kibbie and I have a beautiful public server now! HOMETOWN
 

User avatar
maikerumine
Member
 
Posts: 946
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

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

by maikerumine » Sun Aug 16, 2015 19:49

For this reason every day ibackup and offline manualy. Anything can happen.
 

amadin
Member
 
Posts: 471
Joined: Tue Jun 16, 2015 16:23
GitHub: Amadin

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

by amadin » Mon Aug 17, 2015 07:00

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.
 

User avatar
ExeterDad
Member
 
Posts: 1121
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad

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

by ExeterDad » Mon Aug 17, 2015 10:20

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.
٩(̾●̮̮̃̾•̃̾)۶

Kibbie and I have a beautiful public server now! HOMETOWN
 

amadin
Member
 
Posts: 471
Joined: Tue Jun 16, 2015 16:23
GitHub: Amadin

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

by amadin » Mon Aug 17, 2015 12:31

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
 

User avatar
jogag
Member
 
Posts: 106
Joined: Wed Aug 12, 2015 18:32
GitHub: jogag
IRC: jogag
In-game: jogag

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

by jogag » Thu Aug 20, 2015 16:27

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.
 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 9 guests

cron