为什么一个查询超时时,它是在它的超时限制? [英] Why does a query time-out when it is within it's timeout limit?

查看:1505
本文介绍了为什么一个查询超时时,它是在它的超时限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个长时间运行的查询超时约48分钟后。

I have a long running query that times out after about 48 minutes.

的命令超时设定为2小时,连接超时设置为17分钟。

The command time-out is set to 2 hours and the connection time-out is set to 17 minutes.

什么会导致查询,以提高超时? (我假设必须有别的东西,我已经忽略了?)

What would cause the query to raise a time-out? (I'm assuming there must be something else that I've overlooked?)

Npgsql.NpgsqlException:
    A timeout has occured. If you were establishing a connection, increase Timeout value in ConnectionString. If you were executing a command, increase the CommandTimeout value in ConnectionString or in your NpgsqlCommand object.
       at Npgsql.NpgsqlState.ProcessBackendResponsesEnum(NpgsqlConnector context) in C:\projects\Npgsql2\src\Npgsql\NpgsqlState.cs:line 384
       at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb) in C:\projects\Npgsql2\src\Npgsql\NpgsqlCommand.cs:line 611
       at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior cb) in C:\projects\Npgsql2\src\Npgsql\NpgsqlCommand.cs:line 591
       at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior) in C:\projects\Npgsql2\src\Npgsql\NpgsqlCommand.cs:line 538

信息:

  • 的Postgres版本:8.3
  • NpgSql:2.0.11.0

Postgres的日志显示下面的错误:

The postgres log shows the following "ERROR":

cancelling statement due to user request

昨晚的查询运行两次,在不同的时间不同的日期范围,两次失败与相同的错误,并运行相同的时间量之后 - 00:48:24.909 和00:48:24.936

The query ran twice last night at different times for different date ranges, both times it failed with the same error, and after running for the same amount of time - "00:48:24.909" and "00:48:24.936"

另外,previous查询已采取不长于0点47分四十零秒,所以这表明别的东西引起该超时在约48分钟。

Also, previous queries have taken no longer than 00:47:40, so this suggests something else is causing the time-out at around 48 minutes.

我看不到Postgres的配置文件中的任何东西,有没有其他地方,我可以看看吗?

I can't see anything in the postgres configuration file, is there anywhere else I could look?

推荐答案

这是在Npgsql的错误。我只是验证它。这是<一个href="https://github.com/npgsql/Npgsql/commit/d999e45e4376877494f9c7687430924195280f04#diff-cb022d3a3f5cb8dd7d4e28ffd2e1316c"相对=nofollow>固定在2013年3月10日,但之后一直没有一个稳定版本。因为它目前为你必须从电流源构建来解决这个问题。

It's a bug in Npgsql. I just verified it. It was fixed on 03/10/2013, but there hasn't been a stable release since then. As it currently stands you'll have to build from current sources to get around this.

这是造成该Socket.Poll()接受一个I​​nt32微秒参数,通过什么似乎是Socket.Poll()本身就是一个错误的事实的组合。

It is caused by a combination of the fact that Socket.Poll() takes an Int32 microseconds argument, and by what appears to be a bug in Socket.Poll() itself.

首先,2个小时转换为-1,389,934,592微秒(7200秒* 1,000,000),该值的绝对值的大约是48分钟。

First, 2 hours converts to -1,389,934,592 microseconds (7200 seconds * 1,000,000), the absolute value of which is about 48 minutes.

二,的 Socket.Poll()文档状态:

设置微秒参数为负整数,如果你想无限期地等待响应。

set the microSeconds parameter to a negative integer if you would like to wait indefinitely for a response.

相反,它似乎转换为绝对值,约48分钟,所以有你的怪,但predictable超时。

Instead, it appears to convert to the absolute value, about 48 minutes, so there's your odd but predictable timeout.

这篇关于为什么一个查询超时时,它是在它的超时限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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