Duplicate Key in multiple tables during insert causing mysql 1062 error [SOLVED?]

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Get Involved
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
User avatar
bipolarmorgan
Registered User
Posts: 68
Joined: Tue Jul 07, 2015 7:27 pm
Location: Cyberspace
Name: Morgan
Contact:

Duplicate Key in multiple tables during insert causing mysql 1062 error [SOLVED?]

Post by bipolarmorgan » Thu Nov 05, 2015 1:30 am

I'm getting a duplicate key mysql 1062 error intermittently during searches. I cannot seem to reproduce the error consistently. This doesn't seem to be MOD or STYLE related, and I've done enough research to know that it's likely caused by the forum software improperly generating a search_key as the primary key in that mysql table.

Support Request Template

What version of phpBB are you using?: phpBB 3.0.14
What is your board’s URL?: http://gurugossiper.com
Which database type/version are you using?: MySQL(i) 5.6.23
Which PHP version are you using?: 5.4.44
Who do you host your board with?: Hostgator Dedicated Server
How did you install your board?: I used the download package from phpBB.com
Is your board a fresh install or a conversion?: Update from a previous version of phpBB3
What MODs do you have installed?: Private Message Moderation (1.5.4)
a:1:{s:2:"en";s:23:"Full Quick Reply Editor";} (2.2.0)
a:1:{s:5:"en-gb";s:11:"FAQ Manager";} (1.2.6)
a:1:{s:2:"en";s:10:"User Merge";} (1.2.0)
a:1:{s:2:"en";s:20:"Avatar on Memberlist";} (1.0.3)
a:1:{s:2:"en";s:34:"Member List Permission Detail Mod.";} (1.0.1)
a:2:{s:2:"de";s:11:"NV newspage";s:2:"en";s:11:"NV newspage";} (1.0.8)
a:1:{s:2:"en";s:24:"Advertisement Management";} (1.0.12)
a:1:{s:2:"en";s:19:"Advanced Rules Page";} (1.0.0)
a:1:{s:2:"en";s:19:"Prime Update E-Mail";} (1.0.1)
a:1:{s:2:"en";s:31:"Advanced Double Activation Pack";} (1.4.12)
a:1:{s:2:"en";s:13:"Anti-Spam ACP";} (1.0.6)
a:2:{s:2:"en";s:13:"board3 Portal";s:2:"de";s:13:"board3 Portal";} (2.0.2)
a:2:{s:2:"en";s:18:"Duplicate User IPs";s:2:"tr";s:26:"Aynı IP adresli kayıtlar";} (1.0.0)
a:1:{s:2:"en";s:25:"Integrated Error Messages";} (1.0.4)
a:1:{s:2:"en";s:12:"Prime Notify";} (1.0.10b)
a:1:{s:2:"en";s:15:"Prime Trash Bin";} (1.1.8)
a:1:{s:2:"en";s:31:"Database Optimize & Repair Tool";} (1.0.2)
a:1:{s:2:"en";s:23:"Post Count Requirements";} (2.1.2)
a:1:{s:2:"en";s:22:"IP Permissions on Logs";} (1.0.0)
a:2:{s:2:"en";s:24:"Debug Errors and Notices";s:2:"fr";s:28:"Erreurs et Notices de débug";} (1.2.0)
a:1:{s:2:"en";s:17:"MOD Version Check";} (1.0.2)
a:2:{s:2:"en";s:16:"Thanks for posts";s:2:"ru";s:50:"Благодарность за сообщения";} (1.3.5)
a:1:{s:2:"en";s:29:"Expanded ACP Style Management";} (1.0.3)
a:2:{s:2:"en";s:20:"PM Blocking by Users";s:2:"tr";s:45:"Kullanıcı Tarafından Özel Mesaj Engelleme";} (1.0.0)
a:1:{s:2:"en";s:27:"Mobbern Theme Control Panel";} (1.0.1)
a:1:{s:5:"en-gb";s:19:"ReIMG Image Resizer";} (2.0.2)
a:1:{s:2:"en";s:13:"phpBB [video]";} (1.15)
a:1:{s:2:"en";s:8:"Tapatalk";} (4.9.7)
What styles do you currently have installed?: subsilver2
Guru Gossip
prosilver
Metro Copy
Metro Copy 2
Mobbern
Metro Purple
Mobile and SEO
What language(s) is your board currently using?: British English
What is your level of experience?: Comfortable with PHP and phpBB
What username can be used to view this issue?: No answer given
What password can be used to view this issue?: No answer given
When did your problem begin?: Since recently, slightely unsure, doesn't seem to coincide with anything.
Please describe your problem.: A general error occured: General Error
» SQL ERROR [ mysqli ]

Duplicate entry '1bf18eb65eb3cfa1784fc5d3f89c0c22' for key 'PRIMARY' [1062]

SQL

INSERT INTO phpbb_search_results (search_key, search_time, search_keywords, search_authors) VALUES ('1bf18eb65eb3cfa1784fc5d3f89c0c22', 1446686806, '', ' 19655 ')

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/includes/db/dbal.php
LINE: 757
CALL: trigger_error()

FILE: [ROOT]/includes/db/mysqli.php
LINE: 182
CALL: dbal->sql_error()

FILE: [ROOT]/includes/search/search.php
LINE: 194
CALL: dbal_mysqli->sql_query()

FILE: [ROOT]/includes/search/fulltext_native.php
LINE: 1018
CALL: search_backend->save_ids()

FILE: [ROOT]/search.php
LINE: 554
CALL: fulltext_native->author_search()

Generated by Support Toolkit SRT Generator.
Last edited by bipolarmorgan on Fri Nov 13, 2015 7:55 am, edited 1 time in total.

User avatar
AmigoJack
Registered User
Posts: 5589
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by AmigoJack » Thu Nov 05, 2015 6:45 am

This is impossible with an umodified installation - attach /includes/search/search.php so I can have a look at it to pinpoint which modification leads to this faulty behaviour.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
bipolarmorgan
Registered User
Posts: 68
Joined: Tue Jul 07, 2015 7:27 pm
Location: Cyberspace
Name: Morgan
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by bipolarmorgan » Thu Nov 05, 2015 8:19 pm

AmigoJack wrote:This is impossible with an umodified installation - attach /includes/search/search.php so I can have a look at it to pinpoint which modification leads to this faulty behaviour.
Impossible?! LMFAO - OK, if you say so. In that case, I will attach said file, and I'd love to know which mod is causing the problem. Thank you for the response, it is greatly appreciated.

FYI - it matches the 3.0.13 file exactly and 3.0.14 upgrade doesn't change that file, so I don't know why you would assume that file.... I'd love to know your thinking.
search.php
(8.32 KiB) Downloaded 17 times

User avatar
AmigoJack
Registered User
Posts: 5589
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by AmigoJack » Fri Nov 06, 2015 6:50 am

bipolarmorgan wrote:Impossible?! LMFAO
Yes, almost, since the code does first search for an existing key before trying to insert it.
bipolarmorgan wrote:I don't know why you would assume that file
Because of the backtrack you provided plus my knowledge of what each file does.

That file is unmodified, which leaves only the chance that your board search is used quite often (so race conditions occur, where two requesters are issuing the same search and for both the resulting key doesn't exist yet, but one of them is faster to store the key, and the other one then gets an error). You can ignore such an error by modifying line 194 from:

Code: Select all

                    $db->sql_query($sql);
into:

Code: Select all

                    /*** 2015-11-06 BEGIN AmigoJack
                        https://www.phpbb.com/community/viewtopic.php?f=46&t=2343386 ***/
                    //$db->sql_query($sql);
                    $db-> sql_return_on_error( TRUE );
                    $db-> sql_query( $sql );
                    $db-> sql_return_on_error( FALSE );
                    /*** 2015-11-06 END ***/
Tested.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
bipolarmorgan
Registered User
Posts: 68
Joined: Tue Jul 07, 2015 7:27 pm
Location: Cyberspace
Name: Morgan
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by bipolarmorgan » Fri Nov 06, 2015 4:58 pm

AmigoJack wrote: which leaves only the chance that your board search is used quite often (so race conditions occur, where two requesters are issuing the same search and for both the resulting key doesn't exist yet, but one of them is faster to store the key, and the other one then gets an error).
But I don't want to ignore the error, if I wanted to do that, I could turn off debugging as well. But I was wondering if there was a solution or workaround (maybe a mysql trigger) to resolve such an issue.

Yes, we likely are getting two users requesting the same search at the same time causing the problem. However, this shouldn't be happening. That is why it is logged as an error. Ignoring the problem is bad development practice.

Thank you for your responses, I do appreciate the feedback.

Thoughts on the below mysql statement? (it might fix the problem)....
If you specify ON DUPLICATE KEY UPDATE, and a row is inserted that would cause a duplicate value in a UNIQUE index or PRIMARY KEY, MySQL performs an UPDATE of the old row. For example, if column a is declared as UNIQUE and contains the value 1, the following two statements have similar effect:

INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1;

UPDATE table SET c=c+1 WHERE a=1;
(The effects are not identical for an InnoDB table where a is an auto-increment column. With an auto-increment column, an INSERT statement increases the auto-increment value but UPDATE does not.)

User avatar
bipolarmorgan
Registered User
Posts: 68
Joined: Tue Jul 07, 2015 7:27 pm
Location: Cyberspace
Name: Morgan
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by bipolarmorgan » Sun Nov 08, 2015 6:44 pm

:?:

User avatar
AmigoJack
Registered User
Posts: 5589
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by AmigoJack » Mon Nov 09, 2015 7:58 am

My approach was balanced in efficience and solution. You can also ignore errors #1062 only, if you want. But in the end it doesn't matter which error occured at that position - if it's not a duplicate key then it's something worse which would also threw up on an UPDATE attempt.
bipolarmorgan wrote:But I don't want to ignore the error
Every software ignores errors, i.e. when trying to create a folder you can mostly ignore the error of ALREADY_EXISTS - why wouldn't you want that? phpBB does so as well.
bipolarmorgan wrote:if there was a solution
One solution would be to lock tables, which has drastic disadvantages. Another solution would be to let PHP only execute one script at a time, which has even more drastic disadvantages.
bipolarmorgan wrote:this shouldn't be happening
Race conditions occur far more often than you think - that's why the world struggles with being thread-safe and atomic operations.
bipolarmorgan wrote:the below mysql statement
That is partly redundant with phpBB's code - pick one only. And MySQL even comes with an INSERT IGNORE syntax, which is more appropriate for this case.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
bipolarmorgan
Registered User
Posts: 68
Joined: Tue Jul 07, 2015 7:27 pm
Location: Cyberspace
Name: Morgan
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by bipolarmorgan » Mon Nov 09, 2015 5:50 pm

How about instead of ignoring the error, we instead don't report the error, but deal with it - make it look for the existing row and use it's data, I guess.... or would that cause incorrect searches ?

IDK, it just doesn't seem right to simply ignore the error, when there should likely be a solution.

I get what you are saying and I do appreciate the feedback though, don't get me wrong, I'm not trying to argue or be too hard headed... but it just doesn't feel right to ignore such an error.

I would think the update statement would work fine, as the first user would get their search results, and the second one would also get theirs... and there wouldn't be an error thrown.

I would be happy to test this, if I could get some help figuring where I modify the code to use an update like I posted....

User avatar
AmigoJack
Registered User
Posts: 5589
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by AmigoJack » Tue Nov 10, 2015 7:29 am

bipolarmorgan wrote:How about instead of ignoring the error, we instead don't report the error, but deal with it - make it look for the existing row and use it's data, I guess
I already said that phpBB is doing that, hence your suggestion was redundant. But in both cases it's no atomic operation. Also "ignoring" and "not reporting" is in that case the same.
bipolarmorgan wrote:there should likely be a solution
I showed and told you solutions. If you want to philosphy ("feel") about it then I'm out, as I'm here for the logic. If you don't understand specific parts then ask about those.


Your approach binds you to MySQL, while my approach still supports all DBMSes. And if you want to check for error #1062 only then you're bound to MySQL again, since every DBMS has its own error codes (i.e. PostgreSQL would be #23505). Again: in that specific situation every error is ignorable.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
bipolarmorgan
Registered User
Posts: 68
Joined: Tue Jul 07, 2015 7:27 pm
Location: Cyberspace
Name: Morgan
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by bipolarmorgan » Tue Nov 10, 2015 10:19 am

AmigoJack wrote:
bipolarmorgan wrote:the below mysql statement
That is partly redundant with phpBB's code - pick one only. And MySQL even comes with an INSERT IGNORE syntax, which is more appropriate for this case.


I think I want ON DUPLICATE KEY IGNORE then ... because INSERT IGNORE will ignore all errors, when I simply want to avoid the one error...

ON DUPLICATE KEY IGNORE will abort the insert if the row already exists..., thereby avoiding the collision (in theory.)

Can you point me logically to the file/line/area where I would add that to the mysql statement that inserts the primary key for that table?

AmigoJack wrote:
bipolarmorgan wrote:but it just doesn't feel right to ignore such an error.
If you want to philosphy ("feel") about it then I'm out, as I'm here for the logic. If you don't understand specific parts then ask about those.


Your approach binds you to MySQL, while my approach still supports all DBMSes. And if you want to check for error #1062 only then you're bound to MySQL again, since every DBMS has its own error codes (i.e. PostgreSQL would be #23505). Again: in that specific situation every error is ignorable.
Touche sir, yes I was trying to stay logical, but might have gotten a little thoughtful I suppose .... while I appreciate your solution for certain situations, in this situation I would prefer to avoid that solution, as it's still allowing the collision and just ignoring the error. If you came up with a solution that didn't simply ignore the error, then you would be much more logical, and I would happily test it to see if it resolves the issue I'm describing. Again - IGNORING THE ERROR SHOULD NOT BE PART OF THE SOLUTION ... otherwise, if that was an option, I wouldn't have posted in the first place. I would prefer to avoid the error altogether.

Also I realize my approach my bind me to MySQL, but since I'm using mysql and don't plan to change that... it fits my scenario. You have a good point in that your approach does support multiple DBMSes, however, again, it's simply ignoring the underlying issue, which I now believe could be resolved with an ON DUPLICATE KEY IGNORE statement being somehow added to the existing mysql statement that inserts the duplicate key currently. This should (again in theory) avoid the collision to begin with, circumventing the error log and properly returning the correct search parameters.... I'm assuming.

While I realize you may not like my reasoning, it still makes logical sense to approach it from another POV, doesn't it? There isn't just one way to solve a puzzle, sometimes there are multiple ways to solve it. Either way, Thank you for your help and feedback, I hope I didn't offend you or make you feel like you weren't helping. You clearly are helping me think this whole thing through, thoroughly, and that my friend, I appreciate. Thank you!

User avatar
AmigoJack
Registered User
Posts: 5589
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by AmigoJack » Tue Nov 10, 2015 12:24 pm

bipolarmorgan wrote:INSERT IGNORE will ignore all errors
That's right. But which potential other errors come to your mind?
bipolarmorgan wrote:Can you point me logically to the file/line/area
It's still /includes/search/search.php and still around line 194, namely line 193:

Code: Select all

$sql = 'INSERT INTO ' . SEARCH_RESULTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
After that, add i.e. these lines:

Code: Select all

$sql.= ' ON DUPLICATE KEY UPDATE search_time= '. $sql_ary['search_time'];
unset( $sql_ary['search_time'] );
foreach( $sql_ary as $sColumn=> $sValue ) $sql.= ', '. $sColumn. '= \''. $db-> sql_escape( $sValue ). '\'';
Untested.
bipolarmorgan wrote:I would prefer to avoid the error altogether
Take a broader look at lines 176 thru 202: phpBB first checks if the key exists. No match means trying to insert the new data, otherwise update the existing row. Your aim at updating the existing row on duplicate key inserts is ignorable, because of significance: the whole table is used for statistics only (displaying recent searches to administrators), not for providing something that is needed essentially (such as storing search filters).
bipolarmorgan wrote:I hope I didn't offend you or make you feel like you weren't helping
No, you didn't. If there's no need for any other DBMS anytime (keep in mind that in your testing environment you might still want/need to test/use other DBMSes) then go for it to handle this precisely. However, I'd put my energy into the DBAL to augment the sql_build_array() method so it can (optionally) also use such "extended" (non-ANSI) SQL syntax for each DBMS supported. After that, I'd return to this very problem and just call the method with one more parameter so it uses that syntax... and would be able to do that on every other case thrughout phpBB where this could occur.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
bipolarmorgan
Registered User
Posts: 68
Joined: Tue Jul 07, 2015 7:27 pm
Location: Cyberspace
Name: Morgan
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by bipolarmorgan » Thu Nov 12, 2015 8:02 am

AmigoJack wrote:
bipolarmorgan wrote:I hope I didn't offend you or make you feel like you weren't helping
No, you didn't. If there's no need for any other DBMS anytime (keep in mind that in your testing environment you might still want/need to test/use other DBMSes) then go for it to handle this precisely. However, I'd put my energy into the DBAL to augment the sql_build_array() method so it can (optionally) also use such "extended" (non-ANSI) SQL syntax for each DBMS supported. After that, I'd return to this very problem and just call the method with one more parameter so it uses that syntax... and would be able to do that on every other case thrughout phpBB where this could occur.
Well, I'd love to test that solution as well, just in case I decide to test another DBM ... and I truly appreciate the time you likely spent on the code and input you've given me.

Sounds like I may be leading you in a direction that could potentially fix this "bug" for future versions .... ? This isn't the only table this condition occurs, so maybe if this fixes this table, I can reproduce the same code for the other tables where I'm having the issue. Or if you come up with a better solution, I'd be more than happy to be the tester...

I just implemented the extra statements you gave me, I'll leave feedback here if i notice anything weird or any issues that seem to stem from changing said code.

**UPDATE** (like 1 minute later) After backing up my existing file and then adding Your code to my file, the search feature is still working properly, (fingers crossed) I will see if I get any of those errors today and report back again, but at first glance, I say good code. Very much appreciated - as I'm hoping this will alleviate like maybe 1% of the stress on my server by avoiding several logged errors.

User avatar
AmigoJack
Registered User
Posts: 5589
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by AmigoJack » Thu Nov 12, 2015 12:29 pm

Years ago I just decided to augment that method to also allow a custom prefix, which then could be my preferred INSERT IGNORE, as I wouldn't switch the DBMS as well. And that was used in a couple of places on a 3.0 installation to silence rare conditions. Works great since then. Since phpBB shifted to 3.1 I'm not fluent with its code anymore, as yet I'm still not convinced to be an overall improvement, so most likely I won't be the one submitting such code as we discussed here.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
bipolarmorgan
Registered User
Posts: 68
Joined: Tue Jul 07, 2015 7:27 pm
Location: Cyberspace
Name: Morgan
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by bipolarmorgan » Fri Nov 13, 2015 5:11 am

AmigoJack wrote:Years ago I just decided to augment that method to also allow a custom prefix, which then could be my preferred INSERT IGNORE, as I wouldn't switch the DBMS as well. And that was used in a couple of places on a 3.0 installation to silence rare conditions. Works great since then. Since phpBB shifted to 3.1 I'm not fluent with its code anymore, as yet I'm still not convinced to be an overall improvement, so most likely I won't be the one submitting such code as we discussed here.
You sound like you are questioning your own solution! That's too bad, because it's a working fix for me!!!! Thanks a million!

**UPDATE** I haven't seen the original error, but I'm hoping you can help me do the same with a couple other errors (below) .... thoughts?
A general error occured: General Error
» SQL ERROR [ mysqli ]

Duplicate entry 'amandamc' for key 'username_clean' [1062]

SQL

INSERT INTO phpbb_users (username, username_clean, user_password, user_pass_convert, user_email, user_email_hash, group_id, user_type, user_permissions, user_timezone, user_dateformat, user_lang, user_style, user_actkey, user_ip, user_regdate, user_passchg, user_options, user_new, user_inactive_reason, user_inactive_time, user_lastmark, user_lastvisit, user_lastpost_time, user_lastpage, user_posts, user_dst, user_colour, user_occ, user_interests, user_avatar, user_avatar_type, user_avatar_width, user_avatar_height, user_new_privmsg, user_unread_privmsg, user_last_privmsg, user_message_rules, user_full_folder, user_emailtime, user_notify, user_notify_pm, user_notify_type, user_allow_pm, user_allow_viewonline, user_allow_viewemail, user_allow_massemail, user_sig, user_sig_bbcode_uid, user_sig_bbcode_bitfield, user_form_salt, user_dupe_ip) VALUES ('amandamc', 'amandamc', '$H$93wrRPtqCZgr5bgT3GZCXn1vppHlQj0', 0, 'cypertamanda@gmail.com', '51626402222', 2, 1, '', -6, 'D M d, Y g:i a', 'en', 32, '2KM8V4', '129.118.92.22', 1447357388, 1447357394, 232319, 1, 1, 1447357388, 1447357394, 0, 0, '', 0, '0', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 1, 0, 1, 1, 1, 1, '', '', '', 'db029247593f9010', '')

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/includes/db/dbal.php
LINE: 754
CALL: trigger_error()

FILE: [ROOT]/includes/db/mysqli.php
LINE: 182
CALL: dbal->sql_error()

FILE: [ROOT]/includes/functions_user.php
LINE: 250
CALL: dbal_mysqli->sql_query()

FILE: [ROOT]/includes/ucp/ucp_register.php
LINE: 368
CALL: user_add()

FILE: [ROOT]/includes/functions_module.php
LINE: 507
CALL: ucp_register->main()

FILE: [ROOT]/includes/functions_module.php
LINE: 802
CALL: p_master->load_active()

FILE: [ROOT]/ucp.php
LINE: 70
CALL: p_master->load()
A general error occured: General Error
» SQL ERROR [ mysqli ]

Duplicate entry '1864573-93535' for key 'PRIMARY' [1062]

SQL

INSERT INTO phpbb_thanks (user_id, post_id, poster_id, topic_id, forum_id, thanks_time) VALUES (93535, 1864573, 100606, 8103, 156, 1447352148)

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/includes/db/dbal.php
LINE: 757
CALL: trigger_error()

FILE: [ROOT]/includes/db/mysqli.php
LINE: 182
CALL: dbal->sql_error()

FILE: [ROOT]/includes/functions_thanks.php
LINE: 114
CALL: dbal_mysqli->sql_query()

FILE: [ROOT]/viewtopic.php
LINE: 1477
CALL: insert_thanks()

User avatar
AmigoJack
Registered User
Posts: 5589
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Duplicate Key in multiple tables during insert causing mysql 1062 error

Post by AmigoJack » Fri Nov 13, 2015 9:06 am

bipolarmorgan wrote:
Duplicate entry 'amandamc' for key 'username_clean' [1062]
This should never occur, since phpBB always checks for a cleaned username thru the registration. Either the existing dataset got into the database bypassing phpBB's functions, or parts of the registrations are modified.
bipolarmorgan wrote:
FILE: [ROOT]/includes/ucp/ucp_register.php
LINE: 368
CALL: user_add()
In a default 3.0.14 installation that call does not exist at that line - the file is anything but original.


bipolarmorgan wrote:
Duplicate entry '1864573-93535' for key 'PRIMARY' [1062]
...
INSERT INTO phpbb_thanks
...
FILE: [ROOT]/includes/functions_thanks.php
LINE: 114
CALL: dbal_mysqli->sql_query()
...
FILE: [ROOT]/viewtopic.php
LINE: 1477
CALL: insert_thanks()
I neither know that MOD, nor that file or the function being called - ask in the support section of that MOD for help.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

Locked

Return to “[3.0.x] Support Forum”