MyBB Community Forums

Full Version: MySQL Error 1062
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I'm having some issues and I'm wondering if someone can help me. It's been a while since I've dove into MyBB much so apologises.

I manage a large form with thousands of posts. The forum runs on an OpenVZ visualised machine on my own node. 
A few days ago, started to get 500 Internal Server Errors and the following error when people replied to threads.
SQL Error:
1062 - Duplicate entry '508775' for key 'PRIMARY'
Query:
INSERT INTO mybb_posts (`tid`,`replyto`,`fid`,`subject`,`icon`,`uid`,`username`,`dateline`,`message`,`ipaddress`,`includesig`,`smilieoff`,`visible`) VALUES (9794,310963,20,'RE: SAVED GIFS',0,31,'Duchess',1586203004,'test',X'6422fa4b',1,0,1)

When the 500 Internal Server Error appears, I can do nothing in SSH other than login to the node and restart the VPS - the errors I get when inside the SSH for the VPS are "Fork: cannot allocate memory".

So, I did some reading and increased the 'pid' length on the posts table from 10 to 11. This seemed to solve the issue and allow posts to be replied too. 
However then it kept crashing with 500 error messages.

Looking around other tables, I changed the pid on various other tables from 10 to 11. This again appeared to have a positive effect.

Now, another error but this time the private messages table.
SQL Error:
1062 - Duplicate entry '63818' for key 'PRIMARY'

I've done the following:
  • Increased pid from 10 to 11 characters.
  • Ran rkhunter on server.
  • Updated cPanel on the server (forced)
  • Updated YUM
  • Re-uploaded fresh MyBB 1.8.22 files

Any advise?? Smile
*No plugins activated*
"Increased pid from 10 to 11 characters." seems irrelevant.

Did you check the auto increment value for the tables? - though maybe it'd be OK too, see http://www.softwareprojects.com/resource...-1844.html if you're on MySQL.

Just a guess, maybe some internal fault exists in the database system. "Fork: cannot allocate memory" should be taken care of, since I think it's directly related to the database issue.
First, you may try to repair your tables, and truncate the mybb_sessions table (cf this post).
Then, it looks like the autoincrement value for mybb_posts lost its value. You can check it (have an eye on https://stackoverflow.com/questions/1582...-any-table if you don't know how) and compare with your max(pid) value in mybb_posts.
And if the AI is less than max(pid), adjust it (alter table mybb_posts auto_increment=X with X=max(pid) +1)
(2020-04-08, 06:13 AM)noyle Wrote: [ -> ]"Increased pid from 10 to 11 characters." seems irrelevant.

Did you check the auto increment value for the tables? - though maybe it'd be OK too, see http://www.softwareprojects.com/resource...-1844.html if you're on MySQL.

Just a guess, maybe some internal fault exists in the database system. "Fork: cannot allocate memory" should be taken care of, since I think it's directly related to the database issue.
Hi Yah, I think MySQL just creates a memory trap when this error exists.
I changed the next auto_increment value manually using ALTER TABLE. See, when sending a PM I would get the error above, after skipping 100 of the next auto_increments, I could start sending again.
I woke up this morning and the forum has again crashed with the 500 Internal Server Error. But I can find nothing hinting at the cause in the logs.
(2020-04-08, 06:29 AM)Crazycat Wrote: [ -> ]First, you may try to repair your tables, and truncate the mybb_sessions table (cf this post).
Then, it looks like the autoincrement value for mybb_posts lost its value. You can check it (have an eye on https://stackoverflow.com/questions/1582...-any-table if you don't know how) and compare with your max(pid) value in mybb_posts.
And if the AI is less than max(pid), adjust it (alter table mybb_posts auto_increment=X with X=max(pid) +1)
Hi Mate,

I did repair the tables successfully.
I have used your suggestion to skip a few hundred pid's for the posts table.

So, since my origional post, I have set the auto_increment to skip several hundred ids on the posts table and the privatemessages table - though I am expected it to crash again ;/

Despite editing the auto_increment it crashed again. Same issue

I have now tried the suggestion of dropping the database and recreating it then importing a backup of the data.
I have also rebuilt the web services using Easy Apache 4.

I feel this issue will repeat.
Sounds like a hosting environment issue to me. Quite out of my knowledge, maybe Google will help.

Have you also checked the log of MySQL?
Will you try to tune the MySQL's configurations?