Skip to content

Commit

Permalink
DBZ-6271 allow for quiet failure of bin log retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
alwaysbemark authored and jpechane committed Apr 4, 2023
1 parent 4b41e0e commit ded4707
Showing 1 changed file with 5 additions and 11 deletions.
Expand Up @@ -270,17 +270,7 @@ protected void determineSnapshotOffset(RelationalSnapshotContext<MySqlPartition,
}
final MySqlOffsetContext offsetContext = MySqlOffsetContext.initial(connectorConfig);
ctx.offset = offsetContext;
if (connectorConfig.getSnapshotMode().shouldStream()) {
LOGGER.info("Read binlog position of MySQL primary server");
setBinlogPosition(offsetContext);
}
else {
LOGGER.info("Skipped retrieving bin log as streaming CDC wasn't requested");
}
tryStartingSnapshot(ctx);
}

private void setBinlogPosition(MySqlOffsetContext offsetContext) throws SQLException {
LOGGER.info("Read binlog position of MySQL primary server");
final String showMasterStmt = "SHOW MASTER STATUS";
connection.query(showMasterStmt, rs -> {
if (rs.next()) {
Expand All @@ -298,11 +288,15 @@ private void setBinlogPosition(MySqlOffsetContext offsetContext) throws SQLExcep
LOGGER.info("\t using binlog '{}' at position '{}'", binlogFilename, binlogPosition);
}
}
else if (!connectorConfig.getSnapshotMode().shouldStream()) {
LOGGER.info("Failed retrieving binlog position, continuing as streaming CDC wasn't requested");
}
else {
throw new DebeziumException("Cannot read the binlog filename and position via '" + showMasterStmt
+ "'. Make sure your server is correctly configured");
}
});
tryStartingSnapshot(ctx);
}

private void addSchemaEvent(RelationalSnapshotContext<MySqlPartition, MySqlOffsetContext> snapshotContext,
Expand Down

0 comments on commit ded4707

Please sign in to comment.