Make backend query execution interruptible.#454
Open
nmisch wants to merge 3 commits into2ndQuadrant:REL2_x_STABLEfrom
Open
Make backend query execution interruptible.#454nmisch wants to merge 3 commits into2ndQuadrant:REL2_x_STABLEfrom
nmisch wants to merge 3 commits into2ndQuadrant:REL2_x_STABLEfrom
Conversation
The compatibility macros mess up some postgresql headers, yielding compilation failures. pglogical doesn't use affected headers now, so there's no live bug. The next change will add use of such a header.
https://www.postgresql.org/docs/current/libpq-copy.html directs COPY callers to do this. By not doing this, pglogical risked ignoring a late failure in the COPY FROM query. This change unblocks replacing PQexec() with PQsendQuery(). The former silently discards any prior query result, but the latter fails. Since plain PQgetResult() blocks without responding to interrupts, import the PostgreSQL v17 libpq/libpq-be-fe-helpers.h for its interruptible helper. Adapt the header to v9.4+ with PG_VERSION_NUM conditions and changing WL_EXIT_ON_PM_DEATH to explicit proc_exit(). Divide the header into two include-guarded regions, one for v16 content and one for v17+ content.
This prevents v15+ DROP DATABASE hanging when a pglogical process waits inside one of these calls. (See 2ndQuadrant#418 for fixes of that symptom under different conditions.) In all versions, it brings responsiveness of these calls to query cancel, backend termination, and fast shutdown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This prevents v15+ DROP DATABASE hanging when a pglogical process waits inside
one of these calls. (See #418
for fixes of that symptom under different conditions.) In all versions, it
brings responsiveness of these calls to query cancel, backend termination, and
fast shutdown.
Future work should include adopting libpqsrv_connect_params(). I didn't bundle
that in this pull request, because that function doesn't support all the
connection parameters that PQconnectdbParams() supports. Specifically, since
libpqsrv_connect_params() wraps PQconnectStartParams(), it has the limitations
discussed in
https://postgr.es/m/flat/CA%2Bmi_8YyGKA9dWELu63e%3DKL2oN-%2BFe4uca4EtFfb6uQD4Up8pw%40mail.gmail.com.
Future work should also bring interruptibility to calls of
PQgetCopyData(async=false), PQputCopyData(), and PQputCopyEnd().
No new test failures in:
When v17 support appears, compat17/pglogical_compat.h can just #include
"libpq/libpq-be-fe-helpers.h" rather than use the local copy.