database maintenance
Posted: Mon Jun 29, 2009 10:33 pm
gave me great joy to see the updated IdFactory.java. thank you very much. 

Why?janiii wrote:..and i was bitched up that i commited it..
Lol, it's not like it adds THAT much more to the routines. Just a few missing ones. Besides, the first time they're cleaned out will take the longest. After that any future cleanups will be nearly instant. Better to have a clean database and wait a few more minutes on ONE restart than have a dirty DB.MELERIX wrote:cos DS say that in a db ~100-150mb cleanup become ~10min...
but for me this contribution is fine, and janiii are not doing nothing bad.
Maybe if you had told me initially when we had the old forum thread going OR when i reposted it to the new forums. BUT YOU DIDN'T SAY A THING. I could've optimized that had you mentioned it._DS_ wrote:(SELECT object_id FROM items) now done twice.
Again, you didn't say anything, no one did. And whoops, ONE mistake._DS_ wrote:Clan notices cleanup done twice.
Old code:_DS_ wrote:And last, but not least:
stmt.executeUpdate("UPDATE characters SET clanid=0, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0, clan_join_expiry_time=0, clan_create_expiry_time=0 WHERE characters.clanid NOT IN (SELECT clan_id FROM clan_data);");
Question: is clan id 0 in the clan_data ?![]()
Conclusion: you see yourself.
Code: Select all
stmt.executeUpdate("UPDATE characters SET clanid=0 WHERE characters.clanid NOT IN (SELECT clan_id FROM clan_data);");
Code: Select all
Index: D:/Documents/L2J/L2_GameServer/java/net/sf/l2j/gameserver/idfactory/IdFactory.java===================================================================--- D:/Documents/L2J/L2_GameServer/java/net/sf/l2j/gameserver/idfactory/IdFactory.java (revision 3244)+++ D:/Documents/L2J/L2_GameServer/java/net/sf/l2j/gameserver/idfactory/IdFactory.java (working copy)@@ -202,7 +202,6 @@ cleanCount += stmt.executeUpdate("DELETE FROM clanhall_functions WHERE clanhall_functions.hall_id NOT IN (SELECT id FROM clanhall WHERE ownerId <> 0);"); cleanCount += stmt.executeUpdate("DELETE FROM siege_clans WHERE siege_clans.clan_id NOT IN (SELECT clan_id FROM clan_data);"); cleanCount += stmt.executeUpdate("DELETE FROM clan_notices WHERE clan_notices.clan_id NOT IN (SELECT clan_id FROM clan_data);");- cleanCount += stmt.executeUpdate("DELETE FROM clan_notices WHERE clan_notices.clan_id NOT IN (SELECT clan_id FROM clan_data);"); cleanCount += stmt.executeUpdate("DELETE FROM auction_bid WHERE auction_bid.bidderId NOT IN (SELECT clan_id FROM clan_data);"); //Untested, leaving commented out until confirmation that it's safe/works properly. Was initially removed because of a bug. Search for idfactory.java changes in the trac for further info. //cleanCount += stmt.executeUpdate("DELETE FROM auction WHERE auction.id IN (SELECT id FROM clanhall WHERE ownerId <> 0) AND auction.sellerId=0;");@@ -217,7 +216,7 @@ stmt.executeUpdate("UPDATE clan_data SET auction_bid_at = 0 WHERE auction_bid_at NOT IN (SELECT auctionId FROM auction_bid);"); stmt.executeUpdate("UPDATE clan_subpledges SET leader_id=0 WHERE clan_subpledges.leader_id NOT IN (SELECT charId FROM characters) AND leader_id > 0;"); stmt.executeUpdate("UPDATE castle SET taxpercent=0 WHERE castle.id NOT IN (SELECT hasCastle FROM clan_data);");- stmt.executeUpdate("UPDATE characters SET clanid=0, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0, clan_join_expiry_time=0, clan_create_expiry_time=0 WHERE characters.clanid NOT IN (SELECT clan_id FROM clan_data);");+ stmt.executeUpdate("UPDATE characters SET clanid=0, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0, clan_join_expiry_time=0, clan_create_expiry_time=0 WHERE characters.clanid > 0 AND characters.clanid NOT IN (SELECT clan_id FROM clan_data);"); stmt.executeUpdate("UPDATE clanhall SET ownerId=0, paidUntil=0, paid=0 WHERE clanhall.ownerId NOT IN (SELECT clan_id FROM clan_data);"); stmt.close();
Code: Select all
stmt.executeUpdate("UPDATE characters SET clanid=0 WHERE characters.clanid NOT IN (SELECT clan_id FROM clan_data);");
SET clanid=0 does not broke expiry times and does not allow player immediately join clan after restart. I think what after some thinking another underwater stones can be found._DS_ wrote:[quote="toastgodsupreme"Old code:Conclusion: It was fucked before I touched it, I just made sure other things got fixed aside from just the clanid. Don't fucking point fingers at me when I didn't mess it up, I merely expanded on what was already there.Code: Select all
stmt.executeUpdate("UPDATE characters SET clanid=0 WHERE characters.clanid NOT IN (SELECT clan_id FROM clan_data);");
Original code reset expiry timers because clanid 0 does not exist in the clan_data, so query affect all clanless people.toastgodsupreme wrote:I LOVE how you jump from one reason to the next to hate on it.![]()
Wow. First it was because clanid 0 didn't exist in clan data. Now it's because my original code reset expiry timers, oh but wait, I believe the solution i posted resolves that matter to! LORDY LORDY two fixes in one!!!
so why YOU didn't report YOUR test results?_DS_ wrote:Last question: why i am found this issue after 2 hours from installing on live, and no one, including author of the contrib, does not found and fix this bug before ? Answer: because no one bother to test it.