如何调试"无法从客户端接收数据:由同行重置连接"

can*_*eta 10 django database-connection celery django-celery django-postgresql

我正在Ubuntu-12.04上运行django-celery应用程序.

当我从我的Web界面运行芹菜任务时,我收到以下错误,采取postgresql-9.3 logfile(最大日志级别):

2013-11-12 13:57:01 GMT tss_usr 8113 LOG:  could not receive data from client: Connection reset by peer
Run Code Online (Sandbox Code Playgroud)

tss_usr是django应用程序数据库的postgresql用户(在这个例子中)8113是杀死连接的进程的pid,我猜.

您是否知道为什么会发生这种情况或者至少如何调试此问题?

为了让事情再次起作用,我需要重新启动postgresql,这非常不舒服.

ken*_*ler 6

我知道这是一篇较旧的帖子,但我刚刚找到它是因为我今天在我的 postgres 日志中遇到了同样的错误。我把它缩小到一个 PDO 选择语句。我在 Ubuntu Precise 上使用 Zend Framework 1.10.3。

如果 $opinion 是长文本字符串,则以下 pdo 语句会生成错误。列意见是我的 postgres 表中的文本类型。如果 $opinion 低于一定数量的字符,则查询成功。1000 个字符工作正常。2000 个字符失败并显示“无法从客户端接收数据:对等方重置连接”。

  $select = $this->db->select()
           ->from( 'datauserstopics' )
           ->where("opinion = ?",trim($opinion))
           ->where("datatopicsid = ?",trim($tid))
           ->where("datausersid= ?",$datausersid);

  $stmt = $this->db->query($select);
Run Code Online (Sandbox Code Playgroud)

我通过使用规避了这个问题: ->where("substr(opinion,1,100) = ?",trim(substr($opinion,1,100)))

这不是一个完美的解决方案,但就我而言,使用 substr() 的 select 语句就足够了。

请注意,将长字符串插入同一个表/列没有问题。断开连接问题只出现在 PDO select 上,文本字符串相对较长。