L2JMobius

Free Users => Solved/Invalid Bug Reports => Topic started by: ver on January 14, 2021, 12:39:14 PM

Title: Shutdown and strange items loss
Post by: ver on January 14, 2021, 12:39:14 PM
Hello,

I've performed simple shutdown procedure. Gave ppl like 60 secs.
Unfortunatelly during that time the items that were created/spoiled in last 30..40 mins were gone. Looks like items were not stored in DB during the shutdown.

Is it normal? Guess not?

Best regards
Title: Re: Shutdown and strange items loss
Post by: G-hamsteR on January 15, 2021, 10:19:03 AM
Did you receive any error logs? I have never had the same problem. 500 players online without item loss.
Title: Re: Shutdown and strange items loss
Post by: ver on January 15, 2021, 02:38:42 PM
Nope, error log clean ;/
Title: Re: Shutdown and strange items loss
Post by: G-hamsteR on January 18, 2021, 11:38:56 AM
I think the problem is with your mysql server and not with the gameserver. All changes are sent to mysql. Maybe mysql crashed and lost some data.
Title: Re: Shutdown and strange items loss
Post by: ver on January 18, 2021, 09:19:29 PM
This is exactly what I suspected at the first.
Checked database, all logs on my box, even tables structure (maybe they are corrupted or something). But not... All was pretty much normal.

Today I made simple shutdown with 120 sec. All went fine. Server got closed etc. No errors whatsoever.

After the start it appeared that some dropped items in line 15..20 min before, was not inserted in items table. It looks like it was just in memory/some java threads and simply just not inserted when it suppose to be.

Maybe there is something there?  Like items are stored in db to rarely? (Dunno, just made up shot in a dark).
Title: Re: Shutdown and strange items loss
Post by: ver on January 19, 2021, 11:52:38 PM
After all - its not so strange. The players inventory was not stored at all on shutdown procedure because store() method is not saveing that...

File: java/org/l2jmobius/gameserver/Shutdown.java  (manually created patch)
Code: [Select]
      private void saveAllPlayers()
        {
                LOGGER.info("Saving all players data...");

                for (PlayerInstance player : World.getInstance().getAllPlayers())
                {
                        if (player == null)
                        {
                                continue;
                        }

                        // Logout Character
                        try
                        {
                                // Save player status
                                player.store();
                                player.getInventory().updateDatabase();
                                player.getWarehouse().updateDatabase();

                        }
                        catch (Throwable t)
                        {
                        }
                }
        }


I don't know if its proper fix, but at least it does save players stuff.

Title: Re: Shutdown and strange items loss
Post by: Mobius on January 23, 2021, 03:11:54 PM
Can you try this instead?
Code: [Select]
Index: java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java
===================================================================
--- java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java (revision 8154)
+++ java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java (working copy)
@@ -8583,6 +8583,10 @@
  aVars.storeMe();
  }
 
+ getInventory().updateDatabase();
+ getWarehouse().updateDatabase();
+ getFreight().updateDatabase();
+
  // If char is in Offline trade, setStored must be true
  setStored(isInOfflineMode());
  }
Title: Re: Shutdown and strange items loss
Post by: ver on January 24, 2021, 04:14:56 PM
Tried, works smooth ;)
Title: Re: Shutdown and strange items loss
Post by: Mobius on January 24, 2021, 08:28:31 PM
Fixed with https://bitbucket.org/MobiusDev/l2j_mobius/commits/64e40bccde3bca9aeaaab6a558928d8fcd917ba6
Thanks :D