ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Yes, not caching the database is a solution. But comes with a seemingly small cost is performance. I didn't test extensively but the change was less than a few percent.
still interested in the cause of this error though. It must come from the functions file sessions.php. In function _sess_write zen has:
Seems bizarre that this error can be created.Code:$expiry = time() + $SESS_LIFE; $qid = "select count(*) as total from " . TABLE_SESSIONS . " where sesskey = '" . zen_db_input($key) . "'"; $total = $db->Execute($qid); if ($total->fields['total'] > 0) { $sql = "update " . TABLE_SESSIONS . " set expiry = '" . zen_db_input($expiry) . "', value = '" . zen_db_input($val) . "' where sesskey = '" . zen_db_input($key) . "'"; $result = $db->Execute($sql); } else { $sql = "insert into " . TABLE_SESSIONS . " values ('" . zen_db_input($key) . "', '" . zen_db_input($expiry) . "', '" . zen_db_input($val) . "')"; $result = $db->Execute($sql); }
If anyone has thoughts then I'd be interested :-)
Nick
iszent.com
lhungil pointed out a couple of posts back that it's most likely a race condition on busy stores (the check/optional insert is not atomic). Perhaps that section could be made atomic without changing the functionality as:
Code:$expiry = time() + $SESS_LIFE; $sql = "insert IGNORE into " . TABLE_SESSIONS . " values ('" . zen_db_input($key) . "', '" . zen_db_input($expiry) . "', '" . zen_db_input($val) . "')"; $db->Execute($sql); $sql = "update " . TABLE_SESSIONS . " set expiry = '" . zen_db_input($expiry) . "', value = '" . zen_db_input($val) . "' where sesskey = '" . zen_db_input($key) . "'"; $result = $db->Execute($sql);
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Well, yes, it evidently might be created by some kind of race condition. ( Off the record I am surprised by how often this is happening if that is the case just because of the probability of it but that just means that I am surprised not that I don't think it is so)
Yes, that code might replace the existing code.
@mc Yes, it would replace the code block that I pasted in its entirety.
I may or may not give it a try. Trade off here is changing session handling code which would mean that I need to find the time to actively monitor the store after the change or living with a couple of errors a day.
Nick
iszent.com