Jump to content
  • 0

I have a strange issue with the server not successfully saving all of the Player's information.


Daywalkr

Question

Hello. I was ready to release to alpha in the next few days, but a really game-breaking bug has made its way into my intersect stack. I really wish I knew how to cause it - it seems to happen completely at random. I will provide a diffy at the end of this post, and even would happily supply my server, client, and editor to anyone who would like to help me out. I'm at my wits end here.

 

I noticed a while ago that my intersect server was NOT saving correctly. I'd log in and be in a completely different place, with completely different items, than I had when I last logged out. BUT, it wasn't even as if I was simply set back to a previous save, because importantly, SOME properties would save (player variables and quest statuses most of the time). As you can imagine, this destroys the game completely that, at this point, I've spent 5 months or so on?

 

Specifically, the following things tend to not save correctly, that I've noticed:

 

- Inventory

- Map position

- Quest Status

- Player Variables

- Level & Exp

 

But not always the same stuff.

 

Some examples:
- Consider some quest where I'm given a key to unlock some door. After giving the key, a player variable is set to true so the key won't be given again. If the bug occurs after doing the bit where I unlock some door (reliant on some player var), I could be in a state where I've USED my key, but the player variables have reset - the door is locked, but my quest status updated such that the quest giver won't give me a key anymore. Because not every bit of player data was saved.

- Another example, that seems even stranger, is the one that made me post here. I was testing my game on my prod host, as I was going to release alpha tomorrow. I logged in to discover, to my horror, that the bug was affecting my prod server as well - I noticed because all of the copper in my inventory was gone - but a stackable item I was accumulating while mining the copper was still there!

 

Here's a diffy of my source changes since I first noticed the bug. I've made a few, but nothing too heavy. I realize this is a lot to look at, but I figure I may as well include it in case anyone takes special interest: https://diffy.org

/diff/e15db23591a7

 

The most suspicious bit of code I've introduced would be here: https://github.com/AscensionGameDev/Intersect-Engine/pull/811/files

 

Otherwise, the biggest thing I'm asking for is does anyone have any suggestions as to how I can start debugging this? As mentioned previously, I have spent months on this project. I think I did a good job. I want to share it with people. But it can NOT be played in this state, and that really sucks.

 

I suspect a good place to debug would be wherever the code lies that is updating the playerDB - but I'm having trouble finding where that is and, if it's where I think it is (Server -> PlayerData -> User), then I'm having a really hard time figuring out what it's doing, and would love help.

 

I have seen this bug occur both in a SQLite PlayerDB and a MySql DB

 

 

I also have never seen any suspicious logging in my server.

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

I don't know exactly but you could start by checking if there is any PlayerData migration pending. Start by making an upgrade.

Also, check server logs searching for any evidence about database errors that can help us to figure out whats happening.

At last, try to set breaking points at saving player lines to check if everything is working ok. And use SQLite manager to check if only specific tables are not being saved.

We can get more info about the issue this way.

Just a question, it works okay this whole time? Do you know where the problem start to happening? I mean because there is an deleted migration at your diffy and thats a little strange, dont know if EF got problems with that.

Link to comment
Share on other sites

  • 0

I don't remember seeing this issue till around the time I implemented the changes mentioned in the OP.

 

Where does the saving of the player take place? I'd love to have DENSE logging in there, but I can't really find where I should be adding anything.

Link to comment
Share on other sites

  • 0

I have had it happen again. This time was after some heavy editing on my localhost.

 

I had 6000 gold coins in my inventory - throughout the editing process, I ended with around 6800. Logged out closed the server. Opened it back up and I was standing in an older spawn than I left off at, without the coins but with the player variables flipped.

 

I really think I need to know WHERE the iteration through player tables happens, because it very clearly seems to be a problem where only SOME tables are updated, but not all. I would very much prefer if ANY table fails an update, we don't update any... but I can't think of any way you could design around that.

 

Link to comment
Share on other sites

  • 0
context.ChangeTracker.DetectChanges();


I also see this - I wonder if maybe the problem is that _some_ changes aren't being detected?

The problem is if I try to find the def of this method it just takes me to a virtual function :P I can't find its implementation anywhere?

Link to comment
Share on other sites

  • 0

That's part of the Entity framework and if it were an issue it would be an issue for everyone. 

 

As I've said on discord, are you sure you're not somehow cloning your player entities on the server and accidently decoupling them from the database layer by doing so? 

 

Try to play without ever using your warp changes or undo changes slowly in your git history to see where it starts. (just make backups of your databases before you do for safe keeping) 

Link to comment
Share on other sites

  • 0
15 hours ago, Cheshire said:

That's part of the Entity framework and if it were an issue it would be an issue for everyone. 

 

As I've said on discord, are you sure you're not somehow cloning your player entities on the server and accidently decoupling them from the database layer by doing so? 

 

Try to play without ever using your warp changes or undo changes slowly in your git history to see where it starts. (just make backups of your databases before you do for safe keeping) 

context.ChangeTracker.DetectChanges();


I've been playing without my warp changes for a bit now, and did eventually have the issue again. Something you and Kas mentioned in the Discord, however, that is now gaining suspicion is that almost always, I am logged into the editor and the client with the same account.

 

When I am making new content, I normally just pull open the editor and client, and just test changes live in the client. Normally, after any particularly involved sessions, I will log in, say, the next day (fresh server start as well), and find that this bug has occured. That seems to potentially lead credence to your theory of the DB potentially getting confused, as I'm logged in as the same player in two places.

 

 

Just for anyone that hasn't seen the discord stuffs - basically Ches suggested to just... not do that anymore, and see if the problems continue to arise. As I said in the OP, I've seen a very similar problem with items disappearing happen in my other server - but not without me potentially having screwed with the game database during that session.

 

SO, I'm just gonna use my coming playtests as a time to just see if this happens when I'm not constantly messing with databases through the editor. I'll keep this topic updated if I notice it continue to happen even then.

Link to comment
Share on other sites

  • 0

UPDATE:

Since switching to use an alternate account for the editor, I have not seen this problem happen again. Definitely a suspicious lead there - but ultimately, if that IS the issue, perhaps the best fix is just to prevent that from being an option (simultaneous login)? Especially since it's been so hard to make something reproducable.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...