collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Migrated bot, unable to run.  (Read 4800 times)

0 Members and 1 Guest are viewing this topic.

Offline Dochere

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Migrated bot, unable to run.
« on: February 26, 2010, 10:50:00 am »
Hey!


Moved my bots to another server, from Debian to CentOS, having a few odd problems. (i have ran bot on a Windows server, so Debian system should not be the problem)


PHP version 5.2.10
MySQL version 5.0.77


My first error though is:
Code: [Select]
PHP Notice:  Undefined offset:  1 in /home/bot//Sources/Conf.php on line 47
PHP Notice:  Undefined property: Conf::$cf in /home/bot/Sources/Conf.php on line 70
PHP Notice:  Undefined offset:  1 in /home//bot/StartBot.php on line 85
PHP Notice:  Undefined variable: pw in /home/bot/StartBot.php on line 111

Secondly i get this:
Code: [Select]
AOChat: Authentication failed: Challenge failed

The second one is "easily" fixed by removing slave bots, i use Temar's slave module. But more about second bug, could it be firewall not allowing more then 1 outgoing connection? or PHP not allowing more then 1 connection?



Third error is kinda weird, loops through all members deleting every one:
Code: [Select]
bot [ROSTER]  [ERASE] Erasing PLAYERNAME as the character appears to have been rerolled. Old: -1613495546 New: 2683471750

You see the first value is -num and second is a positive value, some way php calculate integer overflow?

Quote
Be very careful with code that relies on integer overflow. Negative overflow is handled differently on different platforms.



All input appreciated.
« Last Edit: February 26, 2010, 11:07:59 am by Dochere »

Offline Dochere

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Re: Migrated bot, unable to run.
« Reply #1 on: February 26, 2010, 11:09:45 am »
Easily enough i can convert all user id's since integer overflow was calculated in different ways depending on OS. (how silly is that)

Or does anyone know of any tricks?

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Migrated bot, unable to run.
« Reply #2 on: February 26, 2010, 01:20:25 pm »
For your first error my question would be which version of the bot are you running? If memory serves I fixed those warnings in some of the later 0.6 releases.

The second error could be any number of reasons. If the bot successfully connects, but the slaves does not I would suspect that there is either some issue with the slave code, or you are being blocked by Funcom for trying to connect too quickly or too many connections etc. There is really no easy way to say for sure.

Your third error is caused by how we choose to deal with overflowed 32bit integers back when it first became an issue. Since php offers no support for 64bit integers on 32bit compiles, they will overflow and become negative. They do however remain unique, and as such it was decided at the time to just let them overflow.

This however causes the issue you witness when you move your database from a 32bit PHP enviroment to a 64bit PHP enviroment, as now all of a sudden PHP is able to handle the larger integer values correctly, creating a mismatch.

The complication of course becomes that the actual size of integers can differ between platforms, so the exact value the overflow occurs on can differ, and thus also calculating the correct id's.

Fortunately one can usually assume that all id's in a database was overflowed the same way. The simplest way to fix it however would likely be to write a script that pulls all members from the database, loop trough them and looks up their correct ID and just replace the ID in the database.
BeBot Founder and Fixer Kingpin

Offline Dochere

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Re: Migrated bot, unable to run.
« Reply #3 on: February 26, 2010, 01:43:24 pm »
Heres the beginning of the integer fix:

Code: [Select]
        function get_uid($user)
        {
                if(empty($user))
                {
                        $this->error->set('No user specified');
                        // TODO: adapt all calls to get_uid() to check for instanceof BotError?
                        // return($this->error);
                        return false;
                }

                //Attempt to get uid from FC (This fails randomly)
                $uid = $this -> bot -> aoc -> get_uid($user);

                //When it fails attempt to get it from the cache.
                if($uid === false)
                {
                        $db_uid = $this -> bot -> db -> select("SELECT ID FROM #___whois WHERE nickname = '" . $user . "' LIMIT 1", MYSQL_ASSOC);

                        if (!empty($db_uid))
                        {
                                $uid = $db_uid[0]['ID'];
                        }
                        else
                        {
                                $this -> error -> set("I was unable to get the user id for user: '$user'");
                                // TODO: adapt all calls to get_uid() to check for instanceof BotError?
                                // return($this->error);
                                return false;
                        }
                }


                if ($uid > (float)2147483647)
                        return $uid - (float)"4294967296";

                return $uid;

        }


small fixes still needed to make it not return values when the inital check fails.
« Last Edit: February 26, 2010, 02:13:42 pm by Dochere »

Offline Dochere

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Re: Migrated bot, unable to run.
« Reply #4 on: March 01, 2010, 10:20:38 am »
Heh, trying to fix that integer just made alot of new errors.


Im better of doing as you said replacing all ID'S with the proper once.

Offline Dochere

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Re: Migrated bot, unable to run.
« Reply #5 on: March 02, 2010, 09:46:59 am »
A much larger task then i would think.


Heres how i went forth:
Modified "#___raid_points" by adding a row_id, then modified id to BIGINT(20) like the #___users char_id.
Looped through all users replacing old id with new id, then used a sql update to replace all ids of names alike in the points table. As updating user table and points table at same time resulted in ALOT of duplicate entry.

Added this function to the roster file, then added a setting that would run this before any other command if "migrated = true".
Code: [Select]
        function update()
        {

                $members = $this -> bot -> db -> select("SELECT char_id, nickname, user_level, notify, updated_at FROM #___users");
                foreach($members as $member)
                {
                        $id = $this -> bot -> core("chat") -> get_uid($member[1]);
                        if ($member[0] != $id)
                        {
                                echo "'Updating user: $member[1] old id: $member[0] new id: $id\n";
                                $this -> bot -> db -> query("UPDATE `#___users` SET `char_id` = $id WHERE `char_id` = $member[0]");
                        }
                }
                $this -> bot -> db -> query("UPDATE #___users AS u, #___raid_points AS p SET p.id = u.char_id WHERE u.nickname = p.nickname");
        }




Im still stuck on some duplicate entry in the points table.  Very few though, in 2200 users i ended up with 12 duplicate entry errors.
« Last Edit: March 02, 2010, 09:51:24 am by Dochere »

Offline Dochere

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Re: Migrated bot, unable to run.
« Reply #6 on: August 25, 2010, 01:51:08 am »
Sorry for actually bumping up again this old thread.


but what do i need to do to make them show up as real UID's again.


Ive installed a 64bit server now but its still showing me the overflowing ID's and it tells me its running a 64bit server when starting.

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Migrated bot, unable to run.
« Reply #7 on: August 26, 2010, 07:15:47 am »
If you are on a 64bit server and you still get overflowed UID's you are most likely still running a 32bit PHP.

Compile from source and you will have a 64bit version of PHP which should solve the issue.
BeBot Founder and Fixer Kingpin

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 746
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal