Forum BigDB Save() called too many times

Discussion and help relating to the PlayerIO database solution, BigDB.

Save() called too many times

Postby LostBytes » July 7th, 2011, 1:43 pm

I am getting lot of messages
Code: Select all
Cannot save changes to database object 'simpleXYZ' in table 'PlayerObjects', because there are too many (5) save operations in progress already on the object. Please consider refactoring your code to avoid calling .Save() this often.


I save to player object after each fight. Maximum speed they can occur is once per 2-3 seconds, so basicly it is not possible to call save 5 times in less than 10 seconds (and that is also practically impossible because of lag and slow players reaction, it is more like 20 seconds at best). That should be more than enough time to save player object, is it not?

I noticed that this error occurs in groups and not everyday. So I can have 2 days of no errors and than 100 error during one day. Is it possible that there is some server problem (they are overloaded during times that this error occurs or something) ?

I save stats after each fight so user don't lose them if he is disconnected or something bad happens. I think I could save at the end of game, but I would rather fix cause than effect
LostBytes
Paid Member
 
Posts: 20
Joined: May 17th, 2011, 7:41 pm

Re: Save() called too many times

Postby Benjaminsen » July 9th, 2011, 6:15 pm

There is no speed guarantee on how fast an asynchronous request will execute on the server as the game server and DB server might not even be in the same data center.

The easy way to solve your issue is to simply discard save requests if one is already in progress and mark the object as dirty. Then simply check if the object is dirty when a save completes. If that's the case, save again.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Save() called too many times

Postby LostBytes » July 9th, 2011, 11:47 pm

Thanks,

I implemented it as you said and so far it looks like it is working correctly :)
LostBytes
Paid Member
 
Posts: 20
Joined: May 17th, 2011, 7:41 pm


Return to BigDB



cron