Loading...
 
Architecture / Installation

Architecture / Installation


duplicate key in tiki_sessions - a "solution"

posts: 1

perhaps I'm the only one that encountered this problem so far. it was hard enough just to dig it and "discover" what was causing.
my boss emails me with an error he gets at our front page:

Image
Copy to clipboard
Warning: error: Duplicate entry '5663207e3d6e1adc2b7bbe63b672c365' for key 1 in query: insert into `tiki_sessions`(`sessionId`,`timestamp`,`user`) values(?,?,?) in /home/www/*********/lib/tikidblib.php on line 134


I was like "What the hell?" — after days of trying to recreate the bug (apparently it only happened in an IPv6 env) I find myself reading the damn email again and see this:

Image
Copy to clipboard
... array(3) {       [0]=>       &string(73) "insert into `tiki_sessions`(`sessionId`,`timestamp`,`user`) values(?,?,?)"       [1]=>       &array(3) {         [0]=> ----> HERE <-----      string(40) "5663207e3d6e1adc2b7bbe63b672c36583f32c3f"         [1]=>         int(1134482295)         [2]=>         NULL       } ...


And I see that the string for the SESSID is differente from above. After looking at the tiki_sessions structure, I realize it's a VARCHAR(32)...

I checked too that update_session() from tiki first tries to delete the key and then reinsert.

So, after some tests this is what was actually happening:
arrow Boss access webpage — tiki tries to insert a 40 chars long string and mysql truncates it to 32 chars but inserts
arrow Boss reloads webpage — tiki tries to delete a 40 chars long string from table (it doesn't exist and don't generate an error!!!!!)
arrow tiki tries to insert the 40 chars long string but mysql truncates it to 32 chars long and whines about already existing one key — NOW there's an error.

My solution: I changed my tiki_sessions table so sessionId is a VARCHAR(40) instead of 32.

I think this is probably a PHP bug but I haven't checked it yet.
I just want to know if this solution will affect any other thing (I personally think it won't).

I hope I explained my problem and "solution" fairly well :-)

php version: 4.3.10
tiki: 1.8.6
apache: 2.0.54

posts: 2881 United Kingdom

Nope its a IPV6 requirement, Just we mere mortals are still on old stuff ;)

You did well.

Damian


posts: 1092

Good job Nitio

Seems we will also encouter perhaps this problem with php5
From php.net
The way PHP5 creates session ids has changed. No longer are session ids always 32 characters. Rather it depends on how session.hash_function and and session.hash_bits_per_character
more fun....


posts: 43 United States

nitio,

This info was very helpful for resolving an error that we experienced related to Scoring and unnecessarily long usernames. The affected users had usernames consisting of their full email addresses - first_last@mail.domain.com. When they tried to read certain blogs, they received a "duplicate key" error related to the event_id variable in the tiki_users_score table for entries like UserName-blog_is_read_User_Name@mail.domain.com:2, that had around 60 characters in some cases.

Solution: Drop the "@mail.domain.com" from the usernames. biggrin (Who the hell wants to type all that in each time anyway?)

Thx,
))MacLeod((


Upcoming Events

1)  18 Apr 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  16 May 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  20 Jun 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
5)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7) 
Tiki birthday
8)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
9)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
10)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting