Re: statement_timeout is not working as expected with postgres_fdw
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>, Suraj Kharage <suraj.kharage@enterprisedb.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2017-05-04T17:10:26Z
Lists: pgsql-hackers
On Thu, May 4, 2017 at 1:04 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
> On Thu, May 4, 2017 at 10:18 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>> On Thu, May 4, 2017 at 12:18 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
>>> As soon as the first command fails due to timeout, we will set
>>> 'abort_cleanup_failure' which will make a toplevel transaction to
>>> abort and also won't allow other statements to execute. The patch is
>>> trying to enforce a 30-second timeout after statement execution, so it
>>> has to anyway wait till the command execution completes (irrespective
>>> of whether the command succeeds or fail).
>>
>> I don't understand what you mean by this. If the command doesn't
>> finish within 30 seconds, we *don't* wait for it to finish.
>>
>
> + /*
> + * Submit a query. Since we don't use non-blocking mode, this also can
> + * block. But its risk is relatively small, so we ignore that for now.
> + */
> + if (!PQsendQuery(conn, query))
> + {
> + pgfdw_report_error(WARNING, NULL, conn, false, query);
> + return false;
> + }
> +
> + /* Get the result of the query. */
> + if (pgfdw_get_cleanup_result(conn, endtime, &result))
> + return false;
>
> The 30 seconds logic is in function pgfdw_get_cleanup_result, can't
> the command hang in PQsendQuery?
Sure. I thought about trying to fix that too, by using
PQsetnonblocking(), but I thought the patch was doing enough already.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Commits
-
postgres_fdw: Allow cancellation of transaction control commands.
- fc267a0c3c65 9.3.18 landed
- c02c450cfc0f 9.4.13 landed
- b7665f079092 9.5.8 landed
- fd849956cc71 9.6.4 landed
- ae9bfc5d6512 10.0 landed
-
Allow queries submitted by postgres_fdw to be canceled.
- cdf5a004bb7c 9.5.7 landed
- f14bf0a8fdd5 9.4.12 landed
- 3aa16b117a28 9.3.17 landed
- f039eaac7131 9.6.0 cited
-
Fix multiple problems in postgres_fdw query cancellation logic.
- 1b812afb0eaf 9.6.0 cited