Re: repeated problems with xar_session_info table

Jonathan Linowes <[email protected]>
Newsgroups gmane.comp.cms.xaraya.user
Message-ID <[email protected]>
this email's a 'keeper'
:)
linoj (still lurking...)



On Apr 18, 2008, at 7:36 AM, mikespub wrote:
> Ryan Walker wrote:
>> Hi,
>>
>> I manage a site where I'm repeatedly getting the "Undefined index:
>> xarSession_isNewSession" error.
>>
>> I can fix it each time by emptying the sessions table.  But it has  
>> now
>> recurred three times in a few weeks.  I've never seen it occur  
>> more than
>> once during the lifetime of any other site.
>>
>> Does anyone know what triggers this problem and why might it have
>> occurred three times in just a few weeks?
>> Xaraya 1.1.3
>> PHP 4.4.4
>> MySQL 4.1.22
>>
>> Thanks,
>> Ryan
>>
>
> A. Where does it go wrong
> =========================
> The following happens during session initialisation in  
> xarSession_init(),
> see file includes/xarSession.php :
>
> 1. specify how PHP should handle sessions in xarSession__setup()
>
> This tells PHP (amongst other things) to call the  
> xarSession__phpRead()
> function whenever it wants to read session information.
>
> 2. start the actual session with session_start()
>
> Here PHP will start the session and call xarSession__phpRead() to
> try & read session information from the xar_session_info table. This
> will set $GLOBALS['xarSession_isNewSession'] to true or false  
> depending
> on whether information is found or not.
>
> 3. if $GLOBALS['xarSession_isNewSession'] is true, call
> xarSession__new(), otherwise call xarSession__current() to
> finalise session initialisation for Xaraya
>
> This is where the error message is generated - in your case, the
> variable $GLOBALS['xarSession_isNewSession'] is not defined at all,
> because xarSession__phpRead() never gets to the point of setting
> its value :
>
>      $result =& $dbconn->Execute($query,array($sessionId));
>      if (!$result) return; // <-- yep, here's where it happens
>
>      if (!$result->EOF) {
>          $GLOBALS['xarSession_isNewSession'] = false;
>          ...
>      } else {
>          $GLOBALS['xarSession_isNewSession'] = true;
>          ...
>      }
>
> In other words, trying to select something from xar_session_info
> fails altogether, which is typical when e.g. a table is corrupted.
>
> Check the error messages you get and the MySQL error log to make
> sure that's the real cause...
>
> B. Why is this happening
> ========================
>
> The xar_session_info table is heavily loaded and gets at least one
> SELECT and two INSERTs/UPDATEs on each page hit, not to mention  
> DELETEs
> on garbage collection.
>
> So if your site gets a lot of visitors and/or robots crawling around
> at the same time, you get a lot of read/writes on the same table,  
> which
> isn't exactly MySQL's strong point, especially if you use the old  
> MyISAM
> table format.
>
> C. How should I fix this
> ========================
>
> 1. Make sure your PHP/MySQL combination doesn't have a known issue  
> with
> table corruption
>
> 2. Switch to InnoDB as table format for the xar_session_info table
>
> 3. Have a look at sessionless page caching, e.g. for your home page
>
> 4. Add a cosmetic fix in includes/xarSession.php to initialise
> $GLOBALS['xarSession_isNewSession'] before calling session_start()
>
> 5. Do a regular check/repair of your MySQL tables
>
> HTH,
>
> Mike.
> _______________________________________________
> Xaraya_user mailing list
> [email protected]
> http://xaraya.com/mailman/listinfo/xaraya_user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.