aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2014-06-29 17:08:04 +0200
committerAndres Freund <andres@anarazel.de>2014-06-30 12:02:15 +0200
commit6ad903d70a440eb0fbe0b33ceb87a8b0a81cb240 (patch)
treece37d4aaa2e5056f521a42be123d375e8eaaa71a
parentd27d493a4e465c7b3a9e2749e0b69d51aa1e3133 (diff)
downloadpostgresql-6ad903d70a440eb0fbe0b33ceb87a8b0a81cb240.tar.gz
postgresql-6ad903d70a440eb0fbe0b33ceb87a8b0a81cb240.zip
Check interrupts during logical decoding more frequently.
When reading large amounts of preexisting WAL during logical decoding using the SQL interface we possibly could fail to check interrupts in due time. Similarly the same could happen on systems with a very high WAL volume while creating a new logical replication slot, independent of the used interface. Previously these checks where only performed in xlogreader's read_page callbacks, while waiting for new WAL to be produced. That's not sufficient though, if there's never a need to wait. Walsender's send loop already contains a interrupt check. Backpatch to 9.4 where the logical decoding feature was introduced.
-rw-r--r--src/backend/replication/logical/logical.c7
-rw-r--r--src/backend/replication/logical/logicalfuncs.c1
2 files changed, 3 insertions, 5 deletions
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 9eb5cd5ee4d..49f9c7d3a57 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -451,11 +451,6 @@ DecodingContextFindStartpoint(LogicalDecodingContext *ctx)
XLogRecord *record;
char *err = NULL;
- /*
- * If the caller requires that interrupts be checked, the read_page
- * callback should do so, as those will often wait.
- */
-
/* the read_page callback waits for new WAL */
record = XLogReadRecord(ctx->reader, startptr, &err);
if (err)
@@ -470,6 +465,8 @@ DecodingContextFindStartpoint(LogicalDecodingContext *ctx)
/* only continue till we found a consistent spot */
if (DecodingContextReady(ctx))
break;
+
+ CHECK_FOR_INTERRUPTS();
}
ctx->slot->data.confirmed_flush = ctx->reader->EndRecPtr;
diff --git a/src/backend/replication/logical/logicalfuncs.c b/src/backend/replication/logical/logicalfuncs.c
index 2da6bb10b22..a3a58e6a49c 100644
--- a/src/backend/replication/logical/logicalfuncs.c
+++ b/src/backend/replication/logical/logicalfuncs.c
@@ -438,6 +438,7 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
if (upto_nchanges != 0 &&
upto_nchanges <= p->returned_rows)
break;
+ CHECK_FOR_INTERRUPTS();
}
}
PG_CATCH();