"MySQL服务器已消失" [英] "MySQL server has gone away"

查看:128
本文介绍了"MySQL服务器已消失"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Joomla 2.5.8,并安装了一个自定义组件,该组件可从数据库中获取数据并使用TCPDF生成自定义PDF文件.

I'm using Joomla 2.5.8 and have a custom component installed that fetches data from the DB and generates custom PDF files using TCPDF.

根据用户的请求,模型从DB加载一堆数据,这是可以的,没有超时,请求只需要几秒钟,并且此后没有更多的查询发送到数据库. 根据接收到的数据,进行处理以生成PDF文件,并将生成的PDF文件列表重新调整为要在布局中显示的视图.

Upon request by the user, the model loads a bunch of data from the DB, which is OK, there is no timeout, the request takes a few seconds and there is no more query sent to the database afterwards. Based on the data received, a processing is done to generate PDF files and the list of PDF files generated is retuned to the view to be displayed in the layout.

一切似乎都可以正常工作,并且处理可以正确完成,但是,可能是由于模型中进行了长时间的处理,菜单模块未加载,并且返回了以下错误:

Everything seems to work fine and processing completes correctly but, probably due to the long processing that is done in the model, the menu module is not loading and the following error is returned:

MySQL服务器已消失

MySQL server has gone away

SQL:

SELECT m.id, m.title, m.module, m.position, m.content, 
  m.showtitle, m.params, mm.menuid 
FROM jos2_modules AS m LEFT JOIN 
  jos2_modules_menu AS mm ON mm.moduleid = m.id LEFT JOIN 
  jos2_extensions AS e ON e.element = m.module AND e.client_id = m.client_id 
WHERE m.published = 1 AND e.enabled = 1 AND 
  (m.publish_up = '0000-00-00 00:00:00' OR m.publish_up <= '2013-10-31 15:42:00') AND
  (m.publish_down = '0000-00-00 00:00:00' OR m.publish_down >= '2013-10-31 15:42:00') AND 
  m.access IN (1,1,2,3,4) AND m.client_id = 0 AND 
  (mm.menuid = 101 OR mm.menuid <= 0) 
ORDER BY m.position, m.ordering

请注意,如果我删除了PDF文件处理程序,则没有错误. 我无法控制在此处理过程中花费的时间,但也许我没有在正确的位置进行操作.

Note that if I remove the PDF file processing, there is no error. I have no control on the time spent in this processing but maybe I'm not doing it in the right place.

我从以前的帖子中也了解到,MySQL配置中有一些参数可以在MySQL ini文件中进行调整,但这不是我可以做的,因为SQL Server由我的提供商托管.而且,发生错误时,我无权访问数据库.

I also understand from previous posts that there are parameters in the MySQL configuration that can be tuned in MySQL ini files but this is not something I can do as the SQL server is hosted by my provider. Moreover, I'm not having access to the database when the error occurs.

有人已经遇到过这种问题吗?

Has anybody already experience that kind of problem ?

推荐答案

这可能是超时问题.

您是否正在运行一个用于创建许多pdf文件的查询?如果是这样,它可能可能超时,或者创建pdf文件可能正在关闭查询(更有可能).

Are you running a single query which is used to create many pdf files? If so it could timeout, or the pdf file creation might be closing the query (more likely).

您应该尝试对要创建的每个文档重新运行查询,这样的开销很小,如果查询相同,将被缓存.

You should try re-running the query for each document you want to create, the overhead is minimal, if the queries are the same they will be cached.

您发布的查询似乎非常快,对于所有查询,请确保存在索引以使其保持快速. (不是解决方案,但可以解决您的问题).最后,如果查询是实时超时的,则可以一次创建一个文档,并通过ajax调用呈现结果,因此您的服务器一次仅生成一个文档,并且可能不会超时.这也将使网站对用户的显示更快.

The query you posted seems pretty fast, for all queries make sure indexes are present to keep them fast. (not a solution but could solve your problem). Finally, if the queries are in real timeout, you could create the documents one at a time and present the result with an ajax call, so your server only generates one document at a time and possibly doesn't timeout. This will also make the site appear quicker to the user.

也可以尝试增加php脚本set_time_limit(200);的效果,但我不确定这是否会有效,如果他们必须等待三分钟才能看到页面,那将是糟糕的用户体验,他们只会在超时之前点击重新加载.

Also you might try increasing the of the php script set_time_limit(200);, I'm not sure if this will be effective though, and it will be a lousy user experience if they have to wait three minutes to see the page, they'll just hit reload before the timeout.

这篇关于"MySQL服务器已消失"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆