Uncaught mysqli_sql_exception: Duplicate entry '16777215' for key 'PRIMARY' in /

Started by stray_tachyon, February 09, 2025, 12:24:10 PM

Previous topic - Next topic

stray_tachyon

Hi all.
I'm running SMF version 2.0.18 on the site http://www.china-defense.com/smf/index.php [nofollow].  The software is returning HTTP 500 errors and the following is in the error_log:

[04-Feb-2025 20:17:53 Etc/GMT+5] PHP Fatal error:  Uncaught mysqli_sql_exception: Duplicate entry '16777215' for key 'PRIMARY' in /home2/cdf/public_html/smf/Sources/Subs-Db-mysql.php:1169
Stack trace:
#0 /home2/cdf/public_html/smf/Sources/Subs-Db-mysql.php(1169): mysqli_query(Object(mysqli), '\n\t\t\tINSERT INTO...')
#1 /home2/cdf/public_html/smf/Sources/Subs-Db-mysql.php(1497): SMF_DB_MySQLi->query('', '\n\t\t\tINSERT INTO...', Array, Object(mysqli))
#2 /home2/cdf/public_html/smf/Sources/Errors.php(139): SMF_DB_MySQLi->insert('', 'smf2009_log_err...', Array, Array, Array)
#3 /home2/cdf/public_html/smf/Sources/Errors.php(161): log_error('Duplicate entry...', 'general')
#4 /home2/cdf/public_html/smf/index.php(130): fatal_error('Duplicate entry...', 'general')
#5 [internal function]: {closure}(Object(mysqli_sql_exception))
#6 {main}


Using the phpMyAdmin, I deleted the entry in the smf2009_log_errors with id_error = 16777215.  However, every time someone visited the site, the same entry with id_error = 16777215 gets created again and again.

I'm at a lost why this is happening.  I couldn't figure out why it is happening.  Can you please give me some guidance on how to fix it?

Thank you very much.

vbgamer45

Try to change the autoincreament field on the table to a higher id.

Or a quick fix disable error logging.  in smf_settings find
enableErrorLogging and set the value to 0
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

shawnb61

16M errors is a lot...  id_error is a MEDIUMINT...

The largest value an unsigned MEDIUMINT can hold is 16,777,215.

I'd probably change it to an INT, & try to figure out where all the errors are coming from.
A question worth asking is born in experience & driven by necessity. - Fripp

stray_tachyon

Thank you very much.

I have ran "alter table smf2009_log_errors auto_increment = 16777216;", didn't help
I have also changed id_error to mediumint(20)
Neither changes helped.

In the Settings.php, there is an entry:
$db_last_error = 1607014351;
Changing it to "$db_last_error = 160701435100000;" and adding "$enableErrorLogging = 0;" didn't help either.


shawnb61

mediumint(20) won't work, it's still a mediumint.

It needs to become an int.

And you need to figure out how you got 16M+ errors.
A question worth asking is born in experience & driven by necessity. - Fripp

stray_tachyon

Quote from: shawnb61 on February 09, 2025, 01:16:26 PMmediumint(20) won't work, it's still a mediumint.

It needs to become an int.

And you need to figure out how you got 16M+ errors.

I just got pulled in to fix the forum :)

Changed the column to int and we are back in business!!! :D

Thank you thank you thank you!!!

is it safe for me to run "delete from smf2009_log_errors"?

This is an example record in the smf2009_log_errors table:
url:
?action=verificationcode;vid=register;rand=<deleted>

message:
8192: imagefilledpolygon(): Using the $num_points parameter is deprecated

file:
/home2/cdf/public_html/smf/Sources/Subs-Graphics.php

line:
917

vbgamer45

What PHP version are you on? Also you should up to at least 2.0.19...
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

stray_tachyon

Quote from: vbgamer45 on February 09, 2025, 02:17:23 PMWhat PHP version are you on? Also you should up to at least 2.0.19...

Look to be 5.2.1 according to phpMyAdmin help but PHP 8.2 (ea-php82)  according to the hosting company's control panel

Can I upgrade to 2.1.4?

Thanks

Sir Osis of Liver

2.0.18 does not support php 8.  Yes, you should upgrade to current version. 
When in Emor, do as the Snamors.
                              - D. Lister

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

stray_tachyon

Quote from: Kindred on February 09, 2025, 05:14:08 PMAlso,  clear your error log

Yup, did that:

delete from smf2009_log_errors;
alter table smf2009_log_errors auto_increment = 0;

Kindred

Or just use the admin interface to do it.

Doing direct database edits is almost never the right way
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

stray_tachyon

Sorry, one more question
Our current forum is on 2.0.18 http://www.china-defense.com/smf/index.php [nofollow] with database table prefix of "smf2009_"

I have installed 2.1.14 https://www.china-defense.com/smf214/index.php [nofollow] with database table prefix of "smf214_"

Is there a guide on how to migrate data from one forum installation to another?


Thank you very very much.

Oldiesmann

There is no migration involved. SMF supports directly upgrading from one version to another. See https://wiki.simplemachines.org/smf/Upgrading for more information.
Michael Eshom
Christian Metal Fans

Kindred

Also, putting two instances of smf in the same database is a bad idea,  even with different prefixes
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."


Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

stray_tachyon


Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."


Advertisement: