Skip to content

Commit a6a8398

Browse files
fix(mysql): support more snapshot modes
1 parent 0bddc7d commit a6a8398

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

plugin-debezium-mysql/src/main/java/io/kestra/plugin/debezium/mysql/Capture.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,16 @@ protected Properties properties(RunContext runContext, Path offsetFile, Path his
7575
props.setProperty("include.schema.changes", "false");
7676

7777
if (this.snapshotMode != null) {
78-
props.setProperty("snapshot.mode", runContext.render(this.snapshotMode).as(SnapshotMode.class).orElseThrow().name().toLowerCase(Locale.ROOT));
78+
SnapshotMode rSnapshotMode = runContext.render(this.snapshotMode).as(SnapshotMode.class).orElseThrow();
79+
80+
// we map here for backward compatibility
81+
if (rSnapshotMode == SnapshotMode.SCHEMA_ONLY) {
82+
rSnapshotMode = SnapshotMode.NO_DATA;
83+
} else if (rSnapshotMode == SnapshotMode.SCHEMA_ONLY_RECOVERY) {
84+
rSnapshotMode = SnapshotMode.RECOVERY;
85+
}
86+
87+
props.setProperty("snapshot.mode", rSnapshotMode.name().toLowerCase(Locale.ROOT));
7988
}
8089

8190
return props;

plugin-debezium-mysql/src/main/java/io/kestra/plugin/debezium/mysql/MysqlInterface.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
public interface MysqlInterface {
1010
@Schema(
1111
title = "Specifies the criteria for running a snapshot when the connector starts.",
12-
description = " Possible settings are:\n" +
12+
description = "Possible settings are:\n" +
1313
"- `INITIAL`: The connector runs a snapshot only when no offsets have been recorded for the logical server name.\n" +
1414
"- `INITIAL_ONLY`: The connector runs a snapshot only when no offsets have been recorded for the logical server name and then stops; i.e. it will not read change events from the binlog.\n" +
1515
"- `WHEN_NEEDED`: The connector runs a snapshot upon startup whenever it deems it necessary. That is, when no offsets are available, or when a previously recorded offset specifies a binlog location or GTID that is not available in the server.\n" +
1616
"- `NEVER`: The connector never uses snapshots. Upon first startup with a logical server name, the connector reads from the beginning of the binlog. Configure this behavior with care. It is valid only when the binlog is guaranteed to contain the entire history of the database.\n" +
17-
"- `SCHEMA_ONLY`: The connector runs a snapshot of the schemas and not the data. This setting is useful when you do not need the topics to contain a consistent snapshot of the data but need them to have only the changes since the connector was started.\n" +
18-
"- `SCHEMA_ONLY_RECOVERY`: This is a recovery setting for a connector that has already been capturing changes. When you restart the connector, this setting enables recovery of a corrupted or lost database history topic. You might set it periodically to \"clean up\" a database history topic that has been growing unexpectedly. Database history topics require infinite retention."
17+
"- `SCHEMA_ONLY` (**deprecated**): The connector runs a snapshot of the schemas and not the data. This setting is useful when you do not need the topics to contain a consistent snapshot of the data but need them to have only the changes since the connector was started. Use `NO_DATA` instead.\n" +
18+
"- `SCHEMA_ONLY_RECOVERY` (**deprecated**): This is a recovery setting for a connector that has already been capturing changes. When you restart the connector, this setting enables recovery of a corrupted or lost database history topic. You might set it periodically to \"clean up\" a database history topic that has been growing unexpectedly. Database history topics require infinite retention. Use `RECOVERY` instead.\n" +
19+
"- `ALWAYS`: The connector performs a snapshot every time that it starts.\n" +
20+
"- `NO_DATA`: The connector runs a snapshot that captures only the schema, but not any table data. Use this option if you do not need the topics to contain a consistent snapshot of the data.\n" +
21+
"- `RECOVERY`: Restores a database schema history topic that is lost or corrupted by rebuilding it from the source tables.\n"
1922
)
2023
@NotNull
2124
Property<SnapshotMode> getSnapshotMode();
@@ -36,6 +39,9 @@ public enum SnapshotMode {
3639
WHEN_NEEDED,
3740
NEVER,
3841
SCHEMA_ONLY,
39-
SCHEMA_ONLY_RECOVERY
42+
SCHEMA_ONLY_RECOVERY,
43+
NO_DATA,
44+
ALWAYS,
45+
RECOVERY
4046
}
4147
}

0 commit comments

Comments
 (0)