Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6ad903d

Browse files
committed
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.
1 parent d27d493 commit 6ad903d

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/backend/replication/logical/logical.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,6 @@ DecodingContextFindStartpoint(LogicalDecodingContext *ctx)
451451
XLogRecord *record;
452452
char *err = NULL;
453453

454-
/*
455-
* If the caller requires that interrupts be checked, the read_page
456-
* callback should do so, as those will often wait.
457-
*/
458-
459454
/* the read_page callback waits for new WAL */
460455
record = XLogReadRecord(ctx->reader, startptr, &err);
461456
if (err)
@@ -470,6 +465,8 @@ DecodingContextFindStartpoint(LogicalDecodingContext *ctx)
470465
/* only continue till we found a consistent spot */
471466
if (DecodingContextReady(ctx))
472467
break;
468+
469+
CHECK_FOR_INTERRUPTS();
473470
}
474471

475472
ctx->slot->data.confirmed_flush = ctx->reader->EndRecPtr;

src/backend/replication/logical/logicalfuncs.c

+1
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
438438
if (upto_nchanges != 0 &&
439439
upto_nchanges <= p->returned_rows)
440440
break;
441+
CHECK_FOR_INTERRUPTS();
441442
}
442443
}
443444
PG_CATCH();

0 commit comments

Comments
 (0)