Go Back   EQEmulator Home > EQEmulator Forums > Support > Support::General Support

Support::General Support Post all topics here having to do with errors while trying to connect to an EQEMu server but not about the setup/running of the Server itself.

Reply
 
Thread Tools Display Modes
  #1  
Old 07-18-2014, 03:53 PM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default Pet losing some - not all - his gear

Had the same pet for at least a week. He has 7 pieces of rawhide armor. Every couple of days, the bp and legs disaappear. Anyone know where in the code this stuff gets updated? I look at the table and it has what I expect.. At some point, no idea when, he loses the bp and legs (not in table anymre). Really weird, Maybe an issue when loggin in and loading pet?

[ I see where it gets loaded and saved - that code looks fine. Will instrument it, but don't expect the problem to be there. ]
Reply With Quote
  #2  
Old 07-18-2014, 08:35 PM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

Usually, a code problem like that will manifest itself every time.

You might try looking at all of your logs (emu server, mysql, etc...) to see if you are having write issues. A write failure would case items to 'randomly' disappear.


I am working through inventory code atm..so, I'll keep an eye out for anything that might be wonky.
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote
  #3  
Old 07-18-2014, 08:38 PM
provocating's Avatar
provocating
Demi-God
 
Join Date: Nov 2007
Posts: 2,175
Default

No rent items? Nevermind just read where you said it was rawhide.
Reply With Quote
  #4  
Old 07-18-2014, 09:30 PM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

No rent typically disappear after 30 minutes offline..I don't even know if pets check for that.
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote
  #5  
Old 07-18-2014, 09:44 PM
provocating's Avatar
provocating
Demi-God
 
Join Date: Nov 2007
Posts: 2,175
Default

Quote:
Originally Posted by Uleat View Post
No rent typically disappear after 30 minutes offline..I don't even know if pets check for that.
I know, I missed that when I read his post.
Reply With Quote
  #6  
Old 07-22-2014, 09:39 AM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default

From further testing, it looks like the database is fine after the items are lost in game. The db only gets messed up after you log out of the client, and the corrupted pet inventory gets written back out. So, the loss of items seems to be on zoning, and in memory.

I'm going to focus on that today and see what I can find.
Reply With Quote
  #7  
Old 07-22-2014, 10:05 AM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default

Gave pet 12 items. Logged out to update db.

Logged back in and then zoned 9 times. On the 9th time only the 1st 5 items survived when I did a #showstats. The exact 1st 5 items, so the list got truncated. I'm guessing a race condition that didn't let the list get filled in, or perhaps somehow that process got interrupted?

This narrows the repeat process to logging in and zoning alot. I was the only one on the server at the time as well.
Reply With Quote
  #8  
Old 07-22-2014, 10:11 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

I want to say I experienced this bug myself when I was somewhat actively running Akka's Funhouse.

It is probably an initialization issue when entering the zone.
Reply With Quote
  #9  
Old 07-22-2014, 11:29 AM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default

Looking for some feedback on what I am seeing.

I don't see where we're corrupting yet, but I find this odd.

Instrumentation:

- I have log messages in ~NPC and in the spot where the pet gets his gear restored.

Steps:

- Fresh server restart
- Login with existing pet to zone 1.
- I see the pet gear restore loop run fine.
- #zone to zone 2
- I see the pet gear restore loop run fine.
- #zone to zone 1 again.
- The process for zone1 hits the ~NPC code for the pet
- I see the pet gear restore fine after this.

Isn't it odd that the ~NPC code for the pet runs when I reenter the original zone and not when I leave one?
Reply With Quote
  #10  
Old 07-22-2014, 01:48 PM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default

I think I have found the issue... information as soon as I verify the fix....
Reply With Quote
  #11  
Old 07-22-2014, 02:06 PM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default

Ok....

It looks like the zone you are leaving stores the pets inventory into the DB using a loop of inserts. The zone you are entering retrieves the list with a single select.

Sometimes, depending on how fast you zone and how many items are in the pets inventory list, the receiving zone does the select before the sending zone has finished putting the items in.

I added a LOCK TABLES character_pet_inventory WRITE on the side saving the data, along with a release after the loop of inserts. I then added a LOCK TABLES READ on the destination zone's code to reload the data with the select.

I zoned 25 times and it has not failed with 12 pet items. That's never happened for me before, so I think that got it.

I'll post the code after a week or so of testing.
Reply With Quote
  #12  
Old 07-22-2014, 03:05 PM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default

Patch code below:

Code:
***************
*** 2440,2459 ****
--- 2440,2464 ----
  				errbuf);
  			safe_delete_array(query);
  		}
  	}
  
+ 	database.RunQuery(query, MakeAnyLenString(&query, "LOCK TABLES `character_pet_inventory` WRITE", errbuf));
+ 	printf(errbuf);
+ 
  	for(i=0; i<MAX_WORN_INVENTORY; i++) {
  		if(petinfo->Items[i]) {
  			database.RunQuery(query, MakeAnyLenString(&query,
  				"INSERT INTO `character_pet_inventory` (`char_id`, `pet`, `slot`, `item_id`) values (%u, 0, %u, %u)",
  				c->CharacterID(), i, petinfo->Items[i]), errbuf);
  			// should check for errors
  			safe_delete_array(query);
  		}
  	}
  
+ 	database.RunQuery(query, MakeAnyLenString(&query,"UNLOCK TABLES", errbuf));
+ 	printf(errbuf);
  	
  	if(!database.RunQuery(query, MakeAnyLenString(&query,
  		"INSERT INTO `character_pet_info` (`char_id`, `pet`, `petname`, `petpower`, `spell_id`, `hp`, `mana`) "
  		"values (%u, 1, '%s', %u, %u, %u, %u) "
  		"ON DUPLICATE KEY UPDATE `petname`='%s', `petpower`=%i, `spell_id`=%u, `hp`=%u, `mana`=%u",
***************
*** 2581,2590 ****
--- 2586,2598 ----
  		LogFile->write(EQEMuLog::Error, "Error in LoadPetInfo query '%s': %s", query, errbuf);
  		safe_delete_array(query);
          return;
  	}
  
+ 	database.RunQuery(query, MakeAnyLenString(&query, "LOCK TABLES `character_pet_inventory` WRITE", errbuf));
+ 	printf(errbuf);
+ 
  	if (database.RunQuery(query, MakeAnyLenString(&query,
  		"SELECT `pet`, `slot`, `item_id` FROM `character_pet_inventory` WHERE `char_id`=%u",
  		c->CharacterID()), errbuf, &result))
  	{
  		safe_delete_array(query);
***************
*** 2608,2614 ****
--- 2616,2625 ----
  	else {
  		LogFile->write(EQEMuLog::Error, "Error in LoadPetInfo query '%s': %s", query, errbuf);
  		safe_delete_array(query);
          	return;
  	}
+ 	// Unlock the character_pet_inventory table so people can read
+ 	database.RunQuery(query, MakeAnyLenString(&query, "UNLOCK TABLES",errbuf));
+ 	printf(errbuf);
  
  }
Reply With Quote
  #13  
Old 07-22-2014, 05:17 PM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default

Fixed my problem but created other issues for other clients in the same zone....

My unlock is messing with other tables - apparantly no way to unlock just the one table..

Working on a cleaner solution using a mutex.
Reply With Quote
  #14  
Old 07-22-2014, 06:04 PM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default

Ok, this is deeper into the infrastructure than I've messed with.

The idea of locking/unlocking the tables isn't going to work as unlock always releases all tables, and there is other code executing for other clients in the same zone process that locks tables.. So I can't use that method.

A simple mutex is out, as I'm on linux and mutexes don't cross processes without shared memory.

So, I'm guessing a semaphore.. In that case I need to know where all the zone processes are forked, so I can create the semaphore before the zones are forked off.

Or - is there a better way being used already to make sure that 2 zone processes get synbcronized?
Reply With Quote
  #15  
Old 07-22-2014, 09:14 PM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

I've seen a few crash dumps involving pets..I wonder if this is related...
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 07:29 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3