Re: statement_timeout is not working as expected with postgres_fdw
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Cc: Suraj Kharage <suraj.kharage@enterprisedb.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2017-05-04T02:31:15Z
Lists: pgsql-hackers
Attachments
- improve-pgfdw-abort-behavior-v1.patch (application/octet-stream) patch v1
On Wed, May 3, 2017 at 3:49 PM, Robert Haas <robertmhaas@gmail.com> wrote: > It seems pretty clear to me that we are not going to fix all of these > issues in one patch. Here's a sketch of an idea for how to start > making things better: Patch attached. > - Add an in_abort_cleanup flag to ConnCacheEntry. Ended up renaming this to abort_cleanup_incomplete. > - Before pgfdw_xact_callback() or pgfdw_subxact_callback() begin abort > cleanup, check whether the flag is set. If so, slam the connection > shut unless that's already been done; furthermore, if the flag is set > and we're in pgfdw_xact_callback (i.e. this is a toplevel abort), > forget about the connection entry entirely. On the other hand, if the > flag is not set, set it flag and attempt abort cleanup. If we > succeed, clear the flag. Did approximately this. It turned out not to be necessary to add any new calls to PQfinish(); the existing one was adequate. > - Before pgfdw_xact_callback() or pgfdw_subxact_callback() begin > pre-commit processing, check whether the flag is set. If so, throw an > ERROR, so that we switch over to abort processing. Did this. > - Change uses of PQexec() in the abort path to use pgfdw_exec_query() > instead. If we exit pgfdw_exec_query() with an error, we'll re-enter > the abort path, but now in_abort_cleanup will be set, so we'll just > drop the connection (and force any outer transaction levels to abort > as well). Created a new function pgfdw_exec_cleanup_query() for this, also incorporating a timeout. Also fixed things so that after issuing PQcancel() we actually throw away the pending result from the cancelled query, and added some error recursion protection. Review would be appreciated. -- 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