DBZ-1684 Make sure publication initialized prior to slot
This is to avoid the need to restart the connector when streaming begins due to an error that the publication can't be found. It would seem based on testing that since we create the replication slot early on when it does not exist, then when streaming starts its confused about trying to marry a newly created publication to an slot. By creating the publication before the slot, this works around the problem.
This commit is contained in:
parent
eacc624001
commit
cf60466b02
@ -253,10 +253,12 @@ public ReplicationStream startStreaming(Long offset) throws SQLException, Interr
|
||||
|
||||
@Override
|
||||
public void initConnection() throws SQLException, InterruptedException {
|
||||
// See https://www.postgresql.org/docs/current/logical-replication-quick-setup.html
|
||||
// For pgoutput specifically, the publication must be created before the slot.
|
||||
initPublication();
|
||||
if (!hasInitedSlot) {
|
||||
initReplicationSlot();
|
||||
}
|
||||
initPublication();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -278,6 +280,10 @@ public Optional<SlotCreationResult> createReplicationSlot() throws SQLException
|
||||
tempPart = "TEMPORARY";
|
||||
}
|
||||
|
||||
// See https://www.postgresql.org/docs/current/logical-replication-quick-setup.html
|
||||
// For pgoutput specifically, the publication must be created prior to the slot.
|
||||
initPublication();
|
||||
|
||||
try (Statement stmt = pgConnection().createStatement()) {
|
||||
String createCommand = String.format(
|
||||
"CREATE_REPLICATION_SLOT %s %s LOGICAL %s",
|
||||
|
Loading…
Reference in New Issue
Block a user