Discuz! X論壇上傳附件到100%自動取消上傳的原因及解決方案

最近接到一些站長的反饋,說論壇上傳附件,到100%的時候自己取消上傳了。經查是附件索引表pre_forum_attachment表的aid字段自增值出現了問題,導致程序邏輯返回的aid值實際爲一個MySQL 1062 報錯:
來自網頁的消息
—————————
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”><html><head> <title>10.144.49.99 – Database Error</title> <meta http-equiv=”Content-Type” content=”text/html; charset=gbk” /> <meta name=”ROBOTS” content=”NOINDEX,NOFOLLOW,NOARCHIVE” /> <style type=”text/css”> <!– body { background-color: white; color: black; font: 9pt/11pt verdana, arial, sans-serif;} #container { width: 1024px; } #message { width: 1024px; color: black; } .red {color: red;} a:link { font: 9pt/11pt verdana, arial, sans-serif; color: red; } a:visited { font: 9pt/11pt verdana, arial, sans-serif; color: #4e4e4e; } h1 { color: #FF0000; font: 18pt “Verdana”; margin-bottom: 0.5em;} .bg1{ background-color: #FFFFCC;} .bg2{ background-color: #EEEEEE;} .table {background: #AAAAAA; font: 11pt Menlo,Consolas,”Lucida Console”} .info { background: none repeat scroll 0 0 #F3F3F3; border: 0px solid #aaaaaa; border-radius: 10px 10px 10px 10px; color: #000000; font-size: 11pt; line-height: 160%; margin-bottom: 1em; padding: 1em; } .help { background: #F3F3F3; border-radius: 10px 10px 10px 10px; font: 12px verdana, arial, sans-serif; text-align: center; line-height: 160%; padding: 1em; } .sql { background: none repeat scroll 0 0 #FFFFCC; border: 1px solid #aaaaaa; color: #000000; font: arial, sans-serif; font-size: 9pt; line-height: 160%; margin-top: 1em; padding: 4px; } –> </style></head><body><div id=”container”><h1>Discuz! Database Error</h1><div class=’info’>(1062) Duplicate entry ’107697′ for key 1<div class=”sql”>INSERT INTO forum_attachment SET `tid`=’0′ , `pid`=’0′ , `uid`=’1′ , `tableid`=’127′</div></div><div class=”info”><p><strong>PHP Debug</strong></p><table cellpadding=”5″ cellspacing=”1″ width=”100%” class=”table”><tr class=”…
—————————
確定
我們看到實際上是一段html代碼(其實如果站長關注後臺的運行記錄,也會有這個報錯的,只不過我是先排查代碼,才發現的),也就是Discuz! X的MySQL報錯信息頁面,這裏最重要的信息就是MySQL的報錯了,Discuz! Database Erro (1062) Duplicate entry ’107697′ for key 1 INSERT INTO forum_attachment SET `tid`=’0′ , `pid`=’0′ , `uid`=’1′ , `tableid`=’127′ 。知道了aid 1062 報錯,即插入了重複的值,那麼就好辦了,去pre_forum_attachment 修改自增值就可以了,自增值修改成什麼呢,當然要看一下aid當前的最大值多少,然後加1就是要修改的自增值了。可以在MySQL命令行執行:alter table pre_forum_attachment auto_increment = aid最大值+1 ,如果有phpMyAdmin的話,更好操作了了,這裏就不多說了。至於爲什麼自增值會出問題,還沒詳細研究,不過收集的幾個情況包括重啓服務器,數據庫遷移等操作。


源於青互聯虛擬主機博客http://www.qing.es

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章