buttilda / Headcrumbs

Headcrumbs
aww yiss
14 stars 21 forks source link

User Cache UUID issue #11

Closed jadedcat closed 10 years ago

jadedcat commented 10 years ago

https://www.dropbox.com/s/04y2abtj22i9acv/usercache.json?dl=0

appears to be causing this:

http://pastebin.com/7BDPFhXh in Mage Quest for some users.

removing :"PurpleMentat","uuid":"848d057b-854a-4c89-bf45-74271b70e036","expiresOn":"2014-11-06 23:40:01 -0800"}] seems to fix it for some people.

Forum thread for topic:

http://forum.feed-the-beast.com/threads/ftb-mage-quest-alpha-bug-reports.51204/page-2#post-785444

buttilda commented 10 years ago

So the problem is: Since this mod has to download several skins at the same time, I thread the download, so basically the server downloads all the skins at the same time, instead of downloading one by one and lagging out in the process (Try placing a vanilla skull that has a skin and you'll notice that the server stops for almost half a second whilst it's downloading the skin).

The problem happened because the usercache file is written to every time a skin is downloaded. So... the file was being written to concurrently several times. Which in rare occasions caused overrides in parts of the file which made it corrupt. When relaunching the game the server tries to read the file, fails and blows up in the process.

I'm working on a fix to either make sure the file is not being written one by more than one thread at the same time, or, check if the file is corrupt during loading and deleting it if that's the case. Since the usercache is not an important file (all it does it save the server the hassle of having to query the skin servers every time it launches) even if corruptions happen from time to time, having it reset will only cause the server to have to re-download everything, which I'm fine with.

Unfortunately I'm about to get on an airplane that will fly across half the planet, so the fix might take a day or two, maybe more. Sorry about that )=

buttilda commented 10 years ago

How I (hopefully) fixed it:

Headcrumbs will read the usercache.json file before minecraft does and if it finds anything corrupt it will delete the file, forcing minecraft to create a new blank one. As I previously said, this shouldn't affect the users as all it will do is force minecraft to re-query the servers for the users UUIDs.

mjevans commented 9 years ago

This is where you should be using some form of message passing construct to have a single writer thread and append to it's work queue (which is where the thread synchronization is implemented).

buttilda commented 9 years ago

I'm not the one who writes the usercache file so I can't change the way it's written (well, I could coremod it, but I'd rather not)