Ok...
I added a named semaphore and created it in eqlaunch before anything else. Then I use it to access the pet inventory in the functions in zonedb.cpp. It seems to me this is: 1) a bigger issue - since the zone I am leaving doesn't other work in Save() before the zone I land in starts accessing it.. or 2) Somehow another mechanism was meant to handle this and isn't for pet inventory. I can show, so far, that without my fix, the zone I land in can read the content of the character_pet_inventory table before the zone I am leaving has it completely updated... thus the problem. This is all on my Linux server. I can post the named semaphore fix, but I'm not happy with it and I'm hoping someone more knowledgeable with how the old zone and new zone get ordered might step in and slap me up some ;) |
My solution has evolved to a named semaphore in the client class. This semaphore is named after the character_id for the client. It is created on successful arrival in a zone (if you're coming from another zone, the CREAT ends up opening the one you left from (if its in use). There can, of course be multiple semaphores going on at once, for various characters, but they will clean themselves up on logout.
It's used when you save and read pet information. It works, and I leave no semaphores around on exit. I still feel that someone with a better idea of how db coordination is done between zones on zoning might have a more straightforward fix - or maybe tweak of existing mechanism. Should I post about it on development? My fix works, but I'd think a patch more in tune with the original thought process might be better long term. I just can't see what that is.. :) [ edit: expanded the critical section to start when the zoning flag is set and to end at client's destructor. The new zone now has perfect pet data. I also moved my check on the new zone to before we read in character buffs - with the wrong timing - these could get scrogged as well. With 15 items, I could make the pet bug show up alot - and now its always perfect, And no semaphore baggage, all cleaned up.] Let me know if you guys want the patch posted. My code is older, but I think the changes are small enough you can fit them in if you want them. Players happy - they were sick of losing pet gear occasionally. ] |
My fix works. No more pet gear lost. You guys want it? I don't mind posting the details.
|
Quote:
|
Looks like you have lots to contribute- it would be way easier for the dev's to integrate your changes if you forked the source on github ( https://github.com/EQEmu/Server ), made the change and then submitted a pull request.
|
I was really hoping that one of the core guys would pick this up, if it is going to be useful to the community. My fix works fine for my server (we have less than 20 players). Since it involved the use of a named semaphore, I'm loath to apply a diff to a branch and have someone just roll that in. For player bases that are more normal (I assume much larger than mine), Im worried that abnormal aborts, etc, might require semaphore cleanup and server restarts.
I've not run into that yet, but it seems inevitable. So why did I bother posting? I guess I wanted to point the race condition on zoning and hope that someone more core to the project might have a better idea for the mainstream solution. As an interim step, I'll post my diffs here. |
I believe this is all the diffs. My code is divergent from the base, but this should give context and intent. Basically, I'm grabbing a named semaphore in the instance of client in the zone process when we zone and not releasing it until all pertinent data is saved. The recipient zone tries to grab the same semaphore, which ends up delaying the recipient in cases where saving had not finished yet. I've seen it delay, and solve the pet gear issue. The code in the zone error functions are to release the semaphore in the originating zone if the zoning process is blocked in some way (flags, etc). Note there is a diff semaphore per char id, so multiple zoning clients don't slow each other down.
My fear, is other hard crashes after the zoning client grabs the sem, but before it is released. Also note, we close/delete the sem on both sides, all the time, to avoid issues with leftover semaphores. Its temping to leave the sem there for future zoning, but the dynamic state of things makes that very risky. Tons of printfs left in the code so you can test. Remove as you see fit. Code:
=== modified file 'zone/zoning.cpp' |
This is still working for me after weeks. Again, I have less than 10 players, so a large playerbase might be an issue if crashes end up leaving the named sem around. Pet gear loss completely fixed however, and it safeguards against other data loss as well.
|
All times are GMT -4. The time now is 01:46 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.