• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ How do I solve this bottleneck? IOLoginData::savePlayer

gudan garam

Advanced OT User
Joined
Feb 13, 2011
Messages
353
Solutions
17
Reaction score
173
Location
São Paulo.
Hello people, so me and a few friends were testing different ways to crash a server and we figured a way (that everybody already knows about), that is by trashing the tiles of a house with thousands of items, possibly hundreads of thounsands, than leaving the house.

The crash is caused by the method mentioned on the title, when you leave a house, the method deletes all of the players inbox items to then re-insert them, thus, saving the items that just went from his house to his inbox.

As you may already have figured this out, mysql can't handle insert that many rows into the database and comes to an end, a sad one tbh. And then the server lags and possibly crashes.

I don't know if this is correct, but I think mysql crashes because it tries to insert all the player inbox items with onequery, that query takes to much time (or even memory, idk really) to execute that it crashes the service.


I haven't had time to check, but a friend suggested me to check some configs with mysql to have better batch inserts, and I have thought about a way to split this insert, into smallers inserts.

Lets take a small number just for explanation purposes.

If you are inserting 50 items into the table, insted of executing one query, lets execute 2 queries, inserting 25 items each query, I haven't had time to test that aswell, but a friend said that could help.

Another way would be to only execute this part on the server save, but that wouldn't help I think. As it would still halt mysql causing it to rollback the transaction.

What are your guyses thoughts? Have you had this issue? Did you fix it?
 
besides that, you can first select and count the items to split queries on addEvent(server side), you can create a stored procedure and execute it on shutdown/startup (db side + server side), you can make a trigger in your database to count the quantity of update/insert and split the query to avoid lagging/crashing (db side).
 
That solution is simpler than it seems to you.

Just if a player wants to leave own house should pick up all items otherwise they should be removed.

The most rational way.
 
A true genius, but once a player leave house and lose all items you'll lost one player too.
I wouldn't cry :D Now we're talking about children

Haha they can spend 5 minutes to pick up them. let's not exaggerate xdd

You can even put a warning message
 
Now, the max item per tile is the right answer for that, along with spliting the query

But... if u have a npc near ur house and buy a cheap item that u don't have any cap to carry if will throw the item on the ground, ignore the max item per sqm
 
Now, the max item per tile is the right answer for that, along with spliting the query

But... if u have a npc near ur house and buy a cheap item that u don't have any cap to carry if will throw the item on the ground, ignore the max item per sqm
Well there is few solutions to that problem. Either dont have npc near the house, you cant buy items if your BP is full or make changes in the source code. Take look at queryAdd:
otland/forgottenserver
 
Well there is few solutions to that problem. Either dont have npc near the house, you cant buy items if your BP is full or make changes in the source code. Take look at queryAdd:
otland/forgottenserver

I messed around with that, and other methods such as playerAddItem, the thing is that Tile:queryAdd is called for example, when a monster is killed, so that would cause the monster's corpse not to be created if I limit the items per tile here. I can't find what method is called in the source when a player moves an item, do u know?
 
Back
Top