Page 1 of 1

SaveItem Errors

Posted: Mon Sep 06, 2010 1:34 am
by ratface
SaveItem consistently bugs out, and I'm not entirely sure why -- well I am, but not sure what's causing it.
Compiled from the SVN release I grabbed a few days ago.

Looking at the SQL query, it seems to be putting some very large number in the item_id section of the query.. An item that doesn't exist. In turn that's bugging it out due to the SQL server trying to make the connection with that item_id and the items table and finding nothing.
Any thoughts?

Re: SaveItem Errors

Posted: Mon Sep 06, 2010 12:12 pm
by John Adams
`item_id` is the foreign key that links `items` to all the other `item_*` tables, and to places like character_items or loot tables. If the ID is not something less-than 500,000 or so, then it is not a valid item_id, and that likely means the structures are off... which, they shouldn't be because Items haven't changed in 2 years as far as that field goes.

Without the exact error or procedure how to duplicate the bug, there's no way to know what's actually going on.

Re: SaveItem Errors

Posted: Mon Sep 06, 2010 4:14 pm
by ratface
I'll post the error here in a few, going to grab some food first.
The item_id it's tossing in the field is definitely > 500,000.

edit:

Code: Select all

[20100906 16:19:06] [Error] Error in SaveItem query 'replace into character_items (id, type, char_id, slot, item_id, creator, condition_, attuned, bag_id, count, max_sell_value, account_id) values(427, 'NOT-EQUIPPED', 1, 0, 42262478195290, '', 100, 0, -4294967265, 1, 18446744069414584320, 6023)': #1452: Cannot add or update a child row: a foreign key constraint fails (`eq2world`.`character_items`, CONSTRAINT `FK_char_items` FOREIGN KEY (`item_id`) REFERENCES `items` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)
[20100906 16:20:06] [Error] Error in SaveItem query 'replace into character_items (id, type, char_id, slot, item_id, creator, condition_, attuned, bag_id, count, max_sell_value, account_id) values(428, 'NOT-EQUIPPED', 1, 1, 42262478293240, '', 100, 0, -4294967265, 1, 18446744069414584320, 6023)': #1452: Cannot add or update a child row: a foreign key constraint fails (`eq2world`.`character_items`, CONSTRAINT `FK_char_items` FOREIGN KEY (`item_id`) REFERENCES `items` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)
[20100906 16:20:06] [Error] Error in SaveItem query 'replace into character_items (id, type, char_id, slot, item_id, creator, condition_, attuned, bag_id, count, max_sell_value, account_id) values(429, 'NOT-EQUIPPED', 1, 2, 42262478193640, '', 100, 0, -4294967265, 1, 18446744069414584320, 6023)': #1452: Cannot add or update a child row: a foreign key constraint fails (`eq2world`.`character_items`, CONSTRAINT `FK_char_items` FOREIGN KEY (`item_id`) REFERENCES `items` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)
Three different items. The original ids were I believe 1000, 100600 and maybe 10000 or something. Typed them randomly. I figured it was the screwed up item_id value. There must be a file or something screwed up from what I grabbed.

For procedure.. was simply: /giveitem Peak 1000 or 100600 or whatever random ID I thought up, and then waiting for the errors to show up shortly after. Works every time! =)

Grabbed the latest svn code to be sure, recompiled it.. Grabbed the struct files from the svn as well. Same thing even after a recompile.

Re: SaveItem Errors

Posted: Mon Sep 06, 2010 9:11 pm
by Scatman
ratface. peak. from nagafen?

Re: SaveItem Errors

Posted: Mon Sep 06, 2010 9:13 pm
by Scatman
Are these items coming down from the update server? Or your own?

Re: SaveItem Errors

Posted: Mon Sep 06, 2010 9:52 pm
by Zcoretri
ratface wrote: For procedure.. was simply: /giveitem Peak 1000 or 100600 or whatever random ID I thought up, and then waiting for the errors to show up shortly after. Works every time! =)
Would be better if you gave us some real id numbers you used in /giveitem that produce the error ... don't have the time to randomly input over 114K worth of items, because I did not get any errors.

Re: SaveItem Errors

Posted: Tue Sep 07, 2010 3:12 am
by John Adams
Yeah "42262478195290" is definitely not a valid item_id by our standards. We do store the SOE_ID, which is a signed int(10), but it is not used by us for anything - only referencing for updating items from SOE data.

Are you using our ServerPack + Database release, or something else?


Zcoretri, you can see there may be a structs issue here, because the values being sent are totally whacked:
  • id = 427 (correct)
    type = 'NOT-EQUIPPED' (correct)
    char_id = 1 (correct)
    slot = 0 (correct)
    item_id = 42262478195290 (incorrect)
    creator = '' (correct)
    condition_ = 100 (correct)
    attuned = 0 (correct)
    bag_id = -4294967265 (incorrect)
    count = 1 (correct)
    max_sell_value = 18446744069414584320 (incorrect)
    account_id = 6023 (correct)

Re: SaveItem Errors

Posted: Tue Sep 07, 2010 3:13 am
by John Adams
Scatman wrote:ratface. peak. from nagafen?
Scat! No picking fights with fellow PVPers! I know how your ePeenurz work ;)

Re: SaveItem Errors

Posted: Tue Sep 07, 2010 4:06 am
by ratface
John Adams wrote:Yeah "42262478195290" is definitely not a valid item_id by our standards. We do store the SOE_ID, which is a signed int(10), but it is not used by us for anything - only referencing for updating items from SOE data.

Are you using our ServerPack + Database release, or something else?


Zcoretri, you can see there may be a structs issue here, because the values being sent are totally whacked:
  • id = 427 (correct)
    type = 'NOT-EQUIPPED' (correct)
    char_id = 1 (correct)
    slot = 0 (correct)
    item_id = 42262478195290 (incorrect)
    creator = '' (correct)
    condition_ = 100 (correct)
    attuned = 0 (correct)
    bag_id = -4294967265 (incorrect)
    count = 1 (correct)
    max_sell_value = 18446744069414584320 (incorrect)
    account_id = 6023 (correct)
I had to grab the source from the svn so I could compile on Ubuntu, since the only thing included with the Server Pack release was Windows binaries. The struct files I'm using are also from the svn. The database was the one released in your thread here.

Everything works up until saving from what I can see. The items are given to me properly, equip properly, damage works properly (in the case of weapons), it's just saving that's the issue.. So as soon as I zone or camp out, the items are gone.

As for the actual item IDs, it doesn't matter what ID I use. Whether it's an item that came in the database release or something I added myself, it still has the same result with SaveItem, although with a slightly different (but still very large) item_id value.
Scatman wrote:ratface. peak. from nagafen?
Yes. Who are you? Or can I take the "Chuglet" part of your mybrute to mean you're Chuglet?

Re: SaveItem Errors

Posted: Tue Sep 07, 2010 5:33 am
by Zcoretri
John Adams wrote:Yeah "42262478195290" is definitely not a valid item_id by our standards. We do store the SOE_ID, which is a signed int(10), but it is not used by us for anything - only referencing for updating items from SOE data.

Are you using our ServerPack + Database release, or something else?


Zcoretri, you can see there may be a structs issue here, because the values being sent are totally whacked:
  • id = 427 (correct)
    type = 'NOT-EQUIPPED' (correct)
    char_id = 1 (correct)
    slot = 0 (correct)
    item_id = 42262478195290 (incorrect)
    creator = '' (correct)
    condition_ = 100 (correct)
    attuned = 0 (correct)
    bag_id = -4294967265 (incorrect)
    count = 1 (correct)
    max_sell_value = 18446744069414584320 (incorrect)
    account_id = 6023 (correct)

I don't think it is a structs issue, because no structs are involved in saving to the database...structs are for moving data to and from the client.

EDIT:
Here is a dump of my character_items table after giving items...I zoned and then camped. All items were still there.

Code: Select all

`character_items` (`id`, `type`, `account_id`, `char_id`, `bag_id`, `slot`, `item_id`, `creator`, `condition_`, `attuned`, `count`, `max_sell_value`)
   (558, 'NOT-EQUIPPED', 1, 1, 1, 0, 1000, '', 100, 0, 1, 0),
	(747, 'EQUIPPED', 1, 1, 0, 7, 38528, '', 100, 0, 1, 0),
	(753, 'NOT-EQUIPPED', 1, 1, 0, 1, 3586, '', 100, 0, 1, 0),
	(754, 'EQUIPPED', 1, 1, 0, 3, 20083, '', 100, 0, 1, 0),
	(756, 'EQUIPPED', 1, 1, 0, 8, 20080, '', 100, 0, 1, 0),
	(761, 'NOT-EQUIPPED', 1, 1, 1, 1, 38528, '', 100, 0, 1, 0),
	(767, 'NOT-EQUIPPED', 1, 1, 0, 3, 5309, '', 100, 0, 1, 0);
I did however have an issue of some items disappearing when I moved them between bags...so that probably is a seperate issue that needs looked at.

Re: SaveItem Errors

Posted: Wed Sep 08, 2010 2:13 am
by Scatman
Yep :) Welcome bud! I'll take a look at your problemo once I get back from vacation if they haven't figured out anything.

Re: SaveItem Errors

Posted: Wed Sep 08, 2010 4:48 am
by ratface
Sounds great. I'm familiar with C++ (not that different from PHP either, which is what I'm best at), just not familiar with the project/code at all so wouldn't know where to start for diagnosing this problem.

Re: SaveItem Errors

Posted: Wed Sep 08, 2010 6:43 am
by John Adams
If it were me, I would probably toss a break point in WorldDatabase::SaveItem(...) and wait for an item to get saved, and then look at the values being passed into the function. Trace backwards from there to see why item_id is so wonky.

Best way to get familiar is to dive in with both feets ;)

Re: SaveItem Errors

Posted: Wed Sep 08, 2010 4:57 pm
by ratface
Strangely, running gdb and printing out the values from the Item variable (item->GetMaxSellValue(), item->details.item_id) actually returns the correct values during the SaveItem function.