DBZ-7786 Creates shared files; intial edits to incorporate into MariaDB

This commit is contained in:
roldanbob 2024-06-25 15:36:20 -04:00 committed by Chris Cranford
parent d2fd46e88b
commit 11fa0ba0db
6 changed files with 4485 additions and 3572 deletions

View File

@ -17,38 +17,12 @@ ifdef::community[]
:linkattrs:
:icons: font
:source-highlighter: highlight.js
:MARIADB:
toc::[]
endif::community[]
// ifdef::shared[]
MariaDB has a binary log (binlog) that records all operations in the order in which they are committed to the database. This includes changes to table schemas as well as changes to the data in tables. MariaDB uses the binlog for replication and recovery.
The {prodname} MariaDB connector reads the binlog, produces change events for row-level `INSERT`, `UPDATE`, and `DELETE` operations, and emits the change events to Kafka topics. Client applications read those Kafka topics.
As MariaDB is typically set up to purge binlogs after a specified period of time, the MariaDB connector performs an initial _consistent snapshot_ of each of your databases. The MariaDB connector reads the binlog from the point at which the snapshot was made.
ifdef::community[]
For information about the MariaDB Database versions that are compatible with this connector, see the link:https://debezium.io/releases/[{prodname} release overview].
endif::community[]
ifdef::product[]
For information about the MariaDB Database versions that are compatible with this connector, see the link:{LinkDebeziumSupportedConfigurations}[{NameDebeziumSupportedConfigurations}].
endif::product[]
ifdef::product[]
Information and procedures for using a {prodname} MariaDB connector are organized as follows:
* xref:how-debezium-mariadb-connectors-work[]
* xref:descriptions-of-debezium-mariadb-connector-data-change-events[]
* xref:how-debezium-mariadb-connectors-map-data-types[]
* xref:debezium-mariadb-connector-converters[]
* xref:setting-up-mariadb-to-run-a-debezium-connector[]
* xref:deployment-of-debezium-mariadb-connectors[]
* xref:monitoring-debezium-mariadb-connector-performance[]
* xref:how-debezium-mariadb-connectors-handle-faults-and-problems[]
endif::product[]
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=mariadb-mysql-intro]
// Type: assembly
// ModuleID: how-debezium-mariadb-connectors-work
@ -56,24 +30,7 @@ endif::product[]
[[how-the-mariadb-connector-works]]
== How the connector works
// ifdef::shared[]
An overview of the MariaDB topologies that the connector supports is useful for planning your application. To optimally configure and run a {prodname} MariaDB connector, it is helpful to understand how the connector tracks the structure of tables, exposes schema changes, performs snapshots, and determines Kafka topic names.
ifdef::product[]
Details are in the following topics:
* xref:mariadb-topologies-supported-by-debezium-connectors[]
* xref:supplemental-configuration-for-connecting-debezium-to-mariadb[]
* xref:how-debezium-mariadb-connectors-handle-database-schema-changes[]
* xref:how-debezium-mariadb-connectors-expose-database-schema-changes[]
* xref:how-debezium-mariadb-connectors-perform-database-snapshots[]
* xref:debezium-mariadb-ad-hoc-snapshots[]
* xref:debezium-mariadb-incremental-snapshots[]
* xref:default-names-of-kafka-topics-that-receive-debezium-mariadb-change-event-records[]
endif::product[]
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=how-connector-works-intro]
// Type: concept
// ModuleID: mariadb-topologies-supported-by-debezium-connectors
@ -110,31 +67,7 @@ Because these hosted options do not allow a global read lock, table-level locks
[[mariadb-schema-history-topic]]
=== Schema history topic
// ifdef::shared[]
When a database client queries a database, the client uses the databases current schema.
However, the database schema can be changed at any time, which means that the connector must be able to identify what the schema was at the time each insert, update, or delete operation was recorded.
Also, a connector cannot necessarily apply the current schema to every event.
If an event is relatively old, it's possible that it was recorded before the current schema was applied.
To ensure correct processing of events that occur after a schema change, MariaDB includes in the transaction log not only the row-level changes that affect the data, but also the DDL statements that are applied to the database.
As the connector encounters these DDL statements in the binlog, it parses them and updates an in-memory representation of each tables schema.
The connector uses this schema representation to identify the structure of the tables at the time of each insert, update, or delete operation and to produce the appropriate change event.
In a separate database schema history Kafka topic, the connector records all DDL statements along with the position in the binlog where each DDL statement appeared.
When the connector restarts after either a crash or a graceful stop, it starts reading the binlog from a specific position, that is, from a specific point in time.
The connector rebuilds the table structures that existed at this point in time by reading the database schema history Kafka topic and parsing all DDL statements up to the point in the binlog where the connector is starting.
This database schema history topic is for internal connector use only.
Optionally, the connector can also xref:mariadb-schema-change-topic[emit schema change events to a different topic that is intended for consumer applications].
When the MariaDB connector captures changes in a table to which a schema change tool such as `gh-ost` or `pt-online-schema-change` is applied, there are helper tables created during the migration process.
You must configure the connector to capture changes that occur in these helper tables.
If consumers do not need the records the connector generates for helper tables, configure a {link-prefix}:{link-filtering}#message-filtering[single message transform (SMT)] to remove these records from the messages that the connector emits.
.Additional resources
* xref:mariadb-topic-names[Default names for topics] that receive {prodname} event records.
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=schema-history]
// Type: concept
// ModuleID: how-debezium-mariadb-connectors-expose-database-schema-changes
@ -142,272 +75,8 @@ If consumers do not need the records the connector generates for helper tables,
[id="mariadb-schema-change-topic"]
=== Schema change topic
// ifdef::shared[]
You can configure a {prodname} MariaDB connector to produce schema change events that describe schema changes that are applied to tables in the database.
The connector writes schema change events to a Kafka topic named `_<topicPrefix>_`, where `_topicPrefix_` is the namespace specified in the xref:mariadb-property-topic-prefix[`topic.prefix`] connector configuration property.
Messages that the connector sends to the schema change topic contain a payload, and, optionally, also contain the schema of the change event message.
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=schema-change]
The schema for the schema change event has the following elements:
`name`:: The name of the schema change event message.
`type`:: The type of the change event message.
`version`:: The version of the schema. The version is an integer that is incremented each time the schema is changed.
`fields`:: The fields that are included in the change event message.
.Example: Schema of the MariaDB connector schema change topic
The following example shows a typical schema in JSON format.
[source,json,indent=0,subs="+attributes"]
----
{
"schema": {
"type": "struct",
"fields": [
{
"type": "string",
"optional": false,
"field": "databaseName"
}
],
"optional": false,
"name": "io.debezium.connector.mariadb.SchemaChangeKey",
"version": 1
},
"payload": {
"databaseName": "inventory"
}
}
----
The payload of a schema change event message includes the following elements:
`ddl`:: Provides the SQL `CREATE`, `ALTER`, or `DROP` statement that results in the schema change.
`databaseName`:: The name of the database to which the DDL statements are applied.
The value of `databaseName` serves as the message key.
`pos`:: The position in the binlog where the statements appear.
`tableChanges`:: A structured representation of the entire table schema after the schema change.
The `tableChanges` field contains an array that includes entries for each column of the table.
Because the structured representation presents data in JSON or Avro format, consumers can easily read messages without first processing them through a DDL parser.
[IMPORTANT]
====
For a table that is in capture mode, the connector not only stores the history of schema changes in the schema change topic, but also in an internal database schema history topic.
The internal database schema history topic is for connector use only, and it is not intended for direct use by consuming applications.
Ensure that applications that require notifications about schema changes consume that information only from the schema change topic.
====
[IMPORTANT]
====
Never partition the database schema history topic.
For the database schema history topic to function correctly, it must maintain a consistent, global order of the event records that the connector emits to it.
To ensure that the topic is not split among partitions, set the partition count for the topic by using one of the following methods:
* If you create the database schema history topic manually, specify a partition count of `1`.
* If you use the Apache Kafka broker to create the database schema history topic automatically, the topic is created, set the value of the link:{link-kafka-docs}/#brokerconfigs_num.partitions[Kafka `num.partitions`] configuration option to `1`.
====
[WARNING]
====
The format of the messages that a connector emits to its schema change topic is in an incubating state and is subject to change without notice.
====
.Example: Message emitted to the MariaDB connector schema change topic
The following example shows a typical schema change message in JSON format.
The message contains a logical representation of the table schema.
[source,json,indent=0,subs="+attributes"]
----
{
"schema": { },
"payload": {
"source": { // <1>
"version": "{debezium-version}",
"connector": "mariadb",
"name": "mariadb",
"ts_ms": 1651535750218, // <2>
"ts_us": 1651535750218000, // <2>
"ts_ns": 1651535750218000000, // <2>
"snapshot": "false",
"db": "inventory",
"sequence": null,
"table": "customers",
"server_id": 223344,
"gtid": null,
"file": "mariadb-bin.000003",
"pos": 570,
"row": 0,
"thread": null,
"query": null
},
"databaseName": "inventory", <3>
"schemaName": null,
"ddl": "ALTER TABLE customers ADD middle_name varchar(255) AFTER first_name", <4>
"tableChanges": [ <5>
{
"type": "ALTER", <6>
"id": "\"inventory\".\"customers\"", <7>
"table": { <8>
"defaultCharsetName": "utf8mb4",
"primaryKeyColumnNames": [ <9>
"id"
],
"columns": [ <10>
{
"name": "id",
"jdbcType": 4,
"nativeType": null,
"typeName": "INT",
"typeExpression": "INT",
"charsetName": null,
"length": null,
"scale": null,
"position": 1,
"optional": false,
"autoIncremented": true,
"generated": true
},
{
"name": "first_name",
"jdbcType": 12,
"nativeType": null,
"typeName": "VARCHAR",
"typeExpression": "VARCHAR",
"charsetName": "utf8mb4",
"length": 255,
"scale": null,
"position": 2,
"optional": false,
"autoIncremented": false,
"generated": false
},
{
"name": "middle_name",
"jdbcType": 12,
"nativeType": null,
"typeName": "VARCHAR",
"typeExpression": "VARCHAR",
"charsetName": "utf8mb4",
"length": 255,
"scale": null,
"position": 3,
"optional": true,
"autoIncremented": false,
"generated": false
},
{
"name": "last_name",
"jdbcType": 12,
"nativeType": null,
"typeName": "VARCHAR",
"typeExpression": "VARCHAR",
"charsetName": "utf8mb4",
"length": 255,
"scale": null,
"position": 4,
"optional": false,
"autoIncremented": false,
"generated": false
},
{
"name": "email",
"jdbcType": 12,
"nativeType": null,
"typeName": "VARCHAR",
"typeExpression": "VARCHAR",
"charsetName": "utf8mb4",
"length": 255,
"scale": null,
"position": 5,
"optional": false,
"autoIncremented": false,
"generated": false
}
],
"attributes": [ <11>
{
"customAttribute": "attributeValue"
}
]
}
}
]
}
}
----
.Descriptions of fields in messages emitted to the schema change topic
[cols="1,4,5",options="header"]
|===
|Item |Field name |Description
|1
|`source`
|The `source` field is structured exactly as standard data change events that the connector writes to table-specific topics.
This field is useful to correlate events on different topics.
|2
|`ts_ms`, `ts_us`, `ts_ns`
|Optional field that displays the time at which the connector processed the event.
The time is based on the system clock in the JVM running the Kafka Connect task. +
+
In the source object, ts_ms indicates the time that the change was made in the database. By comparing the value for payload.source.ts_ms with the value for payload.ts_ms, you can determine the lag between the source database update and Debezium.
|3
|`databaseName` +
`schemaName`
|Identifies the database and the schema that contains the change.
The value of the `databaseName` field is used as the message key for the record.
|4
|`ddl`
|This field contains the DDL that is responsible for the schema change.
The `ddl` field can contain multiple DDL statements.
Each statement applies to the database in the `databaseName` field.
Multiple DDL statements appear in the order in which they were applied to the database. +
+
Clients can submit multiple DDL statements that apply to multiple databases.
If MariaDB applies them atomically, the connector takes the DDL statements in order, groups them by database, and creates a schema change event for each group.
If MariaDB applies them individually, the connector creates a separate schema change event for each statement.
|5
|`tableChanges`
|An array of one or more items that contain the schema changes generated by a DDL command.
|6
|`type`
a|Describes the kind of change. The value is one of the following:
`CREATE`:: Table created.
`ALTER`:: Table modified.
`DROP`:: Table deleted.
|7
|`id`
|Full identifier of the table that was created, altered, or dropped.
In the case of a table rename, this identifier is a concatenation of `_<old>_,_<new>_` table names.
|8
|`table`
|Represents table metadata after the applied change.
|9
|`primaryKeyColumnNames`
|List of columns that compose the table's primary key.
|10
|`columns`
|Metadata for each column in the changed table.
|11
|`attributes`
|Custom attribute metadata for each table change.
|===
For more information, see xref:mariadb-schema-history-topic[schema history topic].
// endif::shared[]
// Type: concept
// Title: How {prodname} MariaDB connectors perform database snapshots
@ -415,263 +84,21 @@ For more information, see xref:mariadb-schema-history-topic[schema history topic
[[mariadb-snapshots]]
=== Snapshots
// ifdef::shared[]
When a {prodname} MariaDB connector is first started, it performs an initial _consistent snapshot_ of your database.
This snapshot enables the connector to establish a baseline for the current state of the database.
{prodname} can use different modes when it runs a snapshot.
The snapshot mode is determined by the xref:mariadb-property-snapshot-mode[`snapshot.mode`] configuration property.
The default value of the property is `initial`.
You can customize the way that the connector creates snapshots by changing the value of the `snapshot.mode` property.
ifdef::product[]
You can find more information about snapshots in the following sections:
* xref:debezium-mariadb-ad-hoc-snapshots[]
* xref:debezium-mariadb-incremental-snapshots[]
endif::product[]
The connector completes a series of tasks when it performs the snapshot.
The exact steps vary with the snapshot mode and with the table locking policy that is in effect for the database.
The {prodname} MariaDB connector completes different steps when it performs an initial snapshot that uses a xref:initial-snapshot-workflow-with-global-read-lock[global read lock] or xref:initial-snapshot-workflow-with-table-level-locks[table-level locks].
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=snapshots]
// Type: concept
// ModuleID: debezium-mariadb-description-of-the-workflow-for-initial-snapshots-that-use-a-global-read-lock
[id="initial-snapshot-workflow-with-global-read-lock"]
==== Initial snapshots that use a global read lock
// ifdef::shared[]
You can customize the way that the connector creates snapshots by changing the value of the `snapshot.mode` property.
If you configure a different snapshot mode, the connector completes the snapshot by using a modified version of this workflow.
For information about the snapshot process in environments that do not permit global read locks, see the xref:snapshot-workflow-with-table-level-locks[snapshot workflow for table-level locks].
.Default workflow that the {prodname} MariaDB connector uses to perform an initial snapshot with a global read lock
The following table shows the steps in the workflow that {prodname} follows to create a snapshot with a global read lock.
[cols="1a,9a",options="header",subs="+attributes"]
|===
|Step |Action
|1
a|Establish a connection to the database.
|2
|Determine the tables to be captured.
By default, the connector captures the data for all non-system tables.
After the snapshot completes, the connector continues to stream data for the specified tables.
If you want the connector to capture data only from specific tables you can direct the connector to capture the data for only a subset of tables or table elements by setting properties such as xref:{context}-property-table-include-list[`table.include.list`] or xref:{context}-property-table-exclude-list[`table.exclude.list`].
|3
|Obtain a global read lock on the tables to be captured to block _writes_ by other database clients. +
+
The snapshot itself does not prevent other clients from applying DDL that might interfere with the connector's attempt to read the binlog position and table schemas.
The connector retains the global read lock while it reads the binlog position, and releases the lock as described in a later step.
|4
a|Start a transaction with link:https://mariadb.com/kb/en/set-transaction/#repeatable-read[repeatable read semantics] to ensure that all subsequent reads within the transaction are done against the _consistent snapshot_.
+
[NOTE]
====
The use of these isolation semantics can slow the progress of the snapshot.
If the snapshot takes too long to complete, consider using a different isolation configuration, or skip the initial snapshot and run an xref:debezium-mariadb-incremental-snapshots[incremental snapshot] instead.
====
|5
|Read the current binlog position.
|6
a|Capture the structure of all tables in the database, or all tables that are designated for capture.
The connector persists schema information in its internal database schema history topic, including all necessary `DROP...` and `CREATE...` DDL statements. +
The schema history provides information about the structure that is in effect when a change event occurs.
+
[NOTE]
====
By default, the connector captures the schema of every table in the database, including tables that are not configured for capture.
If tables are not configured for capture, the initial snapshot captures only their structure; it does not capture any table data. +
+
For more information about why snapshots persist schema information for tables that you did not include in the initial snapshot, see xref:understanding-why-initial-snapshots-capture-the-schema-history-for-all-tables[Understanding why initial snapshots capture the schema for all tables].
====
|7
|Release the global read lock obtained in Step 3.
Other database clients can now write to the database.
|8
a|At the binlog position that the connector read in Step 5, the connector begins to scan the tables that are designated for capture.
During the scan, the connector completes the following tasks:
. Confirms that the table was created before the snapshot began.
If the table was created after the snapshot began, the connector skips the table.
After the snapshot is complete, and the connector transitions to streaming, it emits change events for any tables that were created after the snapshot began.
. Produces a `read` event for each row that is captured from a table.
All `read` events contain the same binlog position, which is the position that was obtained in step 5.
. Emits each `read` event to the Kafka topic for the source table.
. Releases data table locks, if applicable.
|9
|Commit the transaction.
|10
|Record the successful completion of the snapshot in the connector offsets.
|===
The resulting initial snapshot captures the current state of each row in the captured tables.
From this baseline state, the connector captures subsequent changes as they occur.
After the snapshot process begins, if the process is interrupted due to connector failure, rebalancing, or other reasons, the process restarts after the connector restarts.
After the connector completes the initial snapshot, it continues streaming from the position that it read in Step 5 so that it does not miss any updates.
If the connector stops again for any reason, after it restarts, it resumes streaming changes from where it previously left off.
After the connector restarts, if the logs have been pruned, the connector's position in the logs might no longer available.
The connector then fails, and returns an error that indicates that a new snapshot is required.
To configure the connector to automatically initiate a snapshot in this situation, set the value of the xref:{context}-property-snapshot-mode[`snapshot.mode`] property to `when_needed`.
For more tips on troubleshooting the {prodname} MariaDB connector, see xref:mariadb-when-things-go-wrong[behavior when things go wrong].
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=initial-snap-global]
// Type: concept
[id="initial-snapshot-workflow-with-table-level-locks"]
==== Initial snapshots that use table-level locks
// ifdef::shared[]
In some database environments administrators do not permit global read locks.
If the {prodname} MariaDB connector detects that global read locks are not permitted, the connector uses table-level locks when it performs snapshots.
For the connector to perform a snapshot that uses table-level locks, the database account that the {prodname} connector uses to connect to MariaDB must have `LOCK TABLES` privileges.
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=initial-snap-table-lock]
.Default workflow that the {prodname} MariaDB connector uses to perform an initial snapshot with table-level locks
The following workflow lists the steps that {prodname} takes to create a snapshot with table-level read locks.
For information about the snapshot process in environments that do not permit global read locks, see the xref:initial-snapshot-workflow-with-global-read-lock[snapshot workflow for global read locks].
[id="snapshot-workflow-with-table-level-locks"]
[cols="1,9",options="header",subs="+attributes"]
|===
|Step |Action
|1
|Establish a connection to the database.
|2
|Determine the tables to be captured.
By default, the connector captures all non-system tables.
To have the connector capture a subset of tables or table elements, you can set a number of `include` and `exclude` properties to filter the data, for example, xref:mariadb-property-table-include-list[`table.include.list`] or xref:mariadb-property-table-exclude-list[`table.exclude.list`].
|3
|Obtain table-level locks.
|4
a|Start a transaction with link:https://mariadb.com/kb/en/set-transaction/#repeatable-read[repeatable read semantics] to ensure that all subsequent reads within the transaction are done against the _consistent snapshot_.
// |5
// |Read and filter the names of the databases and tables.
|5
a|Read the current binlog position.
|6
a|Read the schema of the databases and tables for which the connector is configured to capture changes.
The connector persists schema information in its internal database schema history topic, including all necessary `DROP...` and `CREATE...` DDL statements. +
The schema history provides information about the structure that is in effect when a change event occurs.
+
[NOTE]
====
By default, the connector captures the schema of every table in the database, including tables that are not configured for capture.
If tables are not configured for capture, the initial snapshot captures only their structure; it does not capture any table data.
For more information about why snapshots persist schema information for tables that you did not include in the initial snapshot, see xref:understanding-why-initial-snapshots-capture-the-schema-history-for-all-tables[Understanding why initial snapshots capture the schema for all tables].
====
|7
a|At the binlog position that the connector read in Step 5, the connector begins to scan the tables that are designated for capture.
During the scan, the connector completes the following tasks:
. Confirms that the table was created before the snapshot began.
If the table was created after the snapshot began, the connector skips the table.
After the snapshot is complete, and the connector transitions to streaming, it emits change events for any tables that were created after the snapshot began.
. Produces a `read` event for each row that is captured from a table.
All `read` events contain the same binlog position, which is the position that was obtained in step 5.
. Emits each `read` event to the Kafka topic for the source table.
. Releases data table locks, if applicable.
|8
a|Commit the transaction.
|9
|Release the table-level locks.
Other database clients can now write to any previously locked tables.
|10
a|Record the successful completion of the snapshot in the connector offsets.
|===
[id="mariadb-connector-snapshot-mode-options"]
.Settings for `snapshot.mode` connector configuration property
[cols="30%a,70%a",options="header"]
|===
|Setting |Description
|`always`
|The connector performs a snapshot every time that it starts.
The snapshot includes the structure and data of the captured tables.
Specify this value to populate topics with a complete representation of the data from the captured tables every time that the connector starts.
After the snapshot completes, the connector begins to stream event records for subsequent database changes.
|`initial`
|The connector performs a database snapshot as described in the xref:initial-snapshot-workflow-with-global-read-lock[default workflow for creating an initial snapshot].
After the snapshot completes, the connector begins to stream event records for subsequent database changes.
|`initial_only`
|The connector performs a database snapshot.
After the snapshot completes, the connector stops, and does not stream event records for subsequent database changes.
|`schema_only`
|Deprecated, see `no_data`.
|`no_data`
|The connector captures the structure of all relevant tables, performing all the steps described in the xref:initial-snapshot-workflow-with-global-read-lock[default workflow for creating an initial snapshot], except that it does not create `READ` events to represent the data set at the point of the connector's start-up (Step 7.2).
|`never`
|When the connector starts, rather than performing a snapshot, it immediately begins to stream event records for subsequent database changes.
This option is under consideration for future deprecation, in favor of the `no_data` option.
|`schema_only_recovery`
|Deprecated, see `recovery`.
|`recovery`
|Set this option to restore a database schema history topic that is lost or corrupted.
After a restart, the connector runs a snapshot that rebuilds the topic from the source tables.
You can also set the property to periodically prune a database schema history topic that experiences unexpected growth. +
+
WARNING: Do not use this mode to perform a snapshot if schema changes were committed to the database after the last connector shutdown.
|`when_needed`
|After the connector starts, it performs a snapshot only if it detects one of the following circumstances:
* It cannot detect any topic offsets.
* A previously recorded offset specifies a log position that is not available on the server.
ifdef::community[]
|`configuration_based`
|Set the snapshot mode to `configuration_based` to control snapshot behavior through the set of connector properties that have the prefix 'snapshot.mode.configuration.based'.
endif::community[]
ifdef::community[]
|`custom`
|The `custom` snapshot mode lets you inject your own implementation of the `io.debezium.spi.snapshot.Snapshotter` interface.
Set the `snapshot.mode.custom.name` configuration property to the name provided by the `name()` method of your implementation.
The name is specified on the classpath of your Kafka Connect cluster.
If you use the `EmbeddedEngine`, the name is included in the connector JAR file.
For more information, see xref:connector-custom-snapshot[custom snapshotter SPI].
endif::community[]
|===
For more information, see xref:mariadb-property-snapshot-mode[`snapshot.mode`] in the table of connector configuration properties.
// endif::shared[]
// ModuleID: mariadb-description-of-why-initial-snapshots-capture-the-schema-history-for-all-tables
// Title: Description of why initial snapshots capture the schema history for all tables
@ -679,135 +106,21 @@ For more information, see xref:mariadb-property-snapshot-mode[`snapshot.mode`] i
[id="understanding-why-initial-snapshots-capture-the-schema-history-for-all-tables"]
==== Understanding why initial snapshots capture the schema history for all tables
// ifdef::shared[]
The initial snapshot that a connector runs captures two types of information:
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=why-snapshot-captures-history-all]
Table data::
Information about `INSERT`, `UPDATE`, and `DELETE` operations in tables that are named in the connector's xref:{context}-property-table-include-list[`table.include.list`] property.
Schema data::
DDL statements that describe the structural changes that are applied to tables.
Schema data is persisted to both the internal schema history topic, and to the connector's schema change topic, if one is configured.
After you run an initial snapshot, you might notice that the snapshot captures schema information for tables that are not designated for capture.
By default, initial snapshots are designed to capture schema information for every table that is present in the database, not only from tables that are designated for capture.
Connectors require that the table's schema is present in the schema history topic before they can capture a table.
By enabling the initial snapshot to capture schema data for tables that are not part of the original capture set, {prodname} prepares the connector to readily capture event data from these tables should that later become necessary.
If the initial snapshot does not capture a table's schema, you must add the schema to the history topic before the connector can capture data from the table.
In some cases, you might want to limit schema capture in the initial snapshot.
This can be useful when you want to reduce the time required to complete a snapshot.
Or when {prodname} connects to the database instance through a user account that has access to multiple logical databases, but you want the connector to capture changes only from tables in a specific logic database.
.Additional information
* xref:{context}-capturing-data-from-tables-not-captured-by-the-initial-snapshot-no-schema-change[Capturing data from tables not captured by the initial snapshot (no schema change)]
* xref:{context}-capturing-data-from-new-tables-with-schema-changes[Capturing data from tables not captured by the initial snapshot (schema change)]
* Setting the xref:{context}-property-database-history-store-only-captured-tables-ddl[`schema.history.internal.store.only.captured.tables.ddl`] property to specify the tables from which to capture schema information.
* Setting the xref:{context}-property-database-history-store-only-captured-databases-ddl[`schema.history.internal.store.only.captured.databases.ddl`] property to specify the logical databases from which to capture schema changes.
// endif::shared[]
// Type: procedure
[id="mariadb-capturing-data-from-tables-not-captured-by-the-initial-snapshot-no-schema-change"]
==== Capturing data from tables not captured by the initial snapshot (no schema change)
// ifdef::shared[]
In some cases, you might want the connector to capture data from a table whose schema was not captured by the initial snapshot.
Depending on the connector configuration, the initial snapshot might capture the table schema only for specific tables in the database.
If the table schema is not present in the history topic, the connector fails to capture the table, and reports a missing schema error.
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=cap-tbls-not-in-initial-no-schema-chg]
You might still be able to capture data from the table, but you must perform additional steps to add the table schema.
.Prerequisites
* You want to capture data from a table with a schema that the connector did not capture during the initial snapshot.
* In the transaction log, all entries for the table use the same schema.
For information about capturing data from a new table that has undergone structural changes, see xref:mariadb-capturing-data-from-new-tables-with-schema-changes[Capturing data from tables not captured by the initial snapshot (schema change)].
.Procedure
1. Stop the connector.
2. Remove the internal database schema history topic that is specified by the xref:{context}-property-database-history-kafka-topic[`schema.history.internal.kafka.topic property`].
3. Apply the following changes to the connector configuration:
.. Set the xref:{context}-property-snapshot-mode[`snapshot.mode`] to `schema_only_recovery`.
.. Set the value of xref:{context}-property-database-history-store-only-captured-tables-ddl[`schema.history.internal.store.only.captured.tables.ddl`] to `false`.
.. Add the tables that you want the connector to capture to `table.include.list`.
This guarantees that in the future, the connector can reconstruct the schema history for all tables.
4. Restart the connector.
The snapshot recovery process rebuilds the schema history based on the current structure of the tables.
5. (Optional) After the snapshot completes, initiate an xref:debezium-mariadb-incremental-snapshots[incremental snapshot] to capture existing data for newly added tables along with changes to other tables that occurred while that connector was off-line.
6. (Optional) Reset the `snapshot.mode` back to `schema_only` to prevent the connector from initiating recovery after a future restart.
// endif::shared[]
// Type: procedure
[id="mariadb-capturing-data-from-new-tables-with-schema-changes"]
==== Capturing data from tables not captured by the initial snapshot (schema change)
// ifdef::shared[]
If a schema change is applied to a table, records that are committed before the schema change have different structures than those that were committed after the change.
When {prodname} captures data from a table, it reads the schema history to ensure that it applies the correct schema to each event.
If the schema is not present in the schema history topic, the connector is unable to capture the table, and an error results.
If you want to capture data from a table that was not captured by the initial snapshot, and the schema of the table was modified, you must add the schema to the history topic, if it is not already available.
You can add the schema by running a new schema snapshot, or by running an initial snapshot for the table.
.Prerequisites
* You want to capture data from a table with a schema that the connector did not capture during the initial snapshot.
* A schema change was applied to the table so that the records to be captured do not have a uniform structure.
.Procedure
Initial snapshot captured the schema for all tables (`store.only.captured.tables.ddl` was set to `false`)::
1. Edit the xref:{context}-property-table-include-list[`table.include.list`] property to specify the tables that you want to capture.
2. Restart the connector.
3. Initiate an xref:debezium-mariadb-incremental-snapshots[incremental snapshot] if you want to capture existing data from the newly added tables.
Initial snapshot did not capture the schema for all tables (`store.only.captured.tables.ddl` was set to `true`)::
If the initial snapshot did not save the schema of the table that you want to capture, complete one of the following procedures:
Procedure 1: Schema snapshot, followed by incremental snapshot:::
In this procedure, the connector first performs a schema snapshot.
You can then initiate an incremental snapshot to enable the connector to synchronize data.
1. Stop the connector.
2. Remove the internal database schema history topic that is specified by the xref:{context}-property-database-history-kafka-topic[`schema.history.internal.kafka.topic property`].
3. Clear the offsets in the configured Kafka Connect link:{link-kafka-docs}/#connectconfigs_offset.storage.topic[`offset.storage.topic`].
For more information about how to remove offsets, see the link:https://debezium.io/documentation/faq/#how_to_remove_committed_offsets_for_a_connector[{prodname} community FAQ].
+
[WARNING]
====
Removing offsets should be performed only by advanced users who have experience in manipulating internal Kafka Connect data.
This operation is potentially destructive, and should be performed only as a last resort.
====
4. Set values for properties in the connector configuration as described in the following steps:
.. Set the value of the xref:{context}-property-snapshot-mode[`snapshot.mode`] property to `schema_only`.
.. Edit the xref:{context}-property-table-include-list[`table.include.list`] to add the tables that you want to capture.
5. Restart the connector.
6. Wait for {prodname} to capture the schema of the new and existing tables.
Data changes that occurred any tables after the connector stopped are not captured.
7. To ensure that no data is lost, initiate an xref:debezium-mariadb-incremental-snapshots[incremental snapshot].
Procedure 2: Initial snapshot, followed by optional incremental snapshot:::
In this procedure the connector performs a full initial snapshot of the database.
As with any initial snapshot, in a database with many large tables, running an initial snapshot can be a time-consuming operation.
After the snapshot completes, you can optionally trigger an incremental snapshot to capture any changes that occur while the connector is off-line.
1. Stop the connector.
2. Remove the internal database schema history topic that is specified by the xref:{context}-property-database-history-kafka-topic[`schema.history.internal.kafka.topic property`].
3. Clear the offsets in the configured Kafka Connect link:{link-kafka-docs}/#connectconfigs_offset.storage.topic[`offset.storage.topic`].
For more information about how to remove offsets, see the link:https://debezium.io/documentation/faq/#how_to_remove_committed_offsets_for_a_connector[{prodname} community FAQ].
+
[WARNING]
====
Removing offsets should be performed only by advanced users who have experience in manipulating internal Kafka Connect data.
This operation is potentially destructive, and should be performed only as a last resort.
====
4. Edit the xref:{context}-property-table-include-list[`table.include.list`] to add the tables that you want to capture.
5. Set values for properties in the connector configuration as described in the following steps:
.. Set the value of the xref:{context}-property-snapshot-mode[`snapshot.mode`] property to `initial`.
.. (Optional) Set xref:{context}-property-database-history-store-only-captured-tables-ddl[`schema.history.internal.store.only.captured.tables.ddl`] to `false`.
6. Restart the connector.
The connector takes a full database snapshot.
After the snapshot completes, the connector transitions to streaming.
7. (Optional) To capture any data that changed while the connector was off-line, initiate an xref:debezium-mariadb-incremental-snapshots[incremental snapshot].
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=cap-tbls-not-in-initial-schema-chg]
// Type: concept
// ModuleID: debezium-mariadb-ad-hoc-snapshots
@ -855,28 +168,11 @@ ifdef::community[]
[id="mariadb-read-only-incremental-snapshots"]
==== Read-only incremental snapshots
// ifdef::shared[]
The {prodname} MariaDB connector allows for running incremental snapshots with a read-only connection to the database.
To run an incremental snapshot with read-only access, the connector uses the executed global transaction IDs (GTID) set as high and low watermarks.
The state of a chunk's window is updated by comparing the GTIDs of binary log (binlog) events or the server's heartbeats against low and high watermarks.
To switch to a read-only implementation, set the value of the xref:mariadb-property-read-only[`read.only`] property to `true`.
.Prerequisites
* xref:enable-mariadb-gtids[Enable MariaDB GTIDs].
* If the connector reads from a multi-threaded replica (that is, a replica for which the value of `replica_parallel_workers` is greater than `0`)
you must set one of the following options:
** `replica_preserve_commit_order=ON`
** `slave_preserve_commit_order=ON`
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=readonly-incremental]
==== Ad hoc read-only incremental snapshots
// ifdef::shared[]
When the MariaDB connection is read-only, you can use any of the {link-prefix}:{link-signalling}#sending-signals-to-a-debezium-connector[available signaling channels] without the requirement to use the `source` channel.
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=adhoc-ro-incremental]
// Type: continue
[id="mariadb-snapshot-events"]
@ -903,127 +199,12 @@ include::{partialsdir}/modules/all-connectors/con-connector-blocking-snapshot.ad
[[mariadb-topic-names]]
=== Topic names
// ifdef::shared[]
By default, the MariaDB connector writes change events for all of the `INSERT`, `UPDATE`, and `DELETE` operations that occur in a table to a single Apache Kafka topic that is specific to that table.
The connector uses the following convention to name change event topics:
_topicPrefix.databaseName.tableName_
Suppose that `fulfillment` is the topic prefix, `inventory` is the database name, and the database contains tables named `orders`, `customers`, and `products`.
The {prodname} MariaDB connector emits events to three Kafka topics, one for each table in the database:
----
fulfillment.inventory.orders
fulfillment.inventory.customers
fulfillment.inventory.products
----
The following list provides definitions for the components of the default name:
_topicPrefix_:: The topic prefix as specified by the xref:mariadb-property-topic-prefix[`topic.prefix`] connector configuration property.
_schemaName_:: The name of the schema in which the operation occurred.
_tableName_:: The name of the table in which the operation occurred.
The connector applies similar naming conventions to label its internal database schema history topics, xref:mariadb-schema-change-topic[schema change topics], and xref:mariadb-transaction-metadata[transaction metadata topics].
If the default topic name do not meet your requirements, you can configure custom topic names.
To configure custom topic names, you specify regular expressions in the logical topic routing SMT.
For more information about using the logical topic routing SMT to customize topic naming, see {link-prefix}:{link-topic-routing}#topic-routing[Topic routing].
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=topic-names]
[[mariadb-transaction-metadata]]
=== Transaction metadata
// ifdef::shared[]
{prodname} can generate events that represent transaction boundaries and that enrich data change event messages.
[NOTE]
.Limits on when {prodname} receives transaction metadata
====
{prodname} registers and receives metadata only for transactions that occur after you deploy the connector.
Metadata for transactions that occur before you deploy the connector is not available.
====
{prodname} generates transaction boundary events for the `BEGIN` and `END` delimiters in every transaction.
Transaction boundary events contain the following fields:
`status`:: `BEGIN` or `END`.
`id`:: String representation of the unique transaction identifier.
`ts_ms`:: The time of a transaction boundary event (`BEGIN` or `END` event) at the data source.
If the data source does not provide {prodname} with the event time, then the field instead represents the time at which {prodname} processes the event.
`event_count` (for `END` events):: Total number of events emitted by the transaction.
`data_collections` (for `END` events):: An array of pairs of `data_collection` and `event_count` elements that indicates the number of events that the connector emits for changes that originate from a data collection.
.Example
[source,json,indent=0,subs="+attributes"]
----
{
"status": "BEGIN",
"id": "0e4d5dcd-a33b-11ea-80f1-02010a22a99e:10",
"ts_ms": 1486500577125,
"event_count": null,
"data_collections": null
}
{
"status": "END",
"id": "0e4d5dcd-a33b-11ea-80f1-02010a22a99e:10",
"ts_ms": 1486500577691,
"event_count": 2,
"data_collections": [
{
"data_collection": "s1.a",
"event_count": 1
},
{
"data_collection": "s2.a",
"event_count": 1
}
]
}
----
Unless overridden via the xref:mariadb-property-topic-transaction[`topic.transaction`] option,
the connector emits transaction events to the xref:mariadb-property-topic-prefix[`_<topic.prefix>_`]`.transaction` topic.
.Change data event enrichment
When transaction metadata is enabled the data message `Envelope` is enriched with a new `transaction` field.
This field provides information about every event in the form of a composite of fields:
`id`:: String representation of unique transaction identifier.
`total_order`:: The absolute position of the event among all events generated by the transaction.
`data_collection_order`:: The per-data collection position of the event among all events that were emitted by the transaction.
Following is an example of a message:
[source,json,indent=0,subs="+attributes"]
----
{
"before": null,
"after": {
"pk": "2",
"aa": "1"
},
"source": {
...
},
"op": "c",
"ts_ms": "1580390884335",
"ts_us": "1580390884335472",
"ts_ns": "1580390884335472987",
"transaction": {
"id": "0e4d5dcd-a33b-11ea-80f1-02010a22a99e:10",
"total_order": "1",
"data_collection_order": "1"
}
}
----
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=trans-meta]
// Type: assembly
// ModuleID: descriptions-of-debezium-mariadb-connector-data-change-events
@ -1031,72 +212,7 @@ Following is an example of a message:
[[mariadb-events]]
== Data change events
// ifdef::shared[]
The {prodname} MariaDB connector generates a data change event for each row-level `INSERT`, `UPDATE`, and `DELETE` operation. Each event contains a key and a value. The structure of the key and the value depends on the table that was changed.
{prodname} and Kafka Connect are designed around _continuous streams of event messages_. However, the structure of these events may change over time, which can be difficult for consumers to handle. To address this, each event contains the schema for its content or, if you are using a schema registry, a schema ID that a consumer can use to obtain the schema from the registry. This makes each event self-contained.
The following skeleton JSON shows the basic four parts of a change event. However, how you configure the Kafka Connect converter that you choose to use in your application determines the representation of these four parts in change events. A `schema` field is in a change event only when you configure the converter to produce it. Likewise, the event key and event payload are in a change event only if you configure a converter to produce it. If you use the JSON converter and you configure it to produce all four basic change event parts, change events have this structure:
[source,json,index=0]
----
{
"schema": { //<1>
...
},
"payload": { //<2>
...
},
"schema": { //<3>
...
},
"payload": { //<4>
...
},
}
----
.Overview of change event basic content
[cols="1,2,7",options="header"]
|===
|Item |Field name |Description
|1
|`schema`
|The first `schema` field is part of the event key. It specifies a Kafka Connect schema that describes what is in the event key's `payload` portion. In other words, the first `schema` field describes the structure of the primary key, or the unique key if the table does not have a primary key, for the table that was changed. +
+
It is possible to override the table's primary key by setting the xref:mariadb-property-message-key-columns[`message.key.columns` connector configuration property]. In this case, the first schema field describes the structure of the key identified by that property.
|2
|`payload`
|The first `payload` field is part of the event key. It has the structure described by the previous `schema` field, and it contains the key for the row that was changed.
|3
|`schema`
|The second `schema` field is part of the event value. It specifies the Kafka Connect schema that describes what is in the event value's `payload` portion. In other words, the second `schema` describes the structure of the row that was changed. Typically, this schema contains nested schemas.
|4
|`payload`
|The second `payload` field is part of the event value. It has the structure described by the previous `schema` field and it contains the actual data for the row that was changed.
|===
By default, the connector streams change event records to topics with names that are the same as the event's originating table. See xref:mariadb-topic-names[topic names].
[WARNING]
====
The MariaDB connector ensures that all Kafka Connect schema names adhere to the link:http://avro.apache.org/docs/current/spec.html#names[Avro schema name format]. This means that the logical server name must start with a Latin letter or an underscore, that is, a-z, A-Z, or pass:[_]. Each remaining character in the logical server name and each character in the database and table names must be a Latin letter, a digit, or an underscore, that is, a-z, A-Z, 0-9, or pass:[_]. If there is an invalid character it is replaced with an underscore character.
This can lead to unexpected conflicts if the logical server name, a database name, or a table name contains invalid characters, and the only characters that distinguish names from one another are invalid and thus replaced with underscores.
====
ifdef::product[]
More details are in the following topics:
* xref:about-keys-in-debezium-mariadb-change-events[]
* xref:about-values-in-debezium-mariadb-change-events[]
endif::product[]
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=data-chg-events]
// Type: concept
// ModuleID: about-keys-in-debezium-mariadb-change-events
@ -1104,75 +220,7 @@ endif::product[]
[[mariadb-change-event-keys]]
=== Change event keys
// ifdef::shared[]
A change event's key contains the schema for the changed table's key and the changed row's actual key. Both the schema and its corresponding payload contain a field for each column in the changed table's `PRIMARY KEY` (or unique constraint) at the time the connector created the event.
Consider the following `customers` table, which is followed by an example of a change event key for this table.
[source,sql]
----
CREATE TABLE customers (
id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE KEY
) AUTO_INCREMENT=1001;
----
Every change event that captures a change to the `customers` table has the same event key schema. For as long as the `customers` table has the previous definition, every change event that captures a change to the `customers` table has the following key structure. In JSON, it looks like this:
[source,json,index=0]
----
{
"schema": { <1>
"type": "struct",
"name": "mariadb-server-1.inventory.customers.Key", <2>
"optional": false, <3>
"fields": [ <4>
{
"field": "id",
"type": "int32",
"optional": false
}
]
},
"payload": { <5>
"id": 1001
}
}
----
.Description of change event key
[cols="1,2,7",options="header"]
|===
|Item |Field name |Description
|1
|`schema`
|The schema portion of the key specifies a Kafka Connect schema that describes what is in the key's `payload` portion.
|2
|`mariadb-server-1.inventory.customers.Key`
a|Name of the schema that defines the structure of the key's payload. This schema describes the structure of the primary key for the table that was changed. Key schema names have the format _connector-name_._database-name_._table-name_.`Key`. In this example: +
* `mariadb-server-1` is the name of the connector that generated this event. +
* `inventory` is the database that contains the table that was changed. +
* `customers` is the table that was updated.
|3
|`optional`
|Indicates whether the event key must contain a value in its `payload` field. In this example, a value in the key's payload is required. A value in the key's payload field is optional when a table does not have a primary key.
|4
|`fields`
|Specifies each field that is expected in the `payload`, including each field's name, type, and whether it is required.
|5
|`payload`
|Contains the key for the row for which this change event was generated. In this example, the key, contains a single `id` field whose value is `1001`.
|===
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=event-keys]
// Type: concept
// ModuleID: about-values-in-debezium-mariadb-change-events
@ -1180,652 +228,45 @@ a|Name of the schema that defines the structure of the key's payload. This schem
[[mariadb-change-event-values]]
=== Change event values
// ifdef::shared[]
The value in a change event is a bit more complicated than the key. Like the key, the value has a `schema` section and a `payload` section. The `schema` section contains the schema that describes the `Envelope` structure of the `payload` section, including its nested fields. Change events for operations that create, update or delete data all have a value payload with an envelope structure.
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=event-values]
Consider the same sample table that was used to show an example of a change event key:
[source,sql]
----
CREATE TABLE customers (
id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE KEY
) AUTO_INCREMENT=1001;
----
The value portion of a change event for a change to this table is described for:
* <<mariadb-create-events,_create_ events>>
* <<mariadb-update-events,_update_ events>>
* <<mariadb-primary-key-updates,Primary key updates>>
* <<mariadb-delete-events,_delete_ events>>
* <<mariadb-tombstone-events,Tombstone events>>
* <<mariadb-truncate-events,_truncate_ events>>
// endif::shared[]
// Type: continue
[id="mariadb-create-events"]
=== _create_ events
// ifdef::shared[]
The following example shows the value portion of a change event that the connector generates for an operation that creates data in the `customers` table:
[source,json,options="nowrap",subs="+attributes"]
----
{
"schema": { // <1>
"type": "struct",
"fields": [
{
"type": "struct",
"fields": [
{
"type": "int32",
"optional": false,
"field": "id"
},
{
"type": "string",
"optional": false,
"field": "first_name"
},
{
"type": "string",
"optional": false,
"field": "last_name"
},
{
"type": "string",
"optional": false,
"field": "email"
}
],
"optional": true,
"name": "mariadb-server-1.inventory.customers.Value", // <2>
"field": "before"
},
{
"type": "struct",
"fields": [
{
"type": "int32",
"optional": false,
"field": "id"
},
{
"type": "string",
"optional": false,
"field": "first_name"
},
{
"type": "string",
"optional": false,
"field": "last_name"
},
{
"type": "string",
"optional": false,
"field": "email"
}
],
"optional": true,
"name": "mariadb-server-1.inventory.customers.Value",
"field": "after"
},
{
"type": "struct",
"fields": [
{
"type": "string",
"optional": false,
"field": "version"
},
{
"type": "string",
"optional": false,
"field": "connector"
},
{
"type": "string",
"optional": false,
"field": "name"
},
{
"type": "int64",
"optional": false,
"field": "ts_ms"
},
{
"type": "int64",
"optional": false,
"field": "ts_us"
},
{
"type": "int64",
"optional": false,
"field": "ts_ns"
},
{
"type": "boolean",
"optional": true,
"default": false,
"field": "snapshot"
},
{
"type": "string",
"optional": false,
"field": "db"
},
{
"type": "string",
"optional": true,
"field": "table"
},
{
"type": "int64",
"optional": false,
"field": "server_id"
},
{
"type": "string",
"optional": true,
"field": "gtid"
},
{
"type": "string",
"optional": false,
"field": "file"
},
{
"type": "int64",
"optional": false,
"field": "pos"
},
{
"type": "int32",
"optional": false,
"field": "row"
},
{
"type": "int64",
"optional": true,
"field": "thread"
},
{
"type": "string",
"optional": true,
"field": "query"
}
],
"optional": false,
"name": "io.debezium.connector.mariadb.Source", // <3>
"field": "source"
},
{
"type": "string",
"optional": false,
"field": "op"
},
{
"type": "int64",
"optional": true,
"field": "ts_ms"
},
{
"type": "int64",
"optional": true,
"field": "ts_us"
},
{
"type": "int64",
"optional": true,
"field": "ts_ns"
}
],
"optional": false,
"name": "mariadb-server-1.inventory.customers.Envelope" // <4>
},
"payload": { // <5>
"op": "c", // <6>
"ts_ms": 1465491411815, // <7>
"ts_us": 1465491411815437, // <7>
"ts_ns": 1465491411815437158, // <7>
"before": null, // <8>
"after": { // <9>
"id": 1004,
"first_name": "Anne",
"last_name": "Kretchmar",
"email": "annek@noanswer.org"
},
"source": { // <10>
"version": "{debezium-version}",
"connector": "mariadb",
"name": "mariadb-server-1",
"ts_ms": 0,
"ts_us": 0,
"ts_ns": 0,
"snapshot": false,
"db": "inventory",
"table": "customers",
"server_id": 0,
"gtid": null,
"file": "mariadb-bin.000003",
"pos": 154,
"row": 0,
"thread": 7,
"query": "INSERT INTO customers (first_name, last_name, email) VALUES ('Anne', 'Kretchmar', 'annek@noanswer.org')"
}
}
}
----
.Descriptions of _create_ event value fields
[cols="1,2,7",options="header"]
|===
|Item |Field name |Description
|1
|`schema`
|The value's schema, which describes the structure of the value's payload. A change event's value schema is the same in every change event that the connector generates for a particular table.
|2
|`name`
a|In the `schema` section, each `name` field specifies the schema for a field in the value's payload. +
+
`mariadb-server-1.inventory.customers.Value` is the schema for the payload's `before` and `after` fields. This schema is specific to the `customers` table. +
+
Names of schemas for `before` and `after` fields are of the form `_logicalName_._tableName_.Value`, which ensures that the schema name is unique in the database.
This means that when using the {link-prefix}:{link-avro-serialization}#avro-serialization[Avro converter], the resulting Avro schema for each table in each logical source has its own evolution and history.
|3
|`name`
|`io.debezium.connector.mariadb.Source` is the schema for the payload's `source` field. This schema is specific to the MariaDB connector. The connector uses it for all events that it generates.
|4
|`name`
|`mariadb-server-1.inventory.customers.Envelope` is the schema for the overall structure of the payload, where `mariadb-server-1` is the connector name, `inventory` is the database, and `customers` is the table.
|5
|`payload`
|The value's actual data. This is the information that the change event is providing. +
+
It may appear that the JSON representations of the events are much larger than the rows they describe. This is because the JSON representation must include the schema and the payload portions of the message.
However, by using the {link-prefix}:{link-avro-serialization}#avro-serialization[Avro converter], you can significantly decrease the size of the messages that the connector streams to Kafka topics.
|6
|`op`
a| Mandatory string that describes the type of operation that caused the connector to generate the event. In this example, `c` indicates that the operation created a row. Valid values are:
* `c` = create
* `u` = update
* `d` = delete
* `r` = read (applies to only snapshots)
|7
|`ts_ms`, `ts_us`, `ts_ns`
a| Optional field that displays the time at which the connector processed the event.
The time is based on the system clock in the JVM running the Kafka Connect task. +
+
In the `source` object, `ts_ms` indicates the time that the change was made in the database. By comparing the value for `payload.source.ts_ms` with the value for `payload.ts_ms`, you can determine the lag between the source database update and {prodname}.
|8
|`before`
| An optional field that specifies the state of the row before the event occurred. When the `op` field is `c` for create, as it is in this example, the `before` field is `null` since this change event is for new content.
|9
|`after`
| An optional field that specifies the state of the row after the event occurred. In this example, the `after` field contains the values of the new row's `id`, `first_name`, `last_name`, and `email` columns.
|10
|`source`
a| Mandatory field that describes the source metadata for the event. This field contains information that you can use to compare this event with other events, with regard to the origin of the events, the order in which the events occurred, and whether events were part of the same transaction. The source metadata includes:
* {prodname} version
* Connector name
* binlog name where the event was recorded
* binlog position
* Row within the event
* If the event was part of a snapshot
* Name of the database and table that contain the new row
* ID of the MariaDB thread that created the event (non-snapshot only)
* MariaDB server ID (if available)
* Timestamp for when the change was made in the database
// ifdef::not-shared[]
If the xref:enable-query-log-events[`binlog_annotate_row_events`] MariaDB configuration option is enabled and the connector configuration `include.query` property is enabled, the `source` field also provides the `query` field, which contains the original SQL statement that caused the change event.
// endif::not-shared[]
|===
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=create-events]
// Type: continue
[id="mariadb-update-events"]
=== _update_ events
// ifdef::shared[]
The value of a change event for an update in the sample `customers` table has the same schema as a _create_ event for that table. Likewise, the event value's payload has the same structure. However, the event value payload contains different values in an _update_ event. Here is an example of a change event value in an event that the connector generates for an update in the `customers` table:
[source,json,options="nowrap",subs="+attributes"]
----
{
"schema": { ... },
"payload": {
"before": { // <1>
"id": 1004,
"first_name": "Anne",
"last_name": "Kretchmar",
"email": "annek@noanswer.org"
},
"after": { // <2>
"id": 1004,
"first_name": "Anne Marie",
"last_name": "Kretchmar",
"email": "annek@noanswer.org"
},
"source": { // <3>
"version": "{debezium-version}",
"name": "mariadb-server-1",
"connector": "mariadb",
"name": "mariadb-server-1",
"ts_ms": 1465581029100,
"ts_ms": 1465581029100000,
"ts_ms": 1465581029100000000,
"snapshot": false,
"db": "inventory",
"table": "customers",
"server_id": 223344,
"gtid": null,
"file": "mariadb-bin.000003",
"pos": 484,
"row": 0,
"thread": 7,
"query": "UPDATE customers SET first_name='Anne Marie' WHERE id=1004"
},
"op": "u", // <4>
"ts_ms": 1465581029523, // <5>
"ts_ms": 1465581029523758, // <6>
"ts_ms": 1465581029523758914 // <7>
}
}
----
.Descriptions of _update_ event value fields
[cols="1,2,7",options="header"]
|===
|Item |Field name |Description
|1
|`before`
|An optional field that specifies the state of the row before the event occurred. In an _update_ event value, the `before` field contains a field for each table column and the value that was in that column before the database commit. In this example, the `first_name` value is `Anne.`
|2
|`after`
| An optional field that specifies the state of the row after the event occurred. You can compare the `before` and `after` structures to determine what the update to this row was. In the example, the `first_name` value is now `Anne Marie`.
|3
|`source`
a|Mandatory field that describes the source metadata for the event. The `source` field structure has the same fields as in a _create_ event, but some values are different, for example, the sample _update_ event is from a different position in the binlog. The source metadata includes:
* {prodname} version
* Connector name
* binlog name where the event was recorded
* binlog position
* Row within the event
* If the event was part of a snapshot
* Name of the database and table that contain the updated row
* ID of the MariaDB thread that created the event (non-snapshot only)
* MariaDB server ID (if available)
* Timestamp for when the change was made in the database
// ifdef::not-shared[]
If the xref:enable-query-log-events[`binlog_annotate_row_events`] MariaDB configuration option is enabled and the connector configuration `include.query` property is enabled, the `source` field also provides the `query` field, which contains the original SQL statement that caused the change event.
// endif::not-shared[]
|4
|`op`
a|Mandatory string that describes the type of operation. In an _update_ event value, the `op` field value is `u`, signifying that this row changed because of an update.
|5
|`ts_ms`
a| Optional field that displays the time at which the connector processed the event.
The time is based on the system clock in the JVM running the Kafka Connect task. +
+
In the `source` object, `ts_ms` indicates the time that the change was made in the database. By comparing the value for `payload.source.ts_ms` with the value for `payload.ts_ms`, you can determine the lag between the source database update and {prodname}.
|6
|`ts_us`
a|Optional field that displays the time at which the connector processed the event, in microseconds.
The time is based on the system clock in the JVM running the Kafka Connect task.
|7
|`ts_ns`
a|Optional field that displays the time at which the connector processed the event, in nanoseconds.
The time is based on the system clock in the JVM running the Kafka Connect task.
|===
[NOTE]
====
Updating the columns for a row's primary/unique key changes the value of the row's key. When a key changes, {prodname} outputs _three_ events: a `DELETE` event and a xref:mariadb-tombstone-events[tombstone event] with the old key for the row, followed by an event with the new key for the row. Details are in the next section.
====
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=update-events]
// Type: continue
[id="mariadb-primary-key-updates"]
=== Primary key updates
// ifdef::shared[]
An `UPDATE` operation that changes a row's primary key field(s) is known
as a primary key change. For a primary key change, in place of an `UPDATE` event record, the connector emits a `DELETE` event record for the old key and a `CREATE` event record for the new (updated) key. These events have the usual structure and content, and in addition, each one has a message header related to the primary key change:
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=pkey-updates]
* The `DELETE` event record has `__debezium.newkey` as a message header. The value of this header is the new primary key for the updated row.
* The `CREATE` event record has `__debezium.oldkey` as a message header. The value of this header is the previous (old) primary key that the updated row had.
// endif::shared[]
// Type: continue
[id="mariadb-delete-events"]
=== _delete_ events
// ifdef::shared[]
The value in a _delete_ change event has the same `schema` portion as _create_ and _update_ events for the same table. The `payload` portion in a _delete_ event for the sample `customers` table looks like this:
[source,json,options="nowrap",subs="+attributes"]
----
{
"schema": { ... },
"payload": {
"before": { // <1>
"id": 1004,
"first_name": "Anne Marie",
"last_name": "Kretchmar",
"email": "annek@noanswer.org"
},
"after": null, // <2>
"source": { // <3>
"version": "{debezium-version}",
"connector": "mariadb",
"name": "mariadb-server-1",
"ts_ms": 1465581902300,
"ts_us": 1465581902300000,
"ts_ns": 1465581902300000000,
"snapshot": false,
"db": "inventory",
"table": "customers",
"server_id": 223344,
"gtid": null,
"file": "mariadb-bin.000003",
"pos": 805,
"row": 0,
"thread": 7,
"query": "DELETE FROM customers WHERE id=1004"
},
"op": "d", // <4>
"ts_ms": 1465581902461, // <5>
"ts_us": 1465581902461842, // <6>
"ts_ns": 1465581902461842579 // <7>
}
}
----
.Descriptions of _delete_ event value fields
[cols="1,2,7",options="header"]
|===
|Item |Field name |Description
|1
|`before`
|Optional field that specifies the state of the row before the event occurred. In a _delete_ event value, the `before` field contains the values that were in the row before it was deleted with the database commit.
|2
|`after`
| Optional field that specifies the state of the row after the event occurred. In a _delete_ event value, the `after` field is `null`, signifying that the row no longer exists.
|3
|`source`
a|Mandatory field that describes the source metadata for the event. In a _delete_ event value, the `source` field structure is the same as for _create_ and _update_ events for the same table. Many `source` field values are also the same. In a _delete_ event value, the `ts_ms` and `pos` field values, as well as other values, might have changed. But the `source` field in a _delete_ event value provides the same metadata:
* {prodname} version
* Connector name
* binlog name where the event was recorded
* binlog position
* Row within the event
* If the event was part of a snapshot
* Name of the database and table that contain the updated row
* ID of the MariaDB thread that created the event (non-snapshot only)
* MariaDB server ID (if available)
* Timestamp for when the change was made in the database
// ifdef::not-shared[]
If the xref:enable-query-log-events[`binlog_annotate_row_events`] MariaDB configuration option is enabled and the connector configuration `include.query` property is enabled, the `source` field also provides the `query` field, which contains the original SQL statement that caused the change event.
// endif::not-shared[]
|4
|`op`
a|Mandatory string that describes the type of operation. The `op` field value is `d`, signifying that this row was deleted.
|5
|`ts_ms`
a|Optional field that displays the time at which the connector processed the event.
The time is based on the system clock in the JVM running the Kafka Connect task. +
+
In the `source` object, `ts_ms` indicates the time that the change was made in the database. By comparing the value for `payload.source.ts_ms` with the value for `payload.ts_ms`, you can determine the lag between the source database update and {prodname}.
|6
|`ts_us`
a|Optional field that displays the time at which the connector processed the event, in microseconds.
The time is based on the system clock in the JVM running the Kafka Connect task.
|7
|`ts_ns`
a|Optional field that displays the time at which the connector processed the event, in nanoseconds.
The time is based on the system clock in the JVM running the Kafka Connect task.
|===
A _delete_ change event record provides a consumer with the information it needs to process the removal of this row. The old values are included because some consumers might require them in order to properly handle the removal.
MariaDB connector events are designed to work with link:{link-kafka-docs}/#compaction[Kafka log compaction]. Log compaction enables removal of some older messages as long as at least the most recent message for every key is kept. This lets Kafka reclaim storage space while ensuring that the topic contains a complete data set and can be used for reloading key-based state.
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=del-events]
// Type: continue
[id="mariadb-tombstone-events"]
=== Tombstone events
// ifdef::shared[]
When a row is deleted, the _delete_ event value still works with log compaction, because Kafka can remove all earlier messages that have that same key. However, for Kafka to remove all messages that have that same key, the message value must be `null`. To make this possible, after {prodname}s MariaDB connector emits a _delete_ event, the connector emits a special tombstone event that has the same key but a `null` value.
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=tombstone-events]
// Type: continue
[id="mariadb-truncate-events"]
=== _truncate_ events
// ifdef::shared[]
A _truncate_ change event signals that a table has been truncated.
The message key is `null` in this case, the message value looks like this:
[source,json,indent=0,subs="+attributes"]
----
{
"schema": { ... },
"payload": {
"source": { // <1>
"version": "{debezium-version}",
"name": "mariadb-server-1",
"connector": "mariadb",
"name": "mariadb-server-1",
"ts_ms": 1465581029100,
"ts_us": 1465581029100000,
"ts_ns": 1465581029100000000,
"snapshot": false,
"db": "inventory",
"table": "customers",
"server_id": 223344,
"gtid": null,
"file": "mariadb-bin.000003",
"pos": 484,
"row": 0,
"thread": 7,
"query": "UPDATE customers SET first_name='Anne Marie' WHERE id=1004"
},
"op": "t", // <2>
"ts_ms": 1465581029523, // <3>
"ts_us": 1465581029523468, // <4>
"ts_ns": 1465581029523468471 // <5>
}
}
----
.Descriptions of _truncate_ event value fields
[cols="1,2,7",options="header"]
|===
|Item |Field name |Description
|1
|`source`
a|Mandatory field that describes the source metadata for the event. In a _truncate_ event value, the `source` field structure is the same as for _create_, _update_, and _delete_ events for the same table, provides this metadata:
* {prodname} version
* Connector type and name
* Binlog name where the event was recorded
* Binlog position
* Row within the event
* If the event was part of a snapshot
* Name of the database and table
* ID of the MariaDB thread that truncated the event (non-snapshot only)
* MariaDB server ID (if available)
* Timestamp for when the change was made in the database
|2
|`op`
a|Mandatory string that describes the type of operation. The `op` field value is `t`, signifying that this table was truncated.
|3
|`ts_ms`
a|Optional field that displays the time at which the connector processed the event.
The time is based on the system clock in the JVM running the Kafka Connect task. +
+
In the `source` object, `ts_ms` indicates the time that the change was made in the database. By comparing the value for `payload.source.ts_ms` with the value for `payload.ts_ms`, you can determine the lag between the source database update and {prodname}.
|4
|`ts_us`
a|Optional field that displays the time at which the connector processed the event, in microseconds. The time is based on the system clock in the JVM running the Kafka Connect task.
|5
|`ts_ns`
a|Optional field that displays the time at which the connector processed the event, in nanoseconds. The time is based on the system clock in the JVM running the Kafka Connect task.
|===
In case a single `TRUNCATE` statement applies to multiple tables,
one _truncate_ change event record for each truncated table will be emitted.
Note that since _truncate_ events represent a change made to an entire table and don't have a message key,
unless you're working with topics with a single partition,
there are no ordering guarantees for the change events pertaining to a table (_create_, _update_, etc.) and _truncate_ events for that table.
For instance a consumer may receive an _update_ event only after a _truncate_ event for that table,
when those events are read from different partitions.
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=tombstone-events]
// Type: reference
// ModuleID: how-debezium-mariadb-connectors-map-data-types
@ -1833,455 +274,48 @@ when those events are read from different partitions.
[[mariadb-data-types]]
== Data type mappings
// ifdef::shared[]
The {prodname} MariaDB connector represents changes to rows with events that are structured like the table in which the row exists. The event contains a field for each column value. The MariaDB data type of that column dictates how {prodname} represents the value in the event.
Columns that store strings are defined in MariaDB with a character set and collation. The MariaDB connector uses the column's character set when reading the binary representation of the column values in the binlog events.
The connector can map MariaDB data types to both _literal_ and _semantic_ types.
* *Literal type*: how the value is represented using Kafka Connect schema types.
* *Semantic type*: how the Kafka Connect schema captures the meaning of the field (schema name).
If the default data type conversions do not meet your needs, you can {link-prefix}:{link-custom-converters}#custom-converters[create a custom converter] for the connector.
ifdef::product[]
Details are in the following sections:
* xref:mariadb-basic-types[]
* xref:mariadb-temporal-types[]
* xref:mariadb-decimal-types[]
* xref:mariadb-boolean-values[]
* xref:mariadb-spatial-types[]
endif::product[]
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=data-type-mappings]
[id="mariadb-basic-types"]
=== Basic types
// ifdef::shared[]
The following table shows how the connector maps basic MariaDB data types.
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=basic-data-types]
.Descriptions of basic type mappings
[cols="25%a,20%a,55%a",options="header",subs="+attributes"]
|===
|MariaDB type |Literal type |Semantic type
|`BOOLEAN, BOOL`
|`BOOLEAN`
a|_n/a_
|`BIT(1)`
|`BOOLEAN`
a|_n/a_
|`BIT(>1)`
|`BYTES`
a|`io.debezium.data.Bits` +
+
The `length` schema parameter contains an integer that represents the number of bits. The `byte[]` contains the bits in _little-endian_ form and is sized to contain the specified number of bits. For example, where `n` is bits: +
`numBytes = n/8 + (n%8== 0 ? 0 : 1)`
|`TINYINT`
|`INT16`
a|_n/a_
|`SMALLINT[(M)]`
|`INT16`
a|_n/a_
|`MEDIUMINT[(M)]`
|`INT32`
a|_n/a_
|`INT, INTEGER[(M)]`
|`INT32`
a|_n/a_
|`BIGINT[(M)]`
|`INT64`
a|_n/a_
|`REAL[(M,D)]`
|`FLOAT32`
a|_n/a_
|`FLOAT[(P)]`
|`FLOAT32` or `FLOAT64`
a|The precision is used only to determine storage size.
A precision `P` from 0 to 23 results in a 4-byte single-precision `FLOAT32` column.
A precision `P` from 24 to 53 results in an 8-byte double-precision `FLOAT64` column.
// ifdef::not-shared[]
|`FLOAT(M,D)`
|`FLOAT64`
a|_n/a_
// endif::not-shared[]
|`DOUBLE[(M,D)]`
|`FLOAT64`
a|_n/a_
|`CHAR(M)]`
|`STRING`
a|_n/a_
|`VARCHAR(M)]`
|`STRING`
a|_n/a_
|`BINARY(M)]`
|`BYTES` or `STRING`
a|_n/a_ +
+
Either the raw bytes (the default), a base64-encoded String, or a base64-url-safe-encoded String, or a hex-encoded String, based on the xref:mariadb-property-binary-handling-mode[`binary.handling.mode`] connector configuration property setting.
|`VARBINARY(M)]`
|`BYTES` or `STRING`
a|_n/a_ +
+
Either the raw bytes (the default), a base64-encoded String, or a base64-url-safe-encoded String, or a hex-encoded String, based on the xref:mariadb-property-binary-handling-mode[`binary.handling.mode`] connector configuration property setting.
|`TINYBLOB`
|`BYTES` or `STRING`
a|_n/a_ +
+
Either the raw bytes (the default), a base64-encoded String, or a base64-url-safe-encoded String, or a hex-encoded String, based on the xref:mariadb-property-binary-handling-mode[`binary.handling.mode`] connector configuration property setting.
|`TINYTEXT`
|`STRING`
a|_n/a_
|`BLOB`
|`BYTES` or `STRING`
a|_n/a_ +
+
Either the raw bytes (the default), a base64-encoded String, or a base64-url-safe-encoded String, or a hex-encoded String, based on the xref:mariadb-property-binary-handling-mode[`binary.handling.mode`] connector configuration property setting. +
+
Only values with a size of up to 2GB are supported. It is recommended to externalize large column values, using the claim check pattern.
|`TEXT`
|`STRING`
a|_n/a_ +
+
Only values with a size of up to 2GB are supported. It is recommended to externalize large column values, using the claim check pattern.
|`MEDIUMBLOB`
|`BYTES` or `STRING`
a|_n/a_ +
+
Either the raw bytes (the default), a base64-encoded String, or a base64-url-safe-encoded String, or a hex-encoded String, based on the xref:mariadb-property-binary-handling-mode[`binary.handling.mode`] connector configuration property setting.
|`MEDIUMTEXT`
|`STRING`
a|_n/a_
|`LONGBLOB`
|`BYTES` or `STRING`
a|_n/a_ +
+
Either the raw bytes (the default), a base64-encoded String, or a base64-url-safe-encoded String, or a hex-encoded String, based on the xref:mariadb-property-binary-handling-mode[`binary.handling.mode`] connector configuration property setting. +
+
Only values with a size of up to 2GB are supported. It is recommended to externalize large column values, using the claim check pattern.
|`LONGTEXT`
|`STRING`
a|_n/a_ +
+
Only values with a size of up to 2GB are supported. It is recommended to externalize large column values, using the claim check pattern.
|`JSON`
|`STRING`
a|`io.debezium.data.Json` +
+
Contains the string representation of a `JSON` document, array, or scalar.
|`ENUM`
|`STRING`
a|`io.debezium.data.Enum` +
+
The `allowed` schema parameter contains the comma-separated list of allowed values.
|`SET`
|`STRING`
a|`io.debezium.data.EnumSet` +
+
The `allowed` schema parameter contains the comma-separated list of allowed values.
|`YEAR[(2\|4)]`
|`INT32`
|`io.debezium.time.Year`
|`TIMESTAMP[(M)]`
|`STRING`
a|`io.debezium.time.ZonedTimestamp` +
+
In link:https://www.iso.org/iso-8601-date-and-time-format.html[ISO 8601] format with microsecond precision. MariaDB allows `M` to be in the range of `0-6`.
|===
// endif::shared[]
[id="mariadb-temporal-types"]
=== Temporal types
// ifdef::shared[]
Excluding the `TIMESTAMP` data type, MariaDB temporal types depend on the value of the `time.precision.mode` connector configuration property. For `TIMESTAMP` columns whose default value is specified as `CURRENT_TIMESTAMP` or `NOW`, the value `1970-01-01 00:00:00` is used as the default value in the Kafka Connect schema.
MariaDB allows zero-values for `DATE`, `DATETIME`, and `TIMESTAMP` columns because zero-values are sometimes preferred over null values. The MariaDB connector represents zero-values as null values when the column definition allows null values, or as the epoch day when the column does not allow null values.
.Temporal values without time zones
The `DATETIME` type represents a local date and time such as "2018-01-13 09:48:27". As you can see, there is no time zone information. Such columns are converted into epoch milliseconds or microseconds based on the columns precision by using UTC. The `TIMESTAMP` type represents a timestamp without time zone information. It is converted by MariaDB from the server (or sessions) current time zone into UTC when writing and from UTC into the server (or session's) current time zone when reading back the value. For example:
* `DATETIME` with a value of `2018-06-20 06:37:03` becomes `1529476623000`.
* `TIMESTAMP` with a value of `2018-06-20 06:37:03` becomes `2018-06-20T13:37:03Z`.
Such columns are converted into an equivalent `io.debezium.time.ZonedTimestamp` in UTC based on the server (or sessions) current time zone.
The time zone will be queried from the server by default.
// ifdef::not-shared[]
If this fails, it must be specified explicitly by the database `timezone` MariaDB configuration option.
For example, if the databases time zone (either globally or configured for the connector by means of the `timezone` option) is "America/Los_Angeles", the TIMESTAMP value "2018-06-20 06:37:03" is represented by a `ZonedTimestamp` with the value "2018-06-20T13:37:03Z".
// endif::not-shared[]
The time zone of the JVM running Kafka Connect and Debezium does not affect these conversions.
More details about properties related to temporal values are in the documentation for xref:mariadb-connector-properties[MariaDB connector configuration properties].
time.precision.mode=adaptive_time_microseconds(default)::
The MariaDB connector determines the literal type and semantic type based on the column's data type definition so that events represent exactly the values in the database. All time fields are in microseconds. Only positive `TIME` field values in the range of `00:00:00.000000` to `23:59:59.999999` can be captured correctly.
+
.Mappings when `time.precision.mode=adaptive_time_microseconds`
[cols="25%a,20%a,55%a",options="header",subs="+attributes"]
|===
|MariaDB type |Literal type |Semantic type
|`DATE`
|`INT32`
a|`io.debezium.time.Date` +
Represents the number of days since the epoch.
|`TIME[(M)]`
|`INT64`
a|`io.debezium.time.MicroTime` +
Represents the time value in microseconds and does not include time zone information. MariaDB allows `M` to be in the range of `0-6`.
|`DATETIME, DATETIME(0), DATETIME(1), DATETIME(2), DATETIME(3)`
|`INT64`
a|`io.debezium.time.Timestamp` +
Represents the number of milliseconds past the epoch and does not include time zone information.
|`DATETIME(4), DATETIME(5), DATETIME(6)`
|`INT64`
a|`io.debezium.time.MicroTimestamp` +
Represents the number of microseconds past the epoch and does not include time zone information.
|===
time.precision.mode=connect::
The MariaDB connector uses defined Kafka Connect logical types. This approach is less precise than the default approach and the events could be less precise if the database column has a _fractional second precision_ value of greater than `3`. Values in only the range of `00:00:00.000` to `23:59:59.999` can be handled. Set `time.precision.mode=connect` only if you can ensure that the `TIME` values in your tables never exceed the supported ranges. The `connect` setting is expected to be removed in a future version of {prodname}.
+
.Mappings when `time.precision.mode=connect`
[cols="25%a,20%a,55%a",options="header",subs="+attributes"]
|===
|MariaDB type |Literal type |Semantic type
|`DATE`
|`INT32`
a|`org.apache.kafka.connect.data.Date` +
Represents the number of days since the epoch.
|`TIME[(M)]`
|`INT64`
a|`org.apache.kafka.connect.data.Time` +
Represents the time value in microseconds since midnight and does not include time zone information.
|`DATETIME[(M)]`
|`INT64`
a|`org.apache.kafka.connect.data.Timestamp` +
Represents the number of milliseconds since the epoch, and does not include time zone information.
|===
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=temporal-data-types]
[id="mariadb-decimal-types"]
=== Decimal types
// ifdef::shared[]
{prodname} connectors handle decimals according to the setting of the xref:mariadb-property-decimal-handling-mode[`decimal.handling.mode`] connector configuration property.
decimal.handling.mode=precise::
+
.Mappings when `decimal.handling.mode=precise`
[cols="30%a,15%a,55%a",options="header",subs="+attributes"]
|===
|MariaDB type |Literal type |Semantic type
|`NUMERIC[(M[,D])]`
|`BYTES`
a|`org.apache.kafka.connect.data.Decimal` +
The `scale` schema parameter contains an integer that represents how many digits the decimal point shifted.
|`DECIMAL[(M[,D])]`
|`BYTES`
a|`org.apache.kafka.connect.data.Decimal` +
The `scale` schema parameter contains an integer that represents how many digits the decimal point shifted.
|===
decimal.handling.mode=double::
+
.Mappings when `decimal.handling.mode=double`
[cols="30%a,30%a,40%a",options="header",subs="+attributes"]
|===
|MariaDB type |Literal type |Semantic type
|`NUMERIC[(M[,D])]`
|`FLOAT64`
a|_n/a_
|`DECIMAL[(M[,D])]`
|`FLOAT64`
a|_n/a_
|===
decimal.handling.mode=string::
+
.Mappings when `decimal.handling.mode=string`
[cols="30%a,30%a,40%a",options="header",subs="+attributes"]
|===
|MariaDB type |Literal type |Semantic type
|`NUMERIC[(M[,D])]`
|`STRING`
a|_n/a_
|`DECIMAL[(M[,D])]`
|`STRING`
a|_n/a_
|===
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=decimal-data-types]
[id="mariadb-boolean-values"]
=== Boolean values
// ifdef::shared[]
MariaDB handles the `BOOLEAN` value internally in a specific way.
The `BOOLEAN` column is internally mapped to the `TINYINT(1)` data type.
When the table is created during streaming then it uses proper `BOOLEAN` mapping as {prodname} receives the original DDL.
During snapshots, {prodname} executes `SHOW CREATE TABLE` to obtain table definitions that return `TINYINT(1)` for both `BOOLEAN` and `TINYINT(1)` columns. {prodname} then has no way to obtain the original type mapping and so maps to `TINYINT(1)`.
To enable you to convert source columns to Boolean data types, {prodname} provides a `TinyIntOneToBooleanConverter` {link-prefix}:{link-custom-converters}#custom-converters[custom converter] that you can use in one of the following ways:
* Map all `TINYINT(1)` or `TINYINT(1) UNSIGNED` columns to `BOOLEAN` types.
* Enumerate a subset of columns by using a comma-separated list of regular expressions. +
To use this type of conversion, you must set the xref:mariadb-property-converters[`converters`] configuration property with the `selector` parameter, as shown in the following example:
+
[source]
----
converters=boolean
boolean.type=io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter
boolean.selector=db1.table1.*, db1.table2.column1
----
* NOTE: In some cases, the database may not show the length of `tinyint unsigned` when the snapshot executes `SHOW CREATE TABLE`, which means this converter doesn't work. The new option `length.checker` can solve this issue, the default value is `true`. Disable the `length.checker` and specify the columns that need to be converted to `selected` property instead of converting all columns based on type, as shown in the following example:
+
[source]
----
converters=boolean
boolean.type=io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter
boolean.length.checker=false
boolean.selector=db1.table1.*, db1.table2.column1
----
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=boolean-values]
[id="mariadb-spatial-types"]
=== Spatial types
// ifdef::shared[]
Currently, the {prodname} MariaDB connector supports the following spatial data types.
.Description of spatial type mappings
[cols="35%a,15%a,50%a",options="header",subs="+attributes"]
|===
|MariaDB type |Literal type |Semantic type
|`GEOMETRY, +
LINESTRING, +
POLYGON, +
MULTIPOINT, +
MULTILINESTRING, +
MULTIPOLYGON, +
GEOMETRYCOLLECTION`
|`STRUCT`
a|`io.debezium.data.geometry.Geometry` +
Contains a structure with two fields:
* `srid (INT32`: spatial reference system ID that defines the type of geometry object stored in the structure
* `wkb (BYTES)`: binary representation of the geometry object encoded in the Well-Known-Binary (wkb) format. See the link:https://www.opengeospatial.org/standards/sfa[Open Geospatial Consortium] for more details.
|===
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=spatial-data-types]
[[debezium-mariadb-connector-converters]]
== Custom converters
// ifdef::shared[]
By default, the {prodname} MariaDB connector provides several `CustomConverter` implementations for MariaDB data types.
These custom converters provide alternative mappings for specific data types based on the connector configuration.
To add a `CustomConverter` to the connector, follow the instructions in the link:../development/converters.adoc[Custom Converters documentation].
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=custom-converters]
=== `TINYINT(1)` to Boolean
By default, during a connector snapshot, the {prodname} MariaDB connector obtains column types from the JDBC driver, which assigns the `TINYINT(1)` type to `BOOLEAN` columns.
{prodname} then uses these JDBC column types to define the schema for the snapshot events.
After the connector transitions from the snapshot to the streaming phase, the change event schema that results from the default mapping can lead to inconsistent mappings for `BOOLEAN` columns.
To help ensure that MariaDB emits `BOOLEAN` columns uniformly, you can apply the custom `TinyIntOneToBooleanConverter`, as shown in the following configuration example.
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=tinyint-boolean-conv]
.Example: `TinyIntOneToBooleanConverter` configuration
[source]
----
converters=tinyint-one-to-boolean
converters.tinyint-one-to-boolean.type=io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter
converters.tinyint-one-to-boolean.selector=.*.MY_TABLE.DATA
converters.tinyint-one-to-boolean.length.checker=false
----
In the preceding example, the `selector` and `length.checker` properties are optional.
By default, the converter checks that `TINYINT` data types conform to a length of `1`.
If `length.checker` to `false`, the converter does not explicitly confirm that the `TINYINT` data type conforms to a length of `1`.
The `selector` designates the tables or columns to convert, based on the supplied regular expression.
If you omit the `selector` property, the converter maps all `TINYINT` columns to logical `BOOL` field types.
If you do not configure a `selector` option, and you want to map `TINYINT` columns to `TINYINT(1)`, omit the `length.checker` property, or set its value to `true`.
=== JDBC sink data types
If you integrate the {prodname} JDBC sink connector with a {prodname} MariaDB source connector, the MariaDB connector emits some column attributes differently during the snapshot and streaming phases.
For the JDBC sink connector to consistently consume changes from both the snapshot and streaming phase, you must include the `JdbcSinkDataTypesConverter` converter as part of the MariaDB source connector configuration, as shown in the following example:
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=jdbc-sink-data-types]
.Example: `JdbcSinkDataTypesConverter` configuration
[source]
----
converters=jdbc-sink
converters.jdbc-sink.type=io.debezium.connector.binlog.converters.JdbcSinkDataTypesConverter
converters.jdbc-sink.selector.boolean=.*.MY_TABLE.BOOL_COL
converters.jdbc-sink.selector.real=.*.MY_TABLE.REAL_COL
converters.jdbc-sink.selector.string=.*.MY_TABLE.STRING_COL
converters.jdbc-sink.treat.real.as.double=true
----
In the preceding example, the `selector.*` and `treat.real.as.double` configuration properties are optional.
The `selector.*` properties specify comma-separated lists of regular expressions that specify which tables and columns that the converter applies to.
By default, the converter applies the following rules apply to all Boolean, real, and string-based column data types, across all tables:
* `BOOLEAN` data types are always emitted as `INT16` logical types, with `1` representing `true` and `0` representing `false`
* `REAL` data types are always emitted as `FLOAT64` logical types.
* String-based columns always include the `__debezium.source.column.character_set` schema parameter that contains the column's character set.
For each data type, you can configure a selector rule to override the default scope and apply the selector to specific tables and columns only.
For example, to set the scope of the Boolean converter, add the following rule to the connector configuration, as in the preceding example: `converters.jdbc-sink.selector.boolean=.*.MY_TABLE.BOOL_COL`
// endif::shared[]
// Type: assembly
// ModuleID: setting-up-mariadb-to-run-a-debezium-connector
@ -2289,20 +323,7 @@ For example, to set the scope of the Boolean converter, add the following rule t
[[setting-up-mariadb]]
== Setting up MariaDB
// ifdef::shared[]
Some MariaDB setup tasks are required before you can install and run a {prodname} connector.
ifdef::product[]
Details are in the following sections:
* xref:creating-a-mariadb-user-for-a-debezium-connector[]
* xref:enabling-the-mariadb-binlog-for-debezium[]
* xref:enabling-mariadb-gtids-for-debezium[]
* xref:configuring-mariadb-session-timeouts-for-debezium[]
* xref:enabling-query-log-events-for-debezium-mariadb-connectors[]
endif::product[]
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=setting-up-db]
// Type: procedure
// ModuleID: creating-a-mariadb-user-for-a-debezium-connector
@ -2310,80 +331,7 @@ endif::product[]
[[mariadb-creating-user]]
=== Creating a user
// ifdef::shared[]
A {prodname} MariaDB connector requires a MariaDB user account. This MariaDB user must have appropriate permissions on all databases for which the {prodname} MariaDB connector captures changes.
.Prerequisites
* A MariaDB server.
* Basic knowledge of SQL commands.
.Procedure
. Create the MariaDB user:
+
[source,SQL]
----
mariadb> CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
----
. Grant the required permissions to the user:
+
[source,SQL]
----
mariadb> GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'user' IDENTIFIED BY 'password';
----
+
The table below describes the permissions.
+
IMPORTANT: If using a hosted option such as Amazon RDS or Amazon Aurora that does not allow a global read lock, table-level locks are used to create the _consistent snapshot_. In this case, you need to also grant `LOCK TABLES` permissions to the user that you create. See xref:mariadb-snapshots[snapshots] for more details.
. Finalize the user's permissions:
+
[source,SQL]
----
mariadb> FLUSH PRIVILEGES;
----
// endif::shared[]
[[permissions-explained-mariadb-connector]]
.Descriptions of user permissions
[cols="3,7",options="header",subs="+attributes"]
|===
|Keyword |Description
|`SELECT`
|Enables the connector to select rows from tables in databases. This is used only when performing a snapshot.
|`RELOAD`
|Enables the connector the use of the `FLUSH` statement to clear or reload internal caches, flush tables, or acquire locks. This is used only when performing a snapshot.
|`SHOW DATABASES`
|Enables the connector to see database names by issuing the `SHOW DATABASE` statement. This is used only when performing a snapshot.
|`REPLICATION SLAVE`
|Enables the connector to connect to and read the MariaDB server binlog.
|`REPLICATION CLIENT`
a|Enables the connector the use of the following statements:
* `SHOW MASTER STATUS`
* `SHOW SLAVE STATUS`
* `SHOW BINARY LOGS`
The connector always requires this.
|`ON`
|Identifies the database to which the permissions apply.
|`TO 'user'`
|Specifies the user to grant the permissions to.
|`IDENTIFIED BY 'password'`
|Specifies the user's MariaDB password.
|===
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=creating-a-db-user]
// Type: procedure
// ModuleID: enabling-the-mariadb-binlog-for-debezium
@ -2391,71 +339,8 @@ The connector always requires this.
[[enable-mariadb-binlog]]
=== Enabling the binlog
You must enable binary logging for MariaDB replication. The binary logs record transaction updates for replication tools to propagate changes.
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=enabling-binlog]
.Prerequisites
* A MariaDB server.
* Appropriate MariaDB user privileges.
.Procedure
// ifdef::not-shared[]
. Check whether the `log-bin` option is already on:
+
[source,SQL]
----
mariadb> SHOW VARIABLES LIKE '%log_bin%';
----
// endif::not-shared[]
. If it is `OFF`, configure your MariaDB server configuration file with the following properties, which are described in the table below:
+
[source,properties]
----
server-id = 223344 # Querying variable is called server_id, e.g. SELECT variable_value FROM information_schema.global_variables WHERE variable_name='server_id';
log_bin = mariadb-bin
binlog_format = ROW
binlog_row_image = FULL
binlog_expire_logs_seconds = 864000
----
// ifdef::not-shared[]
. Confirm your changes by checking the binlog status once more:
+
[source,SQL]
----
mariadb> SHOW VARIABLES LIKE '%log_bin%';
----
// endif::not-shared[]
. If you run MariaDB on Amazon RDS, you must enable automated backups for your database instance for binary logging to occur.
If the database instance is not configured to perform automated backups, the binlog is disabled, even if you apply the settings described in the previous steps.
[[binlog-configuration-properties-mariadb-connector]]
.Descriptions of MariaDB binlog configuration properties
[cols="1,4",options="header",subs="+attributes"]
|===
|Property |Description
|`server-id`
|The value for the `server-id` must be unique for each server and replication client in the MariaDB cluster.
|`log_bin`
|The value of `log_bin` is the base name of the sequence of binlog files.
|`binlog_format`
|The `binlog-format` must be set to `ROW` or `row`.
|`binlog_row_image`
|The `binlog_row_image` must be set to `FULL` or `full`.
|`binlog_expire_logs_seconds`
|The `binlog_expire_logs_seconds` corresponds to deprecated system variable `expire_logs_days`. This is the number of seconds for automatic binlog file removal. The default is `2592000`, which equals 30 days. Set the value to match the needs of your environment. See xref:mariadb-purges-binlog-files-used-by-debezium[MariaDB purges binlog files].
|===
// endif::shared[]
// Type: procedure
// ModuleID: enabling-mariadb-gtids-for-debezium
@ -2463,7 +348,8 @@ If the database instance is not configured to perform automated backups, the bin
[[enable-mariadb-gtids]]
=== Enabling GTIDs
Global transaction identifiers (GTIDs) uniquely identify transactions that occur on a server within a cluster. Though not required for a {prodname} MariaDB connector, using GTIDs simplifies replication and enables you to more easily confirm if primary and replica servers are consistent.
Global transaction identifiers (GTIDs) uniquely identify transactions that occur on a server within a cluster.
Although not required for a {prodname} MariaDB connector, using GTIDs simplifies replication and enables you to more easily confirm if primary and replica servers are consistent.
For MariaDB, GTIDs are enabled by default and no additional configuration is necessary.
@ -2473,44 +359,7 @@ For MariaDB, GTIDs are enabled by default and no additional configuration is nec
[[mariadb-session-timeouts]]
=== Configuring session timeouts
// ifdef::shared[]
When an initial consistent snapshot is made for large databases, your established connection could timeout while the tables are being read. You can prevent this behavior by configuring `interactive_timeout` and `wait_timeout` in your MariaDB configuration file.
.Prerequisites
* A MariaDB server.
* Basic knowledge of SQL commands.
* Access to the MariaDB configuration file.
.Procedure
. Configure `interactive_timeout`:
+
[source,SQL]
----
mariadb> interactive_timeout=<duration-in-seconds>
----
. Configure `wait_timeout`:
+
[source,SQL]
----
mariadb> wait_timeout=<duration-in-seconds>
----
.Descriptions of MariaDB session timeout options
[cols="3,7",options="header",subs="+attributes"]
|===
|Option |Description
|`interactive_timeout`
a|The number of seconds the server waits for activity on an interactive connection before closing it. See link:https://mariadb.com/kb/en/server-system-variables/#interactive_timeout[MariaDB's documentation] for more details.
|`wait_timeout`
a|The number of seconds the server waits for activity on a non-interactive connection before closing it. See link:https://mariadb.com/kb/en/server-system-variables/#wait_timeout[MariaDB's documentation] for more details.
|===
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=enabling-binlog]
// Type: procedure
// ModuleID: enabling-query-log-events-for-debezium-mariadb-connectors
@ -2547,42 +396,8 @@ mariadb> binlog_annotate_row_events=ON
[[validate-binlog-row-value-options]]
=== Validating binlog row value options
// ifdef::shared[]
Check `binlog_row_value_options` variable, and make sure that value is **not** set to `PARTIAL_JSON`, since in such case connector might fail to consume *UPDATE* events.
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=validate=binlog-row-options]
.Prerequisites
* A MariaDB server.
* Basic knowledge of SQL commands.
* Access to the MariaDB configuration file.
.Procedure
. Check current variable value
+
[source,SQL]
----
mariadb> show global variables where variable_name = 'binlog_row_value_options';
----
. Result
+
[source,SQL]
----
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| binlog_row_value_options | |
+--------------------------+-------+
----
. In case value is `PARTIAL_JSON`, unset this variable by:
+
[source,SQL]
----
mariadb> set @@global.binlog_row_value_options="" ;
----
// endif::shared[]
// Type: assembly
// ModuleID: deployment-of-debezium-mariadb-connectors
@ -2590,44 +405,7 @@ mariadb> set @@global.binlog_row_value_options="" ;
[[mariadb-deploying-a-connector]]
== Deployment
// ifdef::shared[]
ifdef::community[]
To deploy a {prodname} MariaDB connector, you install the {prodname} MariaDB connector archive, configure the connector, and start the connector by adding its configuration to Kafka Connect.
.Prerequisites
* link:https://zookeeper.apache.org/[Apache Zookeeper], link:http://kafka.apache.org/[Apache Kafka], and link:{link-kafka-docs}.html#connect[Kafka Connect] are installed.
* MariaDB Server is installed and is xref:setting-up-mariadb[set up to work with the {prodname} connector].
.Procedure
ifeval::['{page-version}' == 'master']
. Download the {prodname} link:{link-mariadb-plugin-snapshot}[MariaDB connector plug-in].
endif::[]
ifeval::['{page-version}' != 'master']
. Download the {prodname} link:https://repo1.maven.org/maven2/io/debezium/debezium-connector-mariadb/{debezium-version}/debezium-connector-mariadb-{debezium-version}-plugin.tar.gz[MariaDB connector plug-in].
endif::[]
. Extract the files into your Kafka Connect environment.
. Add the directory with the JAR files to {link-kafka-docs}/#connectconfigs[Kafka Connect's `plugin.path`].
. xref:mariadb-example-configuration[Configure the connector] and xref:mariadb-adding-configuration[add the configuration to your Kafka Connect cluster.]
. Restart your Kafka Connect process to pick up the new JAR files.
If you are working with immutable containers, see link:https://quay.io/organization/debezium[{prodname}'s Container images] for Apache Zookeeper, Apache Kafka, MariaDB, and Kafka Connect with the MariaDB connector already installed and ready to run.
You can also xref:operations/openshift.adoc[run {prodname} on Kubernetes and OpenShift].
endif::community[]
ifdef::product[]
You can use either of the following methods to deploy a {prodname} MariaDB connector:
* xref:openshift-streams-mariadb-connector-deployment[Use {StreamsName} to automatically create an image that includes the connector plug-in].
+
This is the preferred method.
* xref:deploying-debezium-mariadb-connectors[Build a custom Kafka Connect container image from a Dockerfile].
.Additional resources
* xref:descriptions-of-debezium-mariadb-connector-configuration-properties[]
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=deployment]
// Type: concept
[id="openshift-streams-mariadb-connector-deployment"]
@ -2643,306 +421,19 @@ include::{partialsdir}/modules/all-connectors/proc-using-streams-to-deploy-a-deb
// ModuleID: deploying-debezium-mariadb-connectors
=== Deploying {prodname} MariaDB connectors by building a custom Kafka Connect container image from a Dockerfile
// ifdef::shared[]
To deploy a {prodname} MariaDB connector, you must build a custom Kafka Connect container image that contains the {prodname} connector archive, and then push this container image to a container registry.
You then need to create the following custom resources (CRs):
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=deploy-via-dockerfile]
* A `KafkaConnect` CR that defines your Kafka Connect instance.
The `image` property in the CR specifies the name of the container image that you create to run your {prodname} connector.
You apply this CR to the OpenShift instance where link:https://access.redhat.com/products/red-hat-amq#streams[Red Hat {StreamsName}] is deployed.
{StreamsName} offers operators and images that bring Apache Kafka to OpenShift.
* A `KafkaConnector` CR that defines your {prodname} MariaDB connector.
Apply this CR to the same OpenShift instance where you apply the `KafkaConnect` CR.
.Prerequisites
* MariaDB is running and you completed the steps to xref:setting-up-mariadb-to-run-a-debezium-connector[set up MariaDB to work with a {prodname} connector].
* {StreamsName} is deployed on OpenShift and is running Apache Kafka and Kafka Connect.
For more information, see link:{LinkDeployManageStreamsOpenShift}[{NameDeployManageStreamsOpenShift}].
* Podman or Docker is installed.
* You have an account and permissions to create and manage containers in the container registry (such as `quay.io` or `docker.io`) to which you plan to add the container that will run your Debezium connector.
.Procedure
. Create the {prodname} MariaDB container for Kafka Connect:
.. Create a Dockerfile that uses `{DockerKafkaConnect}` as the base image.
For example, from a terminal window, enter the following command:
+
=====================================================================
[source,shell,subs="+attributes,+quotes"]
----
cat <<EOF >debezium-container-for-{context}.yaml // <1>
FROM {DockerKafkaConnect}
USER root:root
RUN mkdir -p /opt/kafka/plugins/debezium // <2>
RUN cd /opt/kafka/plugins/debezium/ \
&& curl -O {red-hat-maven-repository}debezium/debezium-connector-{connector-file}/{debezium-version}-redhat-{debezium-build-number}/debezium-connector-{connector-file}-{debezium-version}-redhat-{debezium-build-number}-plugin.zip \
&& unzip debezium-connector-{connector-file}-{debezium-version}-redhat-{debezium-build-number}-plugin.zip \
&& rm debezium-connector-{connector-file}-{debezium-version}-redhat-{debezium-build-number}-plugin.zip
RUN cd /opt/kafka/plugins/debezium/
USER 1001
EOF
----
=====================================================================
+
[cols="1,7",options="header"]
|===
|Item |Description
|1
|You can specify any file name that you want.
|2
|Specifies the path to your Kafka Connect plug-ins directory.
If your Kafka Connect plug-ins directory is in a different location, replace this path with the actual path of your directory.
|===
+
The command creates a Dockerfile with the name `debezium-container-for-mariadb.yaml` in the current directory.
.. Build the container image from the `debezium-container-for-mariadb.yaml` Docker file that you created in the previous step.
From the directory that contains the file, open a terminal window and enter one of the following commands:
+
[source,shell,options="nowrap"]
----
podman build -t debezium-container-for-mariadb:latest .
----
+
[source,shell,options="nowrap"]
----
docker build -t debezium-container-for-mariadb:latest .
----
The preceding commands build a container image with the name `debezium-container-for-mariadb`.
.. Push your custom image to a container registry, such as `quay.io` or an internal container registry.
The container registry must be available to the OpenShift instance where you want to deploy the image.
Enter one of the following commands:
+
[source,shell,subs="+quotes"]
----
podman push _<myregistry.io>_/debezium-container-for-mariadb:latest
----
+
[source,shell,subs="+quotes"]
----
docker push _<myregistry.io>_/debezium-container-for-mariadb:latest
----
.. Create a new {prodname} MariaDB `KafkaConnect` custom resource (CR).
For example, create a `KafkaConnect` CR with the name `dbz-connect.yaml` that specifies `annotations` and `image` properties.
The following example shows an excerpt from a `dbz-connect.yaml` file that describes a `KafkaConnect` custom resource. +
+
=====================================================================
[source,yaml,subs="+attributes"]
----
apiVersion: {KafkaConnectApiVersion}
kind: KafkaConnect
metadata:
name: my-connect-cluster
annotations:
strimzi.io/use-connector-resources: "true" // <1>
spec:
#...
image: debezium-container-for-mariadb // <2>
...
----
=====================================================================
+
[cols="1,7",options="header"]
|===
|Item |Description
|1
|`metadata.annotations` indicates to the Cluster Operator that `KafkaConnector` resources are used to configure connectors in this Kafka Connect cluster.
|2
|`spec.image` specifies the name of the image that you created to run your Debezium connector.
This property overrides the `STRIMZI_DEFAULT_KAFKA_CONNECT_IMAGE` variable in the Cluster Operator.
|===
.. Apply the `KafkaConnect` CR to the OpenShift Kafka Connect environment by entering the following command:
+
[source,shell,options="nowrap"]
----
oc create -f dbz-connect.yaml
----
+
The command adds a Kafka Connect instance that specifies the name of the image that you created to run your {prodname} connector.
. Create a `KafkaConnector` custom resource that configures your {prodname} MariaDB connector instance.
+
You configure a {prodname} MariaDB connector in a `.yaml` file that specifies the configuration properties for the connector.
The connector configuration might instruct {prodname} to produce events for a subset of the schemas and tables, or it might set properties so that {prodname} ignores, masks, or truncates values in specified columns that are sensitive, too large, or not needed.
+
The following example configures a {prodname} connector that connects to a MariaDB host, `192.168.99.100`, on port `3306`,
and captures changes to the `inventory` database.
`dbserver1` is the server's logical name.
+
.MariaDB `inventory-connector.yaml`
[source,yaml,options="nowrap",subs="+attributes"]
----
apiVersion: {KafkaConnectApiVersion}
kind: KafkaConnector
metadata:
name: inventory-connector-{context} // <1>
labels:
strimzi.io/cluster: my-connect-cluster
spec:
class: io.debezium.connector.mariadb.MariaDbConnector
tasksMax: 1 // <2>
config: // <3>
database.hostname: mariadb // <4>
database.port: 3306
database.user: debezium
database.password: dbz
database.server.id: 184054 // <5>
topic.prefix: inventory-connector-{context} // <6>
table.include.list: inventory // <7>
schema.history.internal.kafka.bootstrap.servers: my-cluster-kafka-bootstrap:9092 // <8>
schema.history.internal.kafka.topic: schema-changes.inventory // <9>
----
+
.Descriptions of connector configuration settings
[cols="1,7",options="header",subs="+attributes"]
|===
|Item |Description
|1
|The name of the connector.
|2
|Only one task should operate at any one time.
Because the MariaDB connector reads the MariaDB servers `binlog`,
using a single connector task ensures proper order and event handling.
The Kafka Connect service uses connectors to start one or more tasks that do the work,
and it automatically distributes the running tasks across the cluster of Kafka Connect services.
If any of the services stop or crash,
those tasks will be redistributed to running services.
|3
|The connectors configuration.
|4
|The database host, which is the name of the container running the MariaDB server (`mariadb`).
|5
|Unique ID of the connector.
|6
|Topic prefix for the MariaDB server or cluster.
This name is used as the prefix for all Kafka topics that receive change event records.
|7
|The connector captures changes from the `inventory` table only.
|8
|The list of Kafka brokers that this connector will use to write and recover DDL statements to the database schema history topic.
Upon restart, the connector recovers the schemas of the database that existed at the point in time in the binlog when the connector should begin reading.
|9
|The name of the database schema history topic. This topic is for internal use only and should not be used by consumers.
|===
. Create your connector instance with Kafka Connect.
For example, if you saved your `KafkaConnector` resource in the `inventory-connector.yaml` file, you would run the following command:
+
[source,shell,options="nowrap"]
----
oc apply -f inventory-connector.yaml
----
+
The preceding command registers `inventory-connector` and the connector starts to run against the `inventory` database as defined in the `KafkaConnector` CR.
endif::product[]
// endif::shared[]
ifdef::community[]
[[mariadb-example-configuration]]
=== MariaDB connector configuration example
// ifdef::shared[]
Following is an example of the configuration for a connector instance that captures data from a MariaDB server on port 3306 at 192.168.99.100, which we logically name `fullfillment`.
Typically, you configure the {prodname} MariaDB connector in a JSON file by setting the configuration properties that are available for the connector.
You can choose to produce events for a subset of the schemas and tables in a database.
Optionally, you can ignore, mask, or truncate columns that contain sensitive data, that are larger than a specified size, or that you do not need.
[source,json]
----
{
"name": "inventory-connector", // <1>
"config": {
"connector.class": "io.debezium.connector.mariadb.MariaDbConnector", // <2>
"database.hostname": "192.168.99.100", // <3>
"database.port": "3306", // <4>
"database.user": "debezium-user", // <5>
"database.password": "debezium-user-pw", // <6>
"database.server.id": "184054", <7>
"topic.prefix": "fullfillment", // <8>
"database.include.list": "inventory", // <9>
"schema.history.internal.kafka.bootstrap.servers": "kafka:9092", // <10>
"schema.history.internal.kafka.topic": "schemahistory.fullfillment", // <11>
"include.schema.changes": "true" // <12>
}
}
----
<1> Connector's name when registered with the Kafka Connect service.
<2> Connector's class name.
<3> MariaDB server address.
<4> MariaDB server port number.
<5> MariaDB user with the appropriate privileges.
<6> MariaDB user's password.
<7> Unique ID of the connector.
<8> Topic prefix for the MariaDB server or cluster.
<9> List of databases hosted by the specified server.
<10> List of Kafka brokers that the connector uses to write and recover DDL statements to the database schema history topic.
<11> Name of the database schema history topic. This topic is for internal use only and should not be used by consumers.
<12> Flag that specifies if the connector should generate events for DDL changes and emit them to the `fulfillment` schema change topic for use by consumers.
endif::community[]
For the complete list of the configuration properties that you can set for the {prodname} MariaDB connector,
see xref:mariadb-connector-properties[MariaDB connector configuration properties].
ifdef::community[]
You can send this configuration with a `POST` command to a running Kafka Connect service.
The service records the configuration and starts one connector task that performs the following actions:
* Connects to the MariaDB database.
* Reads change-data tables for tables in capture mode.
* Streams change event records to Kafka topics.
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=connector-config-example]
[[mariadb-adding-configuration]]
=== Adding connector configuration
// ifdef::shared[]
To start running a MariaDB connector, configure a connector configuration, and add the configuration to your Kafka Connect cluster.
.Prerequisites
* xref:setting-up-mariadb[MariaDB is set up to work with a {prodname} connector].
* The {prodname} MariaDB connector is installed.
.Procedure
. Create a configuration for the MariaDB connector.
. Use the link:{link-kafka-docs}/#connect_rest[Kafka Connect REST API] to add that connector configuration to your Kafka Connect cluster.
endif::community[]
.Results
After the connector starts, it xref:mariadb-snapshots[performs a consistent snapshot] of the MariaDB databases that the connector is configured for.
The connector then starts generating data change events for row-level operations and streaming change event records to Kafka topics.
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=add-connector-cfg]
ifdef::product[]
// Type: procedure
@ -2958,901 +449,18 @@ endif::product[]
[[mariadb-connector-properties]]
=== Connector properties
The {prodname} MariaDB connector has numerous configuration properties that you can use to achieve the right connector behavior for your application.
Many properties have default values.
Information about the properties is organized as follows:
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=connector-props-intro]
* xref:mariadb-required-connector-configuration-properties[Required connector configuration properties]
* xref:mariadb-advanced-connector-configuration-properties[Advanced connector configuration properties]
* xref:debezium-{context}-connector-database-history-configuration-properties[Database schema history connector configuration properties] that control how {prodname} processes events that it reads from the database schema history topic.
** xref:{context}-pass-through-database-history-properties-for-configuring-producer-and-consumer-clients[Pass-through database schema history properties]
* xref:debezium-{context}-connector-pass-through-database-driver-configuration-properties[Pass-through database driver properties] that control the behavior of the database driver.
[id="mariadb-required-connector-configuration-properties"]
The following configuration properties are _required_ unless a default value is available.
==== Required {prodname} MariaDB connector configuration properties
[cols="33%a,17%a,50%a",options="header",subs="+attributes"]
|===
|Property |Default |Description
|[[mariadb-property-name]]<<mariadb-property-name, `+name+`>>
|No default
|Unique name for the connector. Attempting to register again with the same name fails. This property is required by all Kafka Connect connectors.
include::{partialsdir}/modules/all-connectors/ref-mariadb-mysql-rqd-connector-cfg-props.adoc[leveloffset=+1,]
|[[mariadb-property-connector-class]]<<mariadb-property-connector-class, `+connector.class+`>>
|No default
|The name of the Java class for the connector. Always specify `io.debezium.connector.mariadb.MariaDbConnector` for the MariaDB connector.
|[[mariadb-property-tasks-max]]<<mariadb-property-tasks-max, `+tasks.max+`>>
|`1`
|The maximum number of tasks that should be created for this connector. The MariaDB connector always uses a single task and therefore does not use this value, so the default is always acceptable.
|[[mariadb-property-database-hostname]]<<mariadb-property-database-hostname, `+database.hostname+`>>
|No default
|IP address or host name of the MariaDB database server.
|[[mariadb-property-database-port]]<<mariadb-property-database-port, `+database.port+`>>
|`3306`
|Integer port number of the MariaDB database server.
|[[mariadb-property-database-user]]<<mariadb-property-database-user, `+database.user+`>>
|No default
|Name of the MariaDB user to use when connecting to the MariaDB database server.
|[[mariadb-property-database-password]]<<mariadb-property-database-password, `+database.password+`>>
|No default
|Password to use when connecting to the MariaDB database server.
|[[mariadb-property-topic-prefix]]<<mariadb-property-topic-prefix, `+topic.prefix+`>>
|No default
|Topic prefix that provides a namespace for the particular MariaDB database server/cluster in which {prodname} is capturing changes. The topic prefix should be unique across all other connectors, since it is used as a prefix for all Kafka topic names that receive events emitted by this connector.
Only alphanumeric characters, hyphens, dots and underscores must be used in the database server logical name. +
+
[WARNING]
====
Do not change the value of this property.
If you change the name value, after a restart, instead of continuing to emit events to the original topics, the connector emits subsequent events to topics whose names are based on the new value.
The connector is also unable to recover its database schema history topic.
====
|[[mariadb-property-database-server-id]]<<mariadb-property-database-server-id, `+database.server.id+`>>
|No default
|A numeric ID of this database client, which must be unique across all currently-running database processes in the MariaDB cluster. This connector joins the MariaDB database cluster as another server (with this unique ID) so it can read the binlog.
|[[mariadb-property-database-include-list]]<<mariadb-property-database-include-list, `+database.include.list+`>>
|_empty string_
|An optional, comma-separated list of regular expressions that match the names of the databases for which to capture changes.
The connector does not capture changes in any database whose name is not in `database.include.list`.
By default, the connector captures changes in all databases. +
To match the name of a database, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the database; it does not match substrings that might be present in a database name. +
If you include this property in the configuration, do not also set the `database.exclude.list` property.
|[[mariadb-property-database-exclude-list]]<<mariadb-property-database-exclude-list, `+database.exclude.list+`>>
|_empty string_
|An optional, comma-separated list of regular expressions that match the names of databases for which you do not want to capture changes.
The connector captures changes in any database whose name is not in the `database.exclude.list`. +
To match the name of a database, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the database; it does not match substrings that might be present in a database name. +
If you include this property in the configuration, do not also set the `database.include.list` property.
|[[mariadb-property-table-include-list]]<<mariadb-property-table-include-list, `+table.include.list+`>>
|_empty string_
|An optional, comma-separated list of regular expressions that match fully-qualified table identifiers of tables whose changes you want to capture.
The connector does not capture changes in any table that is not included in `table.include.list`.
Each identifier is of the form _databaseName_._tableName_.
By default, the connector captures changes in every non-system table in each database whose changes are being captured. +
To match the name of a table, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the table; it does not match substrings that might be present in a table name. +
If you include this property in the configuration, do not also set the `table.exclude.list` property.
|[[mariadb-property-table-exclude-list]]<<mariadb-property-table-exclude-list, `+table.exclude.list+`>>
|_empty string_
|An optional, comma-separated list of regular expressions that match fully-qualified table identifiers for tables whose changes you do not want to capture.
The connector captures changes in any table that is not included in `table.exclude.list`.
Each identifier is of the form _databaseName_._tableName_. +
To match the name of a column, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the table; it does not match substrings that might be present in a table name. +
If you include this property in the configuration, do not also set the `table.include.list` property.
|[[mariadb-property-column-exclude-list]]<<mariadb-property-column-exclude-list, `+column.exclude.list+`>>
|_empty string_
|An optional, comma-separated list of regular expressions that match the fully-qualified names of columns to exclude from change event record values.
Fully-qualified names for columns are of the form _databaseName_._tableName_._columnName_. +
To match the name of a column, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the column; it does not match substrings that might be present in a column name.
If you include this property in the configuration, do not also set the `column.include.list` property.
|[[mariadb-property-column-include-list]]<<mariadb-property-column-include-list, `+column.include.list+`>>
|_empty string_
|An optional, comma-separated list of regular expressions that match the fully-qualified names of columns to include in change event record values.
Fully-qualified names for columns are of the form _databaseName_._tableName_._columnName_. +
To match the name of a column, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the column; it does not match substrings that might be present in a column name. +
If you include this property in the configuration, do not set the `column.exclude.list` property.
|[[mariadb-property-skip-messages-without-change]]<<mariadb-property-skip-messages-without-change, `+skip.messages.without.change+`>>
|`false`
| Specifies whether to skip publishing messages when there is no change in included columns. This would essentially filter messages if there is no change in columns included as per `column.include.list` or `column.exclude.list` properties.
|[[mariadb-property-column-truncate-to-length-chars]]<<mariadb-property-column-truncate-to-length-chars, `column.truncate.to._length_.chars`>>
|_n/a_
|An optional, comma-separated list of regular expressions that match the fully-qualified names of character-based columns.
Set this property if you want to truncate the data in a set of columns when it exceeds the number of characters specified by the _length_ in the property name.
Set `length` to a positive integer value, for example, `column.truncate.to.20.chars`.
The fully-qualified name of a column observes the following format: _databaseName_._tableName_._columnName_.
To match the name of a column, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the column; the expression does not match substrings that might be present in a column name.
You can specify multiple properties with different lengths in a single configuration.
|[[mariadb-property-column-mask-with-length-chars]]<<mariadb-property-column-mask-with-length-chars, `column.mask.with._length_.chars`>>
|_n/a_
|An optional, comma-separated list of regular expressions that match the fully-qualified names of character-based columns.
Set this property if you want the connector to mask the values for a set of columns, for example, if they contain sensitive data.
Set `_length_` to a positive integer to replace data in the specified columns with the number of asterisk (`*`) characters specified by the _length_ in the property name.
Set _length_ to `0` (zero) to replace data in the specified columns with an empty string.
The fully-qualified name of a column observes the following format: _databaseName_._tableName_._columnName_.
To match the name of a column, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the column; the expression does not match substrings that might be present in a column name.
You can specify multiple properties with different lengths in a single configuration.
|[[mariadb-property-column-mask-hash]]<<mariadb-property-column-mask-hash, `column.mask.hash._hashAlgorithm_.with.salt._salt_`>>;
[[mariadb-property-column-mask-hash-v2]]<<mariadb-property-column-mask-hash-v2, `column.mask.hash.v2._hashAlgorithm_.with.salt._salt_`>>
|_n/a_
a|An optional, comma-separated list of regular expressions that match the fully-qualified names of character-based columns.
Fully-qualified names for columns are of the form `_<databaseName>_._<tableName>_._<columnName>_`. +
To match the name of a column {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the column; the expression does not match substrings that might be present in a column name.
In the resulting change event record, the values for the specified columns are replaced with pseudonyms. +
A pseudonym consists of the hashed value that results from applying the specified _hashAlgorithm_ and _salt_.
Based on the hash function that is used, referential integrity is maintained, while column values are replaced with pseudonyms.
Supported hash functions are described in the {link-java7-standard-names}[MessageDigest section] of the Java Cryptography Architecture Standard Algorithm Name Documentation. +
+
In the following example, `CzQMA0cB5K` is a randomly selected salt. +
----
column.mask.hash.SHA-256.with.salt.CzQMA0cB5K = inventory.orders.customerName, inventory.shipment.customerName
----
If necessary, the pseudonym is automatically shortened to the length of the column.
The connector configuration can include multiple properties that specify different hash algorithms and salts. +
+
Depending on the _hashAlgorithm_ used, the _salt_ selected, and the actual data set, the resulting data set might not be completely masked. +
+
Hashing strategy version 2 should be used to ensure fidelity if the value is being hashed in different places or systems.
|[[mariadb-property-column-propagate-source-type]]<<mariadb-property-column-propagate-source-type, `+column.propagate.source.type+`>>
|_n/a_
a|An optional, comma-separated list of regular expressions that match the fully-qualified names of columns for which you want the connector to emit extra parameters that represent column metadata.
When this property is set, the connector adds the following fields to the schema of event records:
* `pass:[_]pass:[_]debezium.source.column.type` +
* `pass:[_]pass:[_]debezium.source.column.length` +
* `pass:[_]pass:[_]debezium.source.column.scale` +
These parameters propagate a column's original type name and length (for variable-width types), respectively. +
Enabling the connector to emit this extra data can assist in properly sizing specific numeric or character-based columns in sink databases.
The fully-qualified name of a column observes one of the following formats: _databaseName_._tableName_._columnName_, or _databaseName_._schemaName_._tableName_._columnName_. +
To match the name of a column, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the column; the expression does not match substrings that might be present in a column name.
|[[mariadb-property-datatype-propagate-source-type]]<<mariadb-property-datatype-propagate-source-type, `+datatype.propagate.source.type+`>>
|_n/a_
a|An optional, comma-separated list of regular expressions that specify the fully-qualified names of data types that are defined for columns in a database.
When this property is set, for columns with matching data types, the connector emits event records that include the following extra fields in their schema:
* `pass:[_]pass:[_]debezium.source.column.type` +
* `pass:[_]pass:[_]debezium.source.column.length` +
* `pass:[_]pass:[_]debezium.source.column.scale` +
These parameters propagate a column's original type name and length (for variable-width types), respectively. +
Enabling the connector to emit this extra data can assist in properly sizing specific numeric or character-based columns in sink databases.
The fully-qualified name of a column observes one of the following formats: _databaseName_._tableName_._typeName_, or _databaseName_._schemaName_._tableName_._typeName_. +
To match the name of a data type, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the data type; the expression does not match substrings that might be present in a type name.
For the list of MariaDB-specific data type names, see the xref:mariadb-data-types[MariaDB data type mappings].
|[[mariadb-property-time-precision-mode]]<<mariadb-property-time-precision-mode, `+time.precision.mode+`>>
|`adaptive_time_microseconds`
|Time, date, and timestamps can be represented with different kinds of precision, including: +
+
`adaptive_time_microseconds` (the default) captures the date, datetime and timestamp values exactly as in the database using either millisecond, microsecond, or nanosecond precision values based on the database column's type, with the exception of TIME type fields, which are always captured as microseconds. +
+
ifdef::community[]
`adaptive` (deprecated) captures the time and timestamp values exactly as in the database using either millisecond, microsecond, or nanosecond precision values based on the database column's type. +
endif::community[]
+
`connect` always represents time and timestamp values using Kafka Connect's built-in representations for Time, Date, and Timestamp, which use millisecond precision regardless of the database columns' precision.
|[[mariadb-property-decimal-handling-mode]]<<mariadb-property-decimal-handling-mode,`+decimal.handling.mode+`>>
|`precise`
|Specifies how the connector should handle values for `DECIMAL` and `NUMERIC` columns: +
+
`precise` (the default) represents them precisely using `java.math.BigDecimal` values represented in change events in a binary form. +
+
`double` represents them using `double` values, which may result in a loss of precision but is easier to use. +
+
`string` encodes values as formatted strings, which is easy to consume but semantic information about the real type is lost.
|[[mariadb-property-bigint-unsigned-handling-mode]]<<mariadb-property-bigint-unsigned-handling-mode, `+bigint.unsigned.handling.mode+`>>
|`long`
|Specifies how BIGINT UNSIGNED columns should be represented in change events. Possible settings are: +
+
`long` represents values by using Java's `long`, which might not offer the precision but which is easy to use in consumers. `long` is usually the preferred setting. +
+
`precise` uses `java.math.BigDecimal` to represent values, which are encoded in the change events by using a binary representation and Kafka Connect's `org.apache.kafka.connect.data.Decimal` type. Use this setting when working with values larger than 2^63, because these values cannot be conveyed by using `long`.
|[[mariadb-property-include-schema-changes]]<<mariadb-property-include-schema-changes, `+include.schema.changes+`>>
|`true`
|Boolean value that specifies whether the connector should publish changes in the database schema to a Kafka topic with the same name as the database server ID. Each schema change is recorded by using a key that contains the database name and whose value includes the DDL statement(s). This is independent of how the connector internally records database schema history.
|[[mariadb-property-include-schema-comments]]<<mariadb-property-include-schema-comments, `+include.schema.comments+`>>
|`false`
|Boolean value that specifies whether the connector should parse and publish table and column comments on metadata objects. Enabling this option will bring the implications on memory usage. The number and size of logical schema objects is what largely impacts how much memory is consumed by the Debezium connectors, and adding potentially large string data to each of them can potentially be quite expensive.
|[[mariadb-property-include-query]]<<mariadb-property-include-query, `+include.query+`>>
|`false`
|Boolean value that specifies whether the connector should include the original SQL query that generated the change event. +
+
If you set this option to `true` then you must also configure MariaDB with the `binlog_annotate_row_events` option set to `ON`.
When `include.query` is `true`, the query is not present for events that the snapshot process generates.
+
Setting `include.query` to `true` might expose tables or fields that are explicitly excluded or masked by including the original SQL statement in the change event.
For this reason, the default setting is `false`.
For more information about configuring the database to return the original `SQL` statement for each log event, see xref:enable-query-log-events[Enabling query log events].
|[[mariadb-property-event-deserialization-failure-handling-mode]]<<mariadb-property-event-deserialization-failure-handling-mode, `+event.deserialization.failure.handling.mode+`>>
|`fail`
|Specifies how the connector should react to exceptions during deserialization of binlog events.
This option is deprecated, please use xref:mariadb-property-event-processing-failure-handling-mode[`event.processing.failure.handling.mode`] option instead. +
+
`fail` propagates the exception, which indicates the problematic event and its binlog offset, and causes the connector to stop. +
+
`warn` logs the problematic event and its binlog offset and then skips the event. +
+
`ignore` passes over the problematic event and does not log anything.
|[[mariadb-property-inconsistent-schema-handling-mode]]<<mariadb-property-inconsistent-schema-handling-mode, `+inconsistent.schema.handling.mode+`>>
|`fail`
|Specifies how the connector should react to binlog events that relate to tables that are not present in internal schema representation. That is, the internal representation is not consistent with the database. +
+
`fail` throws an exception that indicates the problematic event and its binlog offset, and causes the connector to stop. +
+
`warn` logs the problematic event and its binlog offset and skips the event. +
+
`skip` passes over the problematic event and does not log anything.
|[[mariadb-property-connect-timeout-ms]]<<mariadb-property-connect-timeout-ms, `+connect.timeout.ms+`>>
|`30000`
|A positive integer value that specifies the maximum time in milliseconds this connector should wait after trying to connect to the MariaDB database server before timing out. Defaults to 30 seconds.
|[[mariadb-property-gtid-source-includes]]<<mariadb-property-gtid-source-includes, `+gtid.source.includes+`>>
|No default
|A comma-separated list of regular expressions that match source domain ids in the GTID set used that the connector uses to find the binlog position on the MariaDB server.
When this property is set, the connector uses only the GTID ranges that have source UUIDs that match one of the specified `include` patterns.
To match the value of a GTID, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the GTID's domain identifier. +
If you include this property in the configuration, do not also set the `gtid.source.excludes` property.
|[[mariadb-property-gtid-source-excludes]]<<mariadb-property-gtid-source-excludes, `+gtid.source.excludes+`>>
|No default
|A comma-separated list of regular expressions that match source domain ids in the GTID set that the connector uses to find the binlog position on the MariaDB server.
When this property is set, the connector uses only the GTID ranges that have source UUIDs that do not match any of the specified `exclude` patterns.
To match the value of a GTID, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the GTID's domain identifier. +
If you include this property in the configuration, do not also set the `gtid.source.includes` property.
|[[mariadb-property-tombstones-on-delete]]<<mariadb-property-tombstones-on-delete, `+tombstones.on.delete+`>>
|`true`
|Controls whether a _delete_ event is followed by a tombstone event. +
+
`true` - a delete operation is represented by a _delete_ event and a subsequent tombstone event. +
+
`false` - only a _delete_ event is emitted. +
+
After a source record is deleted, emitting a tombstone event (the default behavior) allows Kafka to completely delete all events that pertain to the key of the deleted row in case {link-kafka-docs}/#compaction[log compaction] is enabled for the topic.
|[[mariadb-property-message-key-columns]]<<mariadb-property-message-key-columns, `+message.key.columns+`>>
|_n/a_
|A list of expressions that specify the columns that the connector uses to form custom message keys for change event records that it publishes to the Kafka topics for specified tables.
By default, {prodname} uses the primary key column of a table as the message key for records that it emits.
In place of the default, or to specify a key for tables that lack a primary key, you can configure custom message keys based on one or more columns. +
+
To establish a custom message key for a table, list the table, followed by the columns to use as the message key.
Each list entry takes the following format: +
+
`_<fully-qualified_tableName>_:__<keyColumn>__,_<keyColumn>_` +
+
To base a table key on multiple column names, insert commas between the column names.
Each fully-qualified table name is a regular expression in the following format: +
+
`_<databaseName>_._<tableName>_` +
+
The property can include entries for multiple tables.
Use a semicolon to separate table entries in the list. +
+
The following example sets the message key for the tables `inventory.customers` and `purchase.orders`: +
+
`inventory.customers:pk1,pk2;(.*).purchaseorders:pk3,pk4` +
+
For the table `inventory.customer`, the columns `pk1` and `pk2` are specified as the message key.
For the `purchaseorders` tables in any database, the columns `pk3` and `pk4` server as the message key.
There is no limit to the number of columns that you use to create custom message keys.
However, it's best to use the minimum number that are required to specify a unique key.
|[[mariadb-property-binary-handling-mode]]<<mariadb-property-binary-handling-mode,`+binary.handling.mode+`>>
|bytes
|Specifies how binary columns, for example, `blob`, `binary`, `varbinary`, should be represented in change events. Possible settings: +
+
`bytes` represents binary data as a byte array. +
+
`base64` represents binary data as a base64-encoded String. +
+
`base64-url-safe` represents binary data as a base64-url-safe-encoded String. +
+
`hex` represents binary data as a hex-encoded (base16) String.
|[[mariadb-property-schema-name-adjustment-mode]]<<mariadb-property-schema-name-adjustment-mode,`+schema.name.adjustment.mode+`>>
|none
|Specifies how schema names should be adjusted for compatibility with the message converter used by the connector. Possible settings: +
* `none` does not apply any adjustment. +
* `avro` replaces the characters that cannot be used in the Avro type name with underscore. +
* `avro_unicode` replaces the underscore or characters that cannot be used in the Avro type name with corresponding unicode like _uxxxx. Note: _ is an escape sequence like backslash in Java +
|[[mariadb-property-field-name-adjustment-mode]]<<mariadb-property-field-name-adjustment-mode,`+field.name.adjustment.mode+`>>
|none
|Specifies how field names should be adjusted for compatibility with the message converter used by the connector. Possible settings: +
* `none` does not apply any adjustment. +
* `avro` replaces the characters that cannot be used in the Avro type name with underscore. +
* `avro_unicode` replaces the underscore or characters that cannot be used in the Avro type name with corresponding unicode like _uxxxx. Note: _ is an escape sequence like backslash in Java +
See {link-prefix}:{link-avro-serialization}#avro-naming[Avro naming] for more details.
|===
// Title: Advanced {prodname} MariaDB connector configuration properties
[id="mariadb-advanced-connector-configuration-properties"]
==== Advanced MariaDB connector configuration properties
==== Advanced {prodname} MariaDB connector configuration properties
The following table describes xref:mariadb-advanced-connector-configuration-properties[advanced MariaDB connector properties]. The default values for these properties rarely need to be changed. Therefore, you do not need to specify them in the connector configuration.
.Descriptions of MariaDB connector advanced configuration properties
[cols="30%a,20%a,50%a",options="header",subs="+attributes"]
|===
|Property |Default |Description
|[[mariadb-property-connect-keep-alive]]<<mariadb-property-connect-keep-alive, `+connect.keep.alive+`>>
|`true`
|A Boolean value that specifies whether a separate thread should be used to ensure that the connection to the MariaDB server/cluster is kept alive.
|[[mariadb-property-use-nongraceful-disconnect]]<<mariadb-property-use-nongraceful-disconnect, `+use.nongraceful.disconnect+`>>
|`false`
|A Boolean value that specifies whether the binary log client's keepalive thread sets the `SO_LINGER` socket option to `0` to immediately close stale TCP connections. +
Set the value to `true` if the connector experiences deadlocks in `SSLSocketImpl.close`. +
ifdef::community[]
For more information, see https://github.com/osheroff/mysql-binlog-connector-java/issues/133[Issue 133] in the https://github.com/osheroff/mysql-binlog-connector-java[mysql-binlog-connector-java] GitHub repository.
endif::community[]
|[[mariadb-property-converters]]<<mariadb-property-converters, `converters`>>
|No default
|Enumerates a comma-separated list of the symbolic names of the {link-prefix}:{link-custom-converters}#custom-converters[custom converter] instances that the connector can use. +
For example, `boolean`. +
This property is required to enable the connector to use a custom converter.
For each converter that you configure for a connector, you must also add a `.type` property, which specifies the fully-qualified name of the class that implements the converter interface.
The `.type` property uses the following format: +
`_<converterSymbolicName>_.type` +
For example, +
boolean.type: io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter
If you want to further control the behavior of a configured converter, you can add one or more configuration parameters to pass values to the converter.
To associate these additional configuration parameter with a converter, prefix the parameter name with the symbolic name of the converter. +
+
For example, to define a `selector` parameter that specifies the subset of columns that the `boolean` converter processes, add the following property: +
boolean.selector=db1.table1.*, db1.table2.column1
|[[mariadb-property-table-ignore-builtin]]<<mariadb-property-table-ignore-builtin, `+table.ignore.builtin+`>>
|`true`
|A Boolean value that specifies whether built-in system tables should be ignored. This applies regardless of the table include and exclude lists. By default, system tables are excluded from having their changes captured, and no events are generated when changes are made to any system tables.
|[[mariadb-property-database-ssl-mode]]<<mariadb-property-database-ssl-mode, `+database.ssl.mode+`>>
|`preferred`
|Specifies whether to use an encrypted connection. Possible settings are: +
+
`disabled` specifies the use of an unencrypted connection. +
+
`preferred` establishes an encrypted connection if the server supports secure connections. If the server does not support secure connections, falls back to an unencrypted connection. +
+
`required` establishes an encrypted connection or fails if one cannot be made for any reason. +
+
`verify_ca` behaves like `required` but additionally it verifies the server TLS certificate against the configured Certificate Authority (CA) certificates and fails if the server TLS certificate does not match any valid CA certificates. +
+
`verify_identity` behaves like `verify_ca` but additionally verifies that the server certificate matches the host of the remote connection.
|[[mariadb-property-database-ssl-keystore]]<<mariadb-property-database-ssl-keystore, `+database.ssl.keystore+`>>
|No defaults
|The location of the key store file.
This is optional and can be used for two-way authentication between the client and the MariaDB Server.
|[[mariadb-property-database-ssl-keystore-password]]<<mariadb-property-database-ssl-keystore-password, `+database.ssl.keystore.password+`>>
|No defaults
|The password for the key store file.
This is optional and only needed if xref:mariadb-property-database-ssl-keystore[`database.ssl.keystore`] is configured.
|[[mariadb-property-database-ssl-truststore]]<<mariadb-property-database-ssl-truststore, `+database.ssl.truststore+`>>
|No defaults
|The location of the trust store file for the server certificate verification.
|[[mariadb-property-database-ssl-truststore-password]]<<mariadb-property-database-ssl-truststore-password, `+database.ssl.truststore.password+`>>
|No defaults
|The password for the trust store file.
Used to check the integrity of the truststore, and unlock the truststore.
ifdef::community[]
|[[mariadb-property-binlog-buffer-size]]<<mariadb-property-binlog-buffer-size, `+binlog.buffer.size+`>>
|0
|The size of a look-ahead buffer used by the binlog reader. The default setting of `0` disables buffering. +
+
Under specific conditions, it is possible that the MariaDB binlog contains uncommitted data finished by a `ROLLBACK` statement.
Typical examples are using savepoints or mixing temporary and regular table changes in a single transaction. +
+
When a beginning of a transaction is detected then {prodname} tries to roll forward the binlog position and find either `COMMIT` or `ROLLBACK` so it can determine whether to stream the changes from the transaction.
The size of the binlog buffer defines the maximum number of changes in the transaction that {prodname} can buffer while searching for transaction boundaries.
If the size of the transaction is larger than the buffer then {prodname} must rewind and re-read the events that have not fit into the buffer while streaming. +
+
NOTE: This feature is incubating. Feedback is encouraged. It is expected that this feature is not completely polished.
endif::community[]
|[[mariadb-property-max-batch-size]]<<mariadb-property-max-batch-size, `+max.batch.size+`>>
|`2048`
|Positive integer value that specifies the maximum size of each batch of events that should be processed during each iteration of this connector. Defaults to 2048.
|[[mariadb-property-max-queue-size]]<<mariadb-property-max-queue-size, `+max.queue.size+`>>
|`8192`
|Positive integer value that specifies the maximum number of records that the blocking queue can hold.
When {prodname} reads events streamed from the database, it places the events in the blocking queue before it writes them to Kafka.
The blocking queue can provide backpressure for reading change events from the database
in cases where the connector ingests messages faster than it can write them to Kafka, or when Kafka becomes unavailable.
Events that are held in the queue are disregarded when the connector periodically records offsets.
Always set the value of `max.queue.size` to be larger than the value of xref:{context}-property-max-batch-size[`max.batch.size`].
|[[mariadb-property-max-queue-size-in-bytes]]<<mariadb-property-max-queue-size-in-bytes, `+max.queue.size.in.bytes+`>>
|`0`
|A long integer value that specifies the maximum volume of the blocking queue in bytes.
By default, volume limits are not specified for the blocking queue.
To specify the number of bytes that the queue can consume, set this property to a positive long value. +
If xref:mariadb-property-max-queue-size[`max.queue.size`] is also set, writing to the queue is blocked when the size of the queue reaches the limit specified by either property.
For example, if you set `max.queue.size=1000`, and `max.queue.size.in.bytes=5000`, writing to the queue is blocked after the queue contains 1000 records, or after the volume of the records in the queue reaches 5000 bytes.
|[[mariadb-property-poll-interval-ms]]<<mariadb-property-poll-interval-ms, `+poll.interval.ms+`>>
|`500`
|Positive integer value that specifies the number of milliseconds the connector should wait for new change events to appear before it starts processing a batch of events. Defaults to 500 milliseconds, or 0.5 second.
|[[mariadb-property-snapshot-mode]]<<mariadb-property-snapshot-mode, `+snapshot.mode+`>>
|_initial_
|Specifies the criteria for running a snapshot when the connector starts. Possible settings are: +
`always`:: The connector performs a snapshot every time that it starts.
The snapshot includes the structure and data of the captured tables.
Specify this value to populate topics with a complete representation of the data from the captured tables every time that the connector starts.
`initial`:: The connector runs a snapshot only when no offsets have been recorded for the logical server name, or if it detects that an earlier snapshot failed to complete.
After the snapshot completes, the connector begins to stream event records for subsequent database changes.
`initial_only`:: The connector runs a snapshot only when no offsets have been recorded for the logical server name.
After the snapshot completes, the connector stops.
It does not transition to streaming to read change events from the binlog.
`schema_only`:: Deprecated, see `no_data`.
`no_data`:: The connector runs a snapshot that captures only the schema, but not any table data.
Set this option if you do not need the topics to contain a consistent snapshot of the data, but you want to capture any schema changes that were applied after the last connector restart.
`schema_only_recovery`:: Deprecated, see `recovery`.
`recovery`:: Set this option to restore a database schema history topic that is lost or corrupted.
After a restart, the connector runs a snapshot that rebuilds the topic from the source tables.
You can also set the property to periodically prune a database schema history topic that experiences unexpected growth. +
+
WARNING: Do not use this mode to perform a snapshot if schema changes were committed to the database after the last connector shutdown.
`never`:: When the connector starts, rather than performing a snapshot, it immediately begins to stream event records for subsequent database changes.
This option is under consideration for future deprecation, in favor of the `no_data` option.
`when_needed`:: After the connector starts, it performs a snapshot only if it detects one of the following circumstances:
* It cannot detect any topic offsets.
* A previously recorded offset specifies a binlog position or GTID that is not available on the server.
ifdef::community[]
`configuration_based`:: With this option, you control snapshot behavior through a set of connector properties that have the prefix 'snapshot.mode.configuration.based'.
endif::community[]
ifdef::community[]
`custom`:: The connector performs a snapshot according to the implementation specified by the xref:mariadb-property-snapshot-mode-custom-name[`snapshot.mode.custom.name`] property, which defines a custom implementation of the `io.debezium.spi.snapshot.Snapshotter` interface.
endif::community[]
ifdef::community[]
|[[mariadb-property-snapshot-mode-configuration-based-snapshot-data]]<<mariadb-property-configuration-based-snapshot-data, `+snapshot.mode.configuration.based.snapshot.data+`>>
|false
|If the `snapshot.mode` is set to `configuration_based`, set this property to specify whether the connector includes table data when it performs a snapshot.
endif::community[]
ifdef::community[]
|[[mariadb-property-snapshot-mode-configuration-based-snapshot-schema]]<<mariadb-property-configuration-based-snapshot-schema, `+snapshot.mode.configuration.based.snapshot.schema+`>>
|false
|If the `snapshot.mode` is set to `configuration_based`, set this property to specify whether the connector includes the table schema when it performs a snapshot.
endif::community[]
ifdef::community[]
|[[mariadb-property-snapshot-mode-configuration-based-start-stream]]<<mariadb-property-configuration-based-start-stream, `+snapshot.mode.configuration.based.start.stream+`>>
|false
|If the `snapshot.mode` is set to `configuration_based`, set this property to specify whether the connector begins to stream change events after a snapshot completes.
endif::community[]
ifdef::community[]
|[[mariadb-property-snapshot-mode-configuration-based-snapshot-on-schema-error]]<<mariadb-property-configuration-based-snapshot-on-schema-error, `+snapshot.mode.configuration.based.snapshot.on.schema.error+`>>
|false
|If the `snapshot.mode` is set to `configuration_based`, set this property to specify whether the connector includes table schema in a snapshot if the schema history topic is not available.
endif::community[]
ifdef::community[]
|[[mariadb-property-snapshot-mode-configuration-based-snapshot-on-data-error]]<<mariadb-property-configuration-based-snapshot-on-data-error, `+snapshot.mode.configuration.based.snapshot.on.data.error+`>>
|false
|If the `snapshot.mode` is set to `configuration_based`, set this property to specify whether the connector includes table data in a snapshot in the event that data is no longer available in the transaction log.
endif::community[]
ifdef::community[]
|[[mariadb-property-snapshot-mode-custom-name]]<<mariadb-property-snapshot-mode-custom-name, `+snapshot.mode.custom.name+`>>
|No default
| If `snapshot.mode` is set to `custom`, use this setting to specify the name of the custom implementation that is provided in the `name()` method that is defined in the 'io.debezium.spi.snapshot.Snapshotter' interface.
After a connector restart, {prodname} calls the specified custom implementation to determine whether to perform a snapshot.
For more information, see xref:connector-custom-snapshot[custom snapshotter SPI].
endif::community[]
|[[mariadb-property-snapshot-locking-mode]]<<mariadb-property-snapshot-locking-mode, `+snapshot.locking.mode+`>>
|_minimal_
a|Controls whether and how long the connector holds the global MariaDB read lock, which prevents any updates to the database, while the connector is performing a snapshot. Possible settings are: +
`minimal`:: The connector holds the global read lock for only the initial phase of the snapshot during which it reads the database schemas and other metadata.
During the next phase of the snapshot, the connector releases the lock as it selects all rows from each table.
To perform the SELECT operation in a consistent fashion, the connector uses a REPEATABLE READ transaction.
Although the release of the global read lock permits other MariaDB clients to update the database, use of REPEATABLE READ isolation ensures a consistent snapshot, because the connector continues to read the same data for the duration of the transaction. +
`extended`:: Blocks all write operations for the duration of the snapshot.
Use this setting if clients submit concurrent operations that are incompatible with the REPEATABLE READ isolation level in MariaDB. +
`none`:: Prevents the connector from acquiring any table locks during the snapshot.
Although this option is allowed with all snapshot modes, it is safe to use _only_ if no schema changes occur while the snapshot is running.
Tables that are defined with the MyISAM engine always acquire a table lock.
As a result, such tables are locked even if you set this option.
This behavior differs from tables that are defined by the InnoDB engine, which acquire row-level locks.
ifdef::community[]
`custom`:: The connector performs a snapshot according to the implementation specified by the xref:mariadb-property-snapshot-locking-mode-custom-name[`snapshot.locking.mode.custom.name`] property, which is a custom implementation of the `io.debezium.spi.snapshot.SnapshotLock` interface.
endif::community[]
ifdef::community[]
|[[mariadb-property-snapshot-locking-mode-custom-name]]<<mariadb-property-snapshot-locking-mode-custom-name, `+snapshot.locking.mode.custom.name+`>>
|No default
| When xref:mariadb-property-snapshot-locking-mode[`snapshot.locking.mode`] is set to `custom`, use this setting to specify the name of the custom implementation provided in the `name()` method that is defined by the 'io.debezium.spi.snapshot.SnapshotLock' interface.
For more information, see xref:connector-custom-snapshot[custom snapshotter SPI].
endif::community[]
|[[mariadb-property-snapshot-query-mode]]<<mariadb-property-snapshot-query-mode, `+snapshot.query.mode+`>>
|`select_all`
|Specifies how the connector queries data while performing a snapshot. +
Set one of the following options:
`select_all`:: The connector performs a `select all` query by default, optionally adjusting the columns selected based on the column include and exclude list configurations.
ifdef::community[]
`custom`:: The connector performs a snapshot query according to the implementation specified by the xref:mariadb-property-snapshot-snapshot-query-mode-custom-name[`snapshot.query.mode.custom.name`] property, which defines a custom implementation of the `io.debezium.spi.snapshot.SnapshotQuery` interface. +
endif::community[]
This setting enables you to manage snapshot content in a more flexible manner compared to using the xref:mariadb-property-snapshot-select-statement-overrides[`snapshot.select.statement.overrides`] property.
ifdef::community[]
|[[mariadb-property-snapshot-snapshot-query-mode-custom-name]]<<mariadb-property-snapshot-query-mode-custom-name, `+snapshot.query.mode.custom.name+`>>
|No default
| When xref:mariadb-property-snapshot-query-mode[`snapshot.query.mode`] is set as `custom`, use this setting to specify the name of the custom implementation provided in the `name()` method that is defined by the 'io.debezium.spi.snapshot.SnapshotQuery' interface.
For more information, see xref:connector-custom-snapshot[custom snapshotter SPI].
endif::community[]
|[[mariadb-property-snapshot-include-collection-list]]<<mariadb-property-snapshot-include-collection-list, `+snapshot.include.collection.list+`>>
| All tables specified in `table.include.list`
|An optional, comma-separated list of regular expressions that match the fully-qualified names (`_<databaseName>.<tableName>_`) of the tables to include in a snapshot.
The specified items must be named in the connector's xref:mariadb-property-table-include-list[`table.include.list`] property.
This property takes effect only if the connector's xref:mariadb-property-snapshot-mode[`snapshot.mode`] property is set to a value other than `never`. +
This property does not affect the behavior of incremental snapshots. +
To match the name of a table, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the table; it does not match substrings that might be present in a table name.
|[[mariadb-property-snapshot-select-statement-overrides]]<<mariadb-property-snapshot-select-statement-overrides, `+snapshot.select.statement.overrides+`>>
|No default
|Specifies the table rows to include in a snapshot.
Use the property if you want a snapshot to include only a subset of the rows in a table.
This property affects snapshots only.
It does not apply to events that the connector reads from the log.
The property contains a comma-separated list of fully-qualified table names in the form `_<databaseName>.<tableName>_`. For example, +
+
`+"snapshot.select.statement.overrides": "inventory.products,customers.orders"+` +
+
For each table in the list, add a further configuration property that specifies the `SELECT` statement for the connector to run on the table when it takes a snapshot.
The specified `SELECT` statement determines the subset of table rows to include in the snapshot.
Use the following format to specify the name of this `SELECT` statement property: +
+
`snapshot.select.statement.overrides._<databaseName>_._<tableName>_`.
For example,
`snapshot.select.statement.overrides.customers.orders`. +
+
Example:
From a `customers.orders` table that includes the soft-delete column, `delete_flag`, add the following properties if you want a snapshot to include only those records that are not soft-deleted:
----
"snapshot.select.statement.overrides": "customer.orders",
"snapshot.select.statement.overrides.customer.orders": "SELECT * FROM [customers].[orders] WHERE delete_flag = 0 ORDER BY id DESC"
----
In the resulting snapshot, the connector includes only the records for which `delete_flag = 0`.
|[[mariadb-property-min-row-count-to-stream-results]]<<mariadb-property-min-row-count-to-stream-results, `+min.row.count.to.stream.results+`>>
|`1000`
|During a snapshot, the connector queries each table for which the connector is configured to capture changes. The connector uses each query result to produce a read event that contains data for all rows in that table. This property determines whether the MariaDB connector puts results for a table into memory, which is fast but requires large amounts of memory, or streams the results, which can be slower but work for very large tables. The setting of this property specifies the minimum number of rows a table must contain before the connector streams results. +
+
To skip all table size checks and always stream all results during a snapshot, set this property to `0`.
|[[mariadb-property-heartbeat-interval-ms]]<<mariadb-property-heartbeat-interval-ms, `+heartbeat.interval.ms+`>>
|`0`
|Controls how frequently the connector sends heartbeat messages to a Kafka topic. The default behavior is that the connector does not send heartbeat messages. +
+
Heartbeat messages are useful for monitoring whether the connector is receiving change events from the database. Heartbeat messages might help decrease the number of change events that need to be re-sent when a connector restarts. To send heartbeat messages, set this property to a positive integer, which indicates the number of milliseconds between heartbeat messages.
|[[mariadb-property-heartbeat-action-query]]<<mariadb-property-heartbeat-action-query, `+heartbeat.action.query+`>>
|No default
|Specifies a query that the connector executes on the source database when the connector sends a heartbeat message. +
+
For example, this can be used to periodically capture the state of the executed GTID set in the source database. +
+
`INSERT INTO gtid_history_table (select @gtid_executed)`
|[[mariadb-property-database-initial-statements]]<<mariadb-property-database-initial-statements, `+database.initial.statements+`>>
|No default
|A semicolon separated list of SQL statements to be executed when a JDBC connection, not the connection that is reading the transaction log, to the database is established.
To specify a semicolon as a character in a SQL statement and not as a delimiter, use two semicolons, (`;;`). +
+
The connector might establish JDBC connections at its own discretion, so this property is ony for configuring session parameters. It is not for executing DML statements.
|[[mariadb-property-snapshot-delay-ms]]<<mariadb-property-snapshot-delay-ms, `+snapshot.delay.ms+`>>
|No default
|An interval in milliseconds that the connector should wait before performing a snapshot when the connector starts. If you are starting multiple connectors in a cluster, this property is useful for avoiding snapshot interruptions, which might cause re-balancing of connectors.
|[[mariadb-property-snapshot-fetch-size]]<<mariadb-property-snapshot-fetch-size, `+snapshot.fetch.size+`>>
|No default
|During a snapshot, the connector reads table content in batches of rows. This property specifies the maximum number of rows in a batch.
|[[mariadb-property-snapshot-lock-timeout-ms]]<<mariadb-property-snapshot-lock-timeout-ms, `+snapshot.lock.timeout.ms+`>>
|`10000`
|Positive integer that specifies the maximum amount of time (in milliseconds) to wait to obtain table locks when performing a snapshot. If the connector cannot acquire table locks in this time interval, the snapshot fails. See xref:mariadb-snapshots[how MariaDB connectors perform database snapshots].
|[[mariadb-property-enable-time-adjuster]]<<mariadb-property-enable-time-adjuster, `+enable.time.adjuster+`>>
|`true`
|Boolean value that indicates whether the connector converts a 2-digit year specification to 4 digits. Set to `false` when conversion is fully delegated to the database. +
+
MariaDB allows users to insert year values with either 2-digits or 4-digits. For 2-digit values, the value gets mapped to a year in the range 1970 - 2069. The default behavior is that the connector does the conversion.
ifdef::community[]
|[[mariadb-property-source-struct-version]]<<mariadb-property-source-struct-version, `+source.struct.version+`>>
|`v2`
|Schema version for the `source` block in {prodname} events. {prodname} 0.10 introduced a few breaking changes to the structure of the `source` block in order to unify the exposed structure across all the connectors. +
+
By setting this option to `v1`, the structure used in earlier versions can be produced. However, this setting is not recommended and is planned for removal in a future {prodname} version.
endif::community[]
|[[mariadb-property-skipped-operations]]<<mariadb-property-skipped-operations, `+skipped.operations+`>>
|`t`
|A comma-separated list of operation types that will be skipped during streaming.
The operations include: `c` for inserts/create, `u` for updates, `d` for deletes, `t` for truncates, and `none` to not skip any operations.
By default, truncate operations are skipped.
|[[mariadb-property-signal-data-collection]]<<mariadb-property-signal-data-collection,`+signal.data.collection+`>>
|No default value
|Fully-qualified name of the data collection that is used to send {link-prefix}:{link-signalling}#debezium-signaling-enabling-source-signaling-channel[signals] to the connector. +
Use the following format to specify the collection name: +
`_<databaseName>_._<tableName>_`
|[[mariadb-property-signal-enabled-channels]]<<mariadb-property-signal-enabled-channels, `+signal.enabled.channels+`>>
|source
|List of the signaling channel names that are enabled for the connector.
By default, the following channels are available:
* `source`
* `kafka`
* `file`
* `jmx`
ifdef::community[]
Optionally, you can also implement a {link-prefix}:{link-signalling}#debezium-signaling-enabling-custom-signaling-channel[custom signaling channel].
endif::community[]
|[[mariadb-property-notification-enabled-channels]]<<mariadb-property-notification-enabled-channels, `+notification.enabled.channels+`>>
|No default
| List of notification channel names that are enabled for the connector.
By default, the following channels are available:
* `sink`
* `log`
* `jmx`
ifdef::community[]
Optionally, you can also implement a {link-prefix}:{link-notification}#debezium-notification-custom-channel[custom notification channel].
endif::community[]
|[[mariadb-property-incremental-snapshot-allow-schema-changes]]<<mariadb-property-incremental-snapshot-allow-schema-changes, `+incremental.snapshot.allow.schema.changes+`>>
|`false`
| Allow schema changes during an incremental snapshot. When enabled the connector will detect schema change during an incremental snapshot and re-select a current chunk to avoid locking DDLs. +
+
Note that changes to a primary key are not supported and can cause incorrect results if performed during an incremental snapshot. Another limitation is that if a schema change affects only columns' default values, then the change won't be detected until the DDL is processed from the binlog stream. This doesn't affect the snapshot events' values, but the schema of snapshot events may have outdated defaults.
|[[mariadb-property-incremental-snapshot-chunk-size]]<<mariadb-property-incremental-snapshot-chunk-size, `+incremental.snapshot.chunk.size+`>>
|`1024`
|The maximum number of rows that the connector fetches and reads into memory during an incremental snapshot chunk.
Increasing the chunk size provides greater efficiency, because the snapshot runs fewer snapshot queries of a greater size.
However, larger chunk sizes also require more memory to buffer the snapshot data.
Adjust the chunk size to a value that provides the best performance in your environment.
|[[mariadb-property-incremental-snapshot-watermarking-strategy]]<<mariadb-property-incremental-snapshot-watermarking-strategy, `+incremental.snapshot.watermarking.strategy+`>>
|`insert_insert`
|Specifies the watermarking mechanism that the connector uses during an incremental snapshot to deduplicate events that might be captured by an incremental snapshot and then recaptured after streaming resumes. +
You can specify one of the following options:
`insert_insert`:: When you send a signal to initiate an incremental snapshot, for every chunk that {prodname} reads during the snapshot, it writes an entry to the signaling data collection to record the signal to open the snapshot window.
After the snapshot completes, {prodname} inserts a second entry that records the signal to close the window.
`insert_delete`:: When you send a signal to initiate an incremental snapshot, for every chunk that {prodname} reads, it writes a single entry to the signaling data collection to record the signal to open the snapshot window.
After the snapshot completes, this entry is removed.
No entry is created for the signal to close the snapshot window.
Set this option to prevent rapid growth of the signaling data collection.
ifdef::community[]
|[[mariadb-property-read-only]]<<mariadb-property-read-only, `+read.only+`>>
|`false`
|Switch to alternative incremental snapshot watermarks implementation to avoid writes to signal data collection
endif::community[]
|[[mariadb-property-provide-transaction-metadata]]<<mariadb-property-provide-transaction-metadata, `provide.transaction.metadata`>>
|`false`
|Determines whether the connector generates events with transaction boundaries and enriches change event envelopes with transaction metadata. Specify `true` if you want the connector to do this. See xref:mariadb-transaction-metadata[Transaction metadata] for details.
|[[mariadb-property-event-processing-failure-handling-mode]]<<mariadb-property-event-processing-failure-handling-mode, `event.processing.failure.handling.mode`>>
|`fail`
|Specify how failures during processing of events (i.e. when encountering a corrupted event) should be handled. By default, `fail` mode raises an exception indicating the problematic event and its position, causing the connector to be stopped. `warn` mode does not raise the exception, instead the problematic event and its position will be logged and the event will be skipped. `ignore` mode ignores the problematic event completely with no logging.
|[[mariadb-property-topic-naming-strategy]]<<mariadb-property-topic-naming-strategy, `topic.naming.strategy`>>
|`io.debezium.schema.DefaultTopicNamingStrategy`
|The name of the TopicNamingStrategy class that should be used to determine the topic name for data change, schema change, transaction, heartbeat event etc., defaults to `DefaultTopicNamingStrategy`.
|[[mariadb-property-topic-delimiter]]<<mariadb-property-topic-delimiter, `topic.delimiter`>>
|`.`
|Specify the delimiter for topic name, defaults to `.`.
|[[mariadb-property-topic-cache-size]]<<mariadb-property-topic-cache-size, `topic.cache.size`>>
|`10000`
|The size used for holding the topic names in bounded concurrent hash map. This cache will help to determine the topic name corresponding to a given data collection.
|[[mariadb-property-topic-heartbeat-prefix]]<<mariadb-property-topic-heartbeat-prefix, `+topic.heartbeat.prefix+`>>
|`__debezium-heartbeat`
|Controls the name of the topic to which the connector sends heartbeat messages. The topic name has this pattern: +
+
_topic.heartbeat.prefix_._topic.prefix_ +
+
For example, if the topic prefix is `fulfillment`, the default topic name is `__debezium-heartbeat.fulfillment`.
|[[mariadb-property-topic-transaction]]<<mariadb-property-topic-transaction, `topic.transaction`>>
|`transaction`
|Controls the name of the topic to which the connector sends transaction metadata messages. The topic name has this pattern: +
+
_topic.prefix_._topic.transaction_ +
+
For example, if the topic prefix is `fulfillment`, the default topic name is `fulfillment.transaction`.
|[[mariadb-property-snapshot-max-threads]]<<mariadb-property-snapshot-max-threads, `snapshot.max.threads`>>
|`1`
|Specifies the number of threads that the connector uses when performing an initial snapshot.
To enable parallel initial snapshots, set the property to a value greater than 1.
In a parallel initial snapshot, the connector processes multiple tables concurrently.
ifdef::community[]
This feature is incubating.
endif::community[]
ifdef::product[]
[IMPORTANT]
====
Parallel initial snapshots is a Developer Preview feature only.
Developer Preview software is not supported by Red{nbsp}Hat in any way and is not functionally complete or production-ready.
Do not use Developer Preview software for production or business-critical workloads.
Developer Preview software provides early access to upcoming product software in advance of its possible inclusion in a Red{nbsp}Hat product offering.
Customers can use this software to test functionality and provide feedback during the development process.
This software is subject to change or removal at any time, and has received limited testing.
Red{nbsp}Hat might provide ways to submit feedback on Developer Preview software without an associated SLA.
For more information about the support scope of Red{nbsp}Hat Developer Preview software, see link:https://access.redhat.com/support/offerings/devpreview/[Developer Preview Support Scope].
====
endif::product[]
|[[mariadb-property-snapshot-tables-order-by-row-count]]<<mariadb-property-snapshot-tables-order-by-row-count, `snapshot.tables.order.by.row.count`>>
|`disabled`
|Controls the order in which the connector processes tables when it performs an initial snapshot.
Specify one of the following options:
`descending`:: The connector snapshots tables in order, based on the number of rows from the highest to the lowest.
`ascending`:: The connector snapshots tables in order, based on the number of rows, from lowest to highest.
`disabled`:: The connector disregards row count when performing an initial snapshot.
|[[mariadb-property-custom-metric-tags]]<<mariadb-property-custom-metric-tags, `custom.metric.tags`>>
|`No default`
|Defines tags that customize MBean object names by adding metadata that provides contextual information.
Specify a comma-separated list of key-value pairs.
Each key represents a tag for the MBean object name, and the corresponding value represents a value for the key, for example, +
`k1=v1,k2=v2`
The connector appends the specified tags to the base MBean object name.
Tags can help you to organize and categorize metrics data.
You can define tags to identify particular application instances, environments, regions, versions, and so forth.
For more information, see xref:customized-mbean-names[Customized MBean names].
|[[mariadb-property-errors-max-retires]]<<mariadb-property-errors-max-retires, `errors.max.retries`>>
|`-1`
|Specifies how the connector responds after an operation that results in a retriable error, such as a connection error. +
Set one of the following options:
`-1`:: No limit. The connector always restarts automatically, and retries the operation, regardless of the number of previous failures.
`0`:: Disabled. The connector fails immediately, and never retries the operation.
User intervention is required to restart the connector.
`> 0`:: The connector restarts automatically until it reaches the specified maximum number of retries.
After the next failure, the connector stops, and user intervention is required to restart it.
|[[mariadb-property-event-converting-failure-handling-mode]]<<mariadb-property-event-converting-failure-handling-mode, `event.converting.failure.handling.mode`>>
|`warn`
|Specifies how the connector responds when a mismatch between the data type of a column and the type specified by the {prodname} internal schema prevents successful conversion of a table record. +
Set one of the following options:
`fail`:: An exception reports that conversion failed because the data type of the field did not match the schema type, and indicates that it might be necessary to restart the connector in `schema _only_recovery` mode to enable a successful conversion.
`warn`:: The connector writes a `null` value to the event field for the column that failed conversion, writes a message to the warning log . +
`skip`:: The connector writes a `null` value to the event field for the column that failed conversion, and writes a message to the debug log.
|[[mariadb-property-database-query-timeout-ms]]<<mariadb-property-database-query-timeout-ms, `database.query.timeout.ms`>>
|`600000` (10 minutes)
|Specifies the time, in milliseconds, that the connector waits for a query to complete.
Set the value to `0` (zero) to remove the timeout limit.
|===
include::{partialsdir}/modules/all-connectors/ref-mariadb-mysql-adv-connector-cfg-props.adoc[leveloffset=+1]
[id="debezium-mariadb-connector-database-history-configuration-properties"]
==== {prodname} connector database schema history configuration properties
@ -3880,15 +488,7 @@ include::{partialsdir}/modules/all-connectors/ref-connector-pass-through-databas
[[mariadb-monitoring]]
== Monitoring
// ifdef::shared[]
The {prodname} MariaDB connector provides three types of metrics that are in addition to the built-in support for JMX metrics that Zookeeper, Kafka, and Kafka Connect provide.
* xref:mariadb-snapshot-metrics[Snapshot metrics] provide information about connector operation while performing a snapshot.
* xref:mariadb-streaming-metrics[Streaming metrics] provide information about connector operation when the connector is reading the binlog.
* xref:mariadb-schema-history-metrics[Schema history metrics] provide information about the status of the connector's schema history.
{link-prefix}:{link-debezium-monitoring}#monitoring-debezium[{prodname} monitoring documentation] provides details for how to expose these metrics by using JMX.
// endif::shared[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=monitoring-intro]
// Type: concept
// ModuleID: monitoring-debezium-mariadb-connectors-customized-mbean-names
@ -3909,70 +509,19 @@ include::{partialsdir}/modules/all-connectors/ref-connector-monitoring-snapshot-
include::{partialsdir}/modules/all-connectors/ref-connector-monitoring-incremental-snapshot-metrics.adoc[leveloffset=+1]
// ifdef::shared[]
The {prodname} MariaDB connector also provides the `HoldingGlobalLock` custom snapshot metric. This metric is set to a Boolean value that indicates whether the connector currently holds a global or table write lock.
// endif::shared[]
// Type: reference
// ModuleID: monitoring-debezium-mariadb-connector-record-streaming
// Title: Monitoring {prodname} MariaDB connector record streaming
[[mariadb-streaming-metrics]]
=== Streaming metrics
// ifdef:;shared[]
Transaction-related attributes are available only if binlog event buffering is enabled.
ifdef::community[]
See xref:mariadb-property-binlog-buffer-size[`binlog.buffer.size`] in the advanced connector configuration properties for more details.
endif::community[]
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=monitoring-intro]
include::{partialsdir}/modules/all-connectors/frag-common-mbean-name.adoc[leveloffset=+1,tags=common-streaming]
include::{partialsdir}/modules/all-connectors/ref-connector-monitoring-streaming-metrics.adoc[leveloffset=+1]
The {prodname} MariaDB connector also provides the following additional streaming metrics:
.Descriptions of additional streaming metrics
[cols="3,2,5",options="header"]
|===
|Attribute |Type |Description
|[[binlog-filename]]<<binlog-filename,`+BinlogFilename+`>>
|`string`
|The name of the binlog file that the connector has most recently read.
|[[binlog-position]]<<binlog-position,`+BinlogPosition+`>>
|`long`
|The most recent position (in bytes) within the binlog that the connector has read.
|[[is-gtid-mode-enabled]]<<is-gtid-mode-enabled,`+IsGtidModeEnabled+`>>
|`boolean`
|Flag that denotes whether the connector is currently tracking GTIDs from MariaDB server.
|[[gtid-set]]<<gtid-set,`+GtidSet+`>>
|`string`
|The string representation of the most recent GTID set processed by the connector when reading the binlog.
|[[number-of-skipped-events]]<<number-of-skipped-events,`+NumberOfSkippedEvents+`>>
|`long`
|The number of events that have been skipped by the MariaDB connector. Typically events are skipped due to a malformed or unparseable event from MariaDB's binlog.
|[[number-of-disconnects]]<<number-of-disconnects,`+NumberOfDisconnects+`>>
|`long`
|The number of disconnects by the MariaDB connector.
|[[number-of-rolled-back-transactions]]<<number-of-rolled-back-transactions,`+NumberOfRolledBackTransactions+`>>
|`long`
|The number of processed transactions that were rolled back and not streamed.
|[[number-of-not-well-formed-transactions]]<<number-of-not-well-formed-transactions,`+NumberOfNotWellFormedTransactions+`>>
|`long`
|The number of transactions that have not conformed to the expected protocol of `BEGIN` + `COMMIT`/`ROLLBACK`. This value should be `0` under normal conditions.
|[[number-of-large-transactions]]<<number-of-large-transactions,`+NumberOfLargeTransactions+`>>
|`long`
|The number of transactions that have not fit into the look-ahead buffer. For optimal performance, this value should be significantly smaller than `NumberOfCommittedTransactions` and `NumberOfRolledBackTransactions`.
|===
// endif::shared[]
// Moved table of connector-specific metrics to conditonalized section of the preceding shared file.
// Type: reference
// ModuleID: monitoring-debezium-mariadb-connector-schema-history
@ -3988,70 +537,4 @@ include::{partialsdir}/modules/all-connectors/ref-connector-monitoring-schema-hi
[[mariadb-when-things-go-wrong]]
== Behavior when things go wrong
{prodname} is a distributed system that captures all changes in multiple upstream databases; it never misses or loses an event. When the system is operating normally or being managed carefully then {prodname} provides _exactly once_ delivery of every change event record.
If a fault does happen then the system does not lose any events. However, while it is recovering from the fault, it might repeat some change events. In these abnormal situations, {prodname}, like Kafka, provides _at least once_ delivery of change events.
ifdef::community[]
The rest of this section describes how {prodname} handles various kinds of faults and problems.
endif::community[]
ifdef::product[]
Details are in the following sections:
* xref:debezium-mariadb-connector-configuration-and-startup-errors[]
* xref:mariadb-becomes-unavailable-while-debezium-is-running[]
* xref:debezium-mariadb-kafka-connect-process-stops-gracefully[]
* xref:debezium-mariadb-kafka-connect-process-crashes[]
* xref:debezium-mariadb-kafka-process-becomes-unavailable[]
* xref:mariadb-purges-binlog-files-used-by-debezium[]
endif::product[]
[id="debezium-mariadb-connector-configuration-and-startup-errors"]
=== Configuration and startup errors
In the following situations, the connector fails when trying to start, reports an error or exception in the log, and stops running:
* The connector's configuration is invalid.
* The connector cannot successfully connect to the MariaDB server by using the specified connection parameters.
* The connector is attempting to restart at a position in the binlog for which MariaDB no longer has the history available.
In these cases, the error message has details about the problem and possibly a suggested workaround. After you correct the configuration or address the MariaDB problem, restart the connector.
[id="mariadb-becomes-unavailable-while-debezium-is-running"]
=== MariaDB becomes unavailable
If your MariaDB server becomes unavailable, the {prodname} MariaDB connector fails with an error and the connector stops. When the server is available again, restart the connector.
However, if you are connecting to a highly available MariaDB cluster, you can restart the connector immediately.
It will connect to a different MariaDB server in the cluster, find the location in the server's binlog that represents the last transaction, and begin reading the new server's binlog from that specific location.
[id="debezium-mariadb-kafka-connect-process-stops-gracefully"]
=== Kafka Connect stops gracefully
When Kafka Connect stops gracefully, there is a short delay while the {prodname} MariaDB connector tasks are stopped and restarted on new Kafka Connect processes.
[id="debezium-mariadb-kafka-connect-process-crashes"]
=== Kafka Connect process crashes
If Kafka Connect crashes, the process stops and any {prodname} MariaDB connector tasks terminate without their most recently-processed offsets being recorded. In distributed mode, Kafka Connect restarts the connector tasks on other processes. However, the MariaDB connector resumes from the last offset recorded by the earlier processes. This means that the replacement tasks might generate some of the same events processed prior to the crash, creating duplicate events.
Each change event message includes source-specific information that you can use to identify duplicate events, for example:
* Event origin
* MariaDB server's event time
* The binlog file name and position
* GTIDs
[id="debezium-mariadb-kafka-process-becomes-unavailable"]
=== Kafka becomes unavailable
The Kafka Connect framework records {prodname} change events in Kafka by using the Kafka producer API. If the Kafka brokers become unavailable, the {prodname} MariaDB connector pauses until the connection is reestablished and the connector resumes where it left off.
[id="mariadb-purges-binlog-files-used-by-debezium"]
=== MariaDB purges binlog files
If the {prodname} MariaDB connector stops for too long, the MariaDB server purges older binlog files and the connector's last position may be lost. When the connector is restarted, the MariaDB server no longer has the starting point and the connector performs another initial snapshot. If the snapshot is disabled, the connector fails with an error.
See xref:mariadb-snapshots[snapshots] for details about how MariaDB connectors perform initial snapshots.
include::{partialsdir}/modules/all-connectors/shared-mariadb-mysql.adoc[leveloffset=+1,tags=wrong-things]

View File

@ -25,3 +25,8 @@ The connector also provides the following additional snapshot metrics when an in
|The upper bound of the primary key set of the currently snapshotted table.
|===
ifdef::MARIADB,MYSQL[]
The {prodname} MariaDB connector also provides the `HoldingGlobalLock` custom snapshot metric.
This metric is set to a Boolean value that indicates whether the connector currently holds a global or table write lock.
endif::MARIADB,MYSQL[]

View File

@ -14,7 +14,7 @@ The following table lists the streaming metrics that are available.
|[[connectors-strm-metric-totalnumberofeventsseen_{context}]]<<connectors-strm-metric-totalnumberofeventsseen_{context}, `TotalNumberOfEventsSeen`>>
|`long`
|The total number of data change events reported by the source database since the last connector start, or since a metrics reset.
|The total number of data change events reported by the source database since the last connector start, or since a metrics reset.
Represents the data change workload for {prodname} to process.
|[[connectors-strm-metric-totalnumberofcreateeventsseen_{context}]]<<connectors-strm-metric-totalnumberofcreateeventsseen_{context}, `TotalNumberOfCreateEventsSeen`>>
@ -75,3 +75,50 @@ The values will incorporate any differences between the clocks on the machines w
|The current volume, in bytes, of records in the queue.
|===
ifdef::MARIADB,MYSQL[]
The {prodname} {connector-name} connector also provides the following additional streaming metrics:
.Descriptions of additional {connector-name} streaming metrics
[cols="3,2,5",options="header"]
|===
|Attribute |Type |Description
|[[binlog-filename]]<<binlog-filename,`+BinlogFilename+`>>
|`string`
|The name of the binlog file that the connector has most recently read.
|[[binlog-position]]<<binlog-position,`+BinlogPosition+`>>
|`long`
|The most recent position (in bytes) within the binlog that the connector has read.
|[[is-gtid-mode-enabled]]<<is-gtid-mode-enabled,`+IsGtidModeEnabled+`>>
|`boolean`
|Flag that denotes whether the connector is currently tracking GTIDs from MariaDB server.
|[[gtid-set]]<<gtid-set,`+GtidSet+`>>
|`string`
|The string representation of the most recent GTID set processed by the connector when reading the binlog.
|[[number-of-skipped-events]]<<number-of-skipped-events,`+NumberOfSkippedEvents+`>>
|`long`
|The number of events that have been skipped by the MariaDB connector. Typically events are skipped due to a malformed or unparseable event from MariaDB's binlog.
|[[number-of-disconnects]]<<number-of-disconnects,`+NumberOfDisconnects+`>>
|`long`
|The number of disconnects by the MariaDB connector.
|[[number-of-rolled-back-transactions]]<<number-of-rolled-back-transactions,`+NumberOfRolledBackTransactions+`>>
|`long`
|The number of processed transactions that were rolled back and not streamed.
|[[number-of-not-well-formed-transactions]]<<number-of-not-well-formed-transactions,`+NumberOfNotWellFormedTransactions+`>>
|`long`
|The number of transactions that have not conformed to the expected protocol of `BEGIN` + `COMMIT`/`ROLLBACK`. This value should be `0` under normal conditions.
|[[number-of-large-transactions]]<<number-of-large-transactions,`+NumberOfLargeTransactions+`>>
|`long`
|The number of transactions that have not fit into the look-ahead buffer. For optimal performance, this value should be significantly smaller than `NumberOfCommittedTransactions` and `NumberOfRolledBackTransactions`.
|===
endif::MARIADB,MYSQL[]

View File

@ -0,0 +1,733 @@
The following list describes advanced {connector-name} connector configuration properties.
The default values for these properties rarely require changes.
Therefore, you do not need to specify them in the connector configuration.
ifdef::community[]
[id="{context}-property-binlog-buffer-size"]
xref:{context}-property-binlog-buffer-size[`binlog.buffer.size`]::
The size of a look-ahead buffer used by the binlog reader.
The default setting of `0` disables buffering. +
+
Under specific conditions, it is possible that the {connector-name} binlog contains uncommitted data finished by a `ROLLBACK` statement.
Typical examples are using savepoints or mixing temporary and regular table changes in a single transaction. +
+
When a beginning of a transaction is detected then {prodname} tries to roll forward the binlog position and find either `COMMIT` or `ROLLBACK` so it can determine whether to stream the changes from the transaction.
The size of the binlog buffer defines the maximum number of changes in the transaction that {prodname} can buffer while searching for transaction boundaries.
If the size of the transaction is larger than the buffer then {prodname} must rewind and re-read the events that have not fit into the buffer while streaming. +
[horizontal]
Default value::: `0`
NOTE: This feature is incubating. Feedback is encouraged. It is expected that this feature is not completely polished.
endif::community[]
[id="{context}-property-connect-keep-alive"]
xref:{context}-property-connect-keep-alive[`connect.keep.alive`]::
A Boolean value that specifies whether a separate thread should be used to ensure that the connection to the {connector-name} server or cluster is kept alive.
[horizontal]
Default value::: true
[id="{context}-property-converters"]
xref:{context}-property-converters[`converters`]::
Enumerates a comma-separated list of the symbolic names of the {link-prefix}:{link-custom-converters}#custom-converters[custom converter] instances that the connector can use. +
For example, `boolean`. +
This property is required to enable the connector to use a custom converter.
+
For each converter that you configure for a connector, you must also add a `.type` property, which specifies the fully-qualified name of the class that implements the converter interface.
The `.type` property uses the following format: +
+
`_<converterSymbolicName>_.type` +
+
For example, +
+
boolean.type: io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter
+
If you want to further control the behavior of a configured converter, you can add one or more configuration parameters to pass values to the converter.
To associate these additional configuration parameter with a converter, prefix the parameter name with the symbolic name of the converter. +
+
For example, to define a `selector` parameter that specifies the subset of columns that the `boolean` converter processes, add the following property: +
boolean.selector=db1.table1.*, db1.table2.column1
[horizontal]
Default value::: No default
[id="{context}-property-custom-metric-tags"]
xref:{context}-property-custom-metric-tags[`custom.metric.tags`]::
Defines tags that customize MBean object names by adding metadata that provides contextual information.
Specify a comma-separated list of key-value pairs.
Each key represents a tag for the MBean object name, and the corresponding value represents a value for the key, for example, +
`k1=v1,k2=v2` +
+
The connector appends the specified tags to the base MBean object name.
Tags can help you to organize and categorize metrics data.
You can define tags to identify particular application instances, environments, regions, versions, and so forth.
For more information, see xref:customized-mbean-names[Customized MBean names].
[horizontal]
Default value::: No default
[id="{context}-property-database-initial-statements"]
xref:{context}-property-database-initial-statements[`database.initial.statements`]::
A semicolon separated list of SQL statements to be executed when a JDBC connection, not the connection that is reading the transaction log, to the database is established.
To specify a semicolon as a character in a SQL statement and not as a delimiter, use two semicolons, (`;;`). +
+
The connector might establish JDBC connections at its own discretion, so this property is ony for configuring session parameters. It is not for executing DML statements.
[horizontal]
Default value::: No default
[id="{context}-property-database-query-timeout-ms"]
xref:{context}-property-database-query-timeout-ms[`database.query.timeout.ms`]::
Specifies the time, in milliseconds, that the connector waits for a query to complete.
Set the value to `0` (zero) to remove the timeout limit.
[horizontal]
Default value::: `600000` (10 minutes)
[id="{context}-property-database-ssl-keystore"]
xref:{context}-property-database-ssl-keystore[`database.ssl.keystore`]::
An optional setting that specifies the location of the key store file.
A key store file can be used for two-way authentication between the client and the {connector-name} server.
Default value::: No default
[id="{context}-property-database-ssl-keystore-password"]
xref:{context}-property-database-ssl-keystore-password[`database.ssl.keystore.password`]::
The password for the key store file.
Specify a password only if the xref:{context}-property-database-ssl-keystore[`database.ssl.keystore`] is configured.
Default value::: No default
[id="{context}-property-database-ssl-mode"]
xref:{context}-property-database-ssl-mode[`database.ssl.mode`]::
Specifies whether the connector uses an encrypted connection.
The following settings are available:
`disabled`::: Specifies the use of an unencrypted connection.
`preferred` (Default)::: The connector establishes an encrypted connection if the server supports secure connections.
If the server does not support secure connections, the connector falls back to using an unencrypted connection.
`required`::: The connector establishes an encrypted connection.
If it is unable to establish an encrypted connection, the connector fails.
`verify_ca`::: The connector behaves as when you set the `required` option, but it also verifies the server TLS certificate against the configured Certificate Authority (CA) certificates.
If the server TLS certificate does not match any valid CA certificates, the connector fails. +
`verify_identity`::: The connector behaves as when you set the `verify_ca` option, but it also verifies that the server certificate matches the host of the remote connection.
[id="{context}-property-database-ssl-truststore"]
xref:{context}-property-database-ssl-truststore[`database.ssl.truststore`]::
The location of the trust store file for the server certificate verification.
[horizontal]
Default value::: No default
[id="{context}-property-database-ssl-truststore-password"]
xref:{context}-property-database-ssl-truststore-password[`database.ssl.truststore.password`]::
The password for the trust store file.
Used to check the integrity of the truststore, and unlock the truststore.
[horizontal]
Default value::: No default
[id="{context}-property-enable-time-adjuster"]
xref:{context}-property-enable-time-adjuster[`enable.time.adjuster`]::
Boolean value that indicates whether the connector converts a 2-digit year specification to 4 digits.
Set the value to `false` when conversion is fully delegated to the database. +
+
{connector-name} users can insert year values with either 2-digits or 4-digits.
2-digit values are mapped to a year in the range 1970 - 2069.
By default, the connector performs the conversion.
[horizontal]
Default value::: `true`
[id="{context}-property-errors-max-retries"]
xref:{context}-property-errors-max-retries[`errors.max.retries`]::
Specifies how the connector responds after an operation that results in a retriable error, such as a connection error. +
Set one of the following options:
`-1`::: No limit.
The connector always restarts automatically, and retries the operation, regardless of the number of previous failures.
`0`::: Disabled.
The connector fails immediately, and never retries the operation.
User intervention is required to restart the connector.
`> 0`::: The connector restarts automatically until it reaches the specified maximum number of retries.
After the next failure, the connector stops, and user intervention is required to restart it.
[horizontal]
Default value::: `-1`
[id="{context}-property-event-converting-failure-handling-mode"]
xref:{context}-property-event-converting-failure-handling-mode[`event.converting.failure.handling.mode`]::
Specifies how the connector responds when it cannot convert a table record due to a mismatch between the data type of a column and the type specified by the {prodname} internal schema. +
Set one of the following options:
`fail`::: An exception reports that conversion failed because the data type of the field did not match the schema type, and indicates that it might be necessary to restart the connector in `schema _only_recovery` mode to enable a successful conversion.
`warn`::: The connector writes a `null` value to the event field for the column that failed conversion, writes a message to the warning log . +
`skip`::: The connector writes a `null` value to the event field for the column that failed conversion, and writes a message to the debug log.
[horizontal]
Default value::: `warn`
[id="{context}-property-event-processing-failure-handling-mode"]
xref:{context}-property-event-processing-failure-handling-mode[`event.processing.failure.handling.mode`]::
Specifies how the connector handles failures that occur when processing events, for example, if it encounters a corrupted event.
The following settings are available:
`fail`::: The connector raises an exception that reports the problematic event and its position.
The connector then stops.
`warn`::: The connector does not raise an exception.
Instead, it logs the problematic event and its position, and then skips the event.
`ignore`::: The connector ignores the problematic event, and does not generate a log entry.
[horizontal]
Default value::: `fail`
[id="{context}-property-heartbeat-action-query"]
xref:{context}-property-heartbeat-action-query[`heartbeat.action.query`]::
Specifies a query that the connector executes on the source database when the connector sends a heartbeat message. +
+
For example, the following query periodically captures the state of the executed GTID set in the source database. +
+
`INSERT INTO gtid_history_table (select @gtid_executed)`
[horizontal]
Default value::: No default
[id="{context}-property-heartbeat-interval-ms"]
xref:{context}-property-heartbeat-interval-ms[`heartbeat.interval.ms`]::
Specifies how frequently the connector sends heartbeat messages to a Kafka topic.
By default, the connector does not send heartbeat messages. +
+
Heartbeat messages are useful for monitoring whether the connector is receiving change events from the database. Heartbeat messages might help decrease the number of change events that need to be re-sent when a connector restarts. To send heartbeat messages, set this property to a positive integer, which indicates the number of milliseconds between heartbeat messages.
[horizontal]
Default value::: `0`
[id="{context}-property-incremental-snapshot-allow-schema-changes"]
xref:{context}-property-incremental-snapshot-allow-schema-changes[`incremental.snapshot.allow.schema.changes`]::
Specifies whether the connector allows schema changes during an incremental snapshot.
When the value is set to `true`, the connector detects schema change during an incremental snapshot, and re-select a current chunk to avoid locking DDLs. +
+
Changes to a primary key are not supported.
Changing the primary during an incremental snapshot, can lead to incorrect results.
A further limitation is that if a schema change affects only the default values of columns, then the change is not detected until the DDL is processed from the binlog stream.
This does not affect the values of snapshot events, but the schema of these snapshot events may have outdated defaults.
[horizontal]
Default value::: `false`
[id="{context}-property-incremental-snapshot-chunk-size"]
xref:{context}-property-incremental-snapshot-chunk-size[`incremental.snapshot.chunk.size`]::
The maximum number of rows that the connector fetches and reads into memory when it retrieves an incremental snapshot chunk.
Increasing the chunk size provides greater efficiency, because the snapshot runs fewer snapshot queries of a greater size.
However, larger chunk sizes also require more memory to buffer the snapshot data.
Adjust the chunk size to a value that provides the best performance in your environment.
[horizontal]
Default value::: `1024`
[id="{context}-property-incremental-snapshot-watermarking-strategy"]
xref:{context}-property-incremental-snapshot-watermarking-strategy[`incremental.snapshot.watermarking.strategy`]::
Specifies the watermarking mechanism that the connector uses during an incremental snapshot to deduplicate events that might be captured by an incremental snapshot and then recaptured after streaming resumes. +
You can specify one of the following options:
`insert_insert` (default)::: When you send a signal to initiate an incremental snapshot, for every chunk that {prodname} reads during the snapshot, it writes an entry to the signaling data collection to record the signal to open the snapshot window.
After the snapshot completes, {prodname} inserts a second entry that records the signal to close the window.
`insert_delete`::: When you send a signal to initiate an incremental snapshot, for every chunk that {prodname} reads, it writes a single entry to the signaling data collection to record the signal to open the snapshot window.
After the snapshot completes, this entry is removed.
No entry is created for the signal to close the snapshot window.
Set this option to prevent rapid growth of the signaling data collection.
[horizontal]
Default value::: `insert_insert`
[id="{context}-property-max-batch-size"]
xref:{context}-property-max-batch-size[`max.batch.size`]::
Positive integer value that specifies the maximum size of each batch of events that should be processed during each iteration of this connector.
[horizontal]
Default value::: `2048`
[id="{context}-property-max-queue-size"]
xref:{context}-property-max-queue-size[`max.queue.size`]::
A positive integer value that specifies the maximum number of records that the blocking queue can hold.
When {prodname} reads events streamed from the database, it places the events in the blocking queue before it writes them to Kafka.
The blocking queue can provide backpressure for reading change events from the database
in cases where the connector ingests messages faster than it can write them to Kafka, or when Kafka becomes unavailable.
Events that are held in the queue are disregarded when the connector periodically records offsets.
Always set `max.queue.size` to a value that is larger than the value of xref:{context}-property-max-batch-size[`max.batch.size`].
[horizontal]
Default value::: `8192`
[id="{context}-property-max-queue-size-in-bytes"]
xref:{context}-property-max-queue-size-in-bytes[`max.queue.size.in.bytes`]::
A long integer value that specifies the maximum volume of the blocking queue in bytes.
By default, volume limits are not specified for the blocking queue.
To specify the number of bytes that the queue can consume, set this property to a positive long value. +
If xref:{context}-property-max-queue-size[`max.queue.size`] is also set, writing to the queue is blocked when the size of the queue reaches the limit specified by either property.
For example, if you set `max.queue.size=1000`, and `max.queue.size.in.bytes=5000`, writing to the queue is blocked after the queue contains 1000 records, or after the volume of the records in the queue reaches 5000 bytes.
[horizontal]
Default value::: `0`
[id="{context}-property-min-row-count-to-stream-results"]
xref:{context}-property-min-row-count-to-stream-results[`min.row.count.to.stream.results`]::
During a snapshot, the connector queries each table for which the connector is configured to capture changes. The connector uses each query result to produce a read event that contains data for all rows in that table.
This property determines whether the {connector-name} connector puts results for a table into memory, which is fast but requires large amounts of memory, or streams the results, which can be slower but work for very large tables. The setting of this property specifies the minimum number of rows a table must contain before the connector streams results. +
+
To skip all table size checks and always stream all results during a snapshot, set this property to `0`.
[horizontal]
Default value::: `1000`
[id="{context}-property-notification-enabled-channels"]
xref:{context}-property-notification-enabled-channels[`notification.enabled.channels`]::
List of notification channel names that are enabled for the connector.
By default, the following channels are available:
* `sink`
* `log`
* `jmx`
ifdef::community[]
Optionally, you can also implement a {link-prefix}:{link-notification}#debezium-notification-custom-channel[custom notification channel].
endif::community[]
[horizontal]
Default value::: No default
[id="{context}-property-poll-interval-ms"]
xref:{context}-property-poll-interval-ms[`poll.interval.ms`]::
Positive integer value that specifies the number of milliseconds the connector waits for new change events to appear before it starts processing a batch of events.
[horizontal]
Default value::: `500` (0.5 seconds)
[id="{context}-property-provide-transaction-metadata"]
xref:{context}-property-provide-transaction-metadata[`provide.transaction.metadata`]::
Determines whether the connector generates events with transaction boundaries and enriches change event envelopes with transaction metadata. Specify `true` if you want the connector to do this.
For more information, see xref:{context}-transaction-metadata[Transaction metadata].
[horizontal]
Default value::: `false`
ifdef::community[]
[id="{context}-property-read-only"]
xref:{context}-property-read-only[`read.only`]::
Specifies whether a connector writes watermarks to the signal data collection to track the progress of an incremental snapshot.
Set the value to `true` to enable a connector that has a read-only connection to the database to use an incremental snapshot watermarking strategy that does not require writing to the signal data collection.
[horizontal]
Default value::: `false`
endif::community[]
[id="{context}-property-signal-data-collection"]
xref:{context}-property-signal-data-collection[`signal.data.collection`]::
Fully-qualified name of the data collection that is used to send {link-prefix}:{link-signalling}#debezium-signaling-enabling-source-signaling-channel[signals] to the connector. +
Use the following format to specify the collection name: +
`_<databaseName>_._<tableName>_`
[horizontal]
Default value::: No default
[id="{context}-property-signal-enabled-channels"]
xref:{context}-property-signal-enabled-channels[`signal.enabled.channels`]::
List of the signaling channel names that are enabled for the connector.
By default, the following channels are available:
* `source`
* `kafka`
* `file`
* `jmx`
ifdef::community[]
Optionally, you can also implement a {link-prefix}:{link-signalling}#debezium-signaling-enabling-custom-signaling-channel[custom signaling channel].
endif::community[]
[horizontal]
Default value::: No default
[id="{context}-property-skipped-operations"]
xref:{context}-property-skipped-operations[`skipped.operations`]::
A comma-separated list of operation types that will be skipped during streaming.
The operations include: `c` for inserts/create, `u` for updates, `d` for deletes, `t` for truncates, and `none` to not skip any operations.
By default, truncate operations are skipped.
[horizontal]
Default value::: `t`
[id="{context}-property-snapshot-delay-ms"]
xref:{context}-property-snapshot-delay-ms[`snapshot.delay.ms`]::
An interval in milliseconds that the connector should wait before performing a snapshot when the connector starts. If you are starting multiple connectors in a cluster, this property is useful for avoiding snapshot interruptions, which might cause re-balancing of connectors.
[horizontal]
Default value::: No default
[id="{context}-property-snapshot-fetch-size"]
xref:{context}-property-snapshot-fetch-size[`snapshot.fetch.size`]::
During a snapshot, the connector reads table content in batches of rows.
This property specifies the maximum number of rows in a batch.
[horizontal]
Default value::: No default
[id="{context}-property-snapshot-include-collection-list"]
xref:{context}-property-snapshot-include-collection-list[`snapshot.include.collection.list`]::
An optional, comma-separated list of regular expressions that match the fully-qualified names (`_<databaseName>.<tableName>_`) of the tables to include in a snapshot.
The specified items must be named in the connector's xref:{context}-property-table-include-list[`table.include.list`] property.
This property takes effect only if the connector's xref:{context}-property-snapshot-mode[`snapshot.mode`] property is set to a value other than `never`. +
This property does not affect the behavior of incremental snapshots. +
+
To match the name of a table, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the table; it does not match substrings that might be present in a table name.
[horizontal]
Default value::: All tables specified in the `table.include.list`.
[id="{context}-property-snapshot-lock-timeout-ms"]
xref:{context}-property-snapshot-lock-timeout-ms[`snapshot.lock.timeout.ms`]::
Positive integer that specifies the maximum amount of time (in milliseconds) to wait to obtain table locks when performing a snapshot. If the connector cannot acquire table locks in this time interval, the snapshot fails.
For more information, see
ifdef::MYSQL[]
xref:mysql-snapshots[how {connector-name} connectors perform database snapshots].
endif::MYSQL[]
ifdef::MARIADB[]
xref:mariadb-snapshots[how {connector-name} connectors perform database snapshots].
endif::MARIADB[]
[horizontal]
Default value::: `10000`
[id="{context}-property-snapshot-locking-mode"]
xref:{context}-property-snapshot-locking-mode[`snapshot.locking.mode`]::
Specifies whether and for how long the connector holds the global {connector-name} read lock, which prevents any updates to the database while the connector is performing a snapshot.
The following settings are available:
`minimal`::: The connector holds the global read lock for only the initial phase of the snapshot during which it reads the database schemas and other metadata.
During the next phase of the snapshot, the connector releases the lock as it selects all rows from each table.
To perform the SELECT operation in a consistent fashion, the connector uses a REPEATABLE READ transaction.
Although the release of the global read lock permits other {connector-name} clients to update the database, use of REPEATABLE READ isolation ensures a consistent snapshot, because the connector continues to read the same data for the duration of the transaction. +
`extended`::: Blocks all write operations for the duration of the snapshot.
Use this setting if clients submit concurrent operations that are incompatible with the REPEATABLE READ isolation level in {connector-name}. +
`none`::: Prevents the connector from acquiring any table locks during the snapshot.
Although this option is allowed with all snapshot modes, it is safe to use _only_ if no schema changes occur while the snapshot is running.
Tables that are defined with the MyISAM engine always acquire a table lock.
As a result, such tables are locked even if you set this option.
This behavior differs from tables that are defined by the InnoDB engine, which acquire row-level locks.
ifdef::community[]
`custom`::: The connector performs a snapshot according to the implementation specified by the xref:{context}-property-snapshot-locking-mode-custom-name[`snapshot.locking.mode.custom.name`] property, which is a custom implementation of the `io.debezium.spi.snapshot.SnapshotLock` interface.
endif::community[]
[horizontal]
Default value::: `minimal`
ifdef::community[]
[id="{context}-property-snapshot-locking-mode-custom-name"]
xref:{context}-property-snapshot-locking-mode-custom-name[`snapshot.locking.mode.custom.name`]::
When xref:{context}-property-snapshot-locking-mode[`snapshot.locking.mode`] is set to `custom`, use this setting to specify the name of the custom implementation provided in the `name()` method that is defined by the 'io.debezium.spi.snapshot.SnapshotLock' interface.
For more information, see xref:connector-custom-snapshot[custom snapshotter SPI].
Default value::: No default
endif::community[]
[id="{context}-property-snapshot-max-threads"]
xref:{context}-property-snapshot-max-threads[`snapshot.max.threads`]::
Specifies the number of threads that the connector uses when performing an initial snapshot.
To enable parallel initial snapshots, set the property to a value greater than 1.
In a parallel initial snapshot, the connector processes multiple tables concurrently.
ifdef::community[]
Parallel initial snapshots is an incubating feature.
endif::community[]
ifdef::product[]
[IMPORTANT]
====
Parallel initial snapshots is a Developer Preview feature only.
Developer Preview software is not supported by Red{nbsp}Hat in any way and is not functionally complete or production-ready.
Do not use Developer Preview software for production or business-critical workloads.
Developer Preview software provides early access to upcoming product software in advance of its possible inclusion in a Red{nbsp}Hat product offering.
Customers can use this software to test functionality and provide feedback during the development process.
This software is subject to change or removal at any time, and has received limited testing.
Red{nbsp}Hat might provide ways to submit feedback on Developer Preview software without an associated SLA.
For more information about the support scope of Red{nbsp}Hat Developer Preview software, see link:https://access.redhat.com/support/offerings/devpreview/[Developer Preview Support Scope].
====
endif::product[]
[horizontal]
Default value::: `1`
[id="{context}-property-snapshot-mode"]
xref:{context}-property-snapshot-mode[`snapshot.mode`]::
Specifies the criteria for running a snapshot when the connector starts.
The following settings are available:
`always`::: The connector performs a snapshot every time that it starts.
The snapshot includes the structure and data of the captured tables.
Specify this value to populate topics with a complete representation of the data from the captured tables every time that the connector starts.
`initial` (default)::: The connector runs a snapshot only when no offsets have been recorded for the logical server name, or if it detects that an earlier snapshot failed to complete.
After the snapshot completes, the connector begins to stream event records for subsequent database changes.
`initial_only`::: The connector runs a snapshot only when no offsets have been recorded for the logical server name.
After the snapshot completes, the connector stops.
It does not transition to streaming to read change events from the binlog.
`schema_only`::: Deprecated, see `no_data`.
`no_data`::: The connector runs a snapshot that captures only the schema, but not any table data.
Set this option if you do not need the topics to contain a consistent snapshot of the data, but you want to capture any schema changes that were applied after the last connector restart.
`schema_only_recovery`::: Deprecated, see `recovery`.
`recovery`::: Set this option to restore a database schema history topic that is lost or corrupted.
After a restart, the connector runs a snapshot that rebuilds the topic from the source tables.
You can also set the property to periodically prune a database schema history topic that experiences unexpected growth. +
+
[WARNING]
====
Do not use this mode to perform a snapshot if schema changes were committed to the database after the last connector shutdown.
====
`never`::: When the connector starts, rather than performing a snapshot, it immediately begins to stream event records for subsequent database changes.
This option is under consideration for future deprecation, in favor of the `no_data` option.
`when_needed`::: After the connector starts, it performs a snapshot only if it detects one of the following circumstances:
* It cannot detect any topic offsets.
* A previously recorded offset specifies a binlog position or GTID that is not available on the server.
ifdef::community[]
`configuration_based`::: With this option, you control snapshot behavior through a set of connector properties that have the prefix 'snapshot.mode.configuration.based'.
endif::community[]
ifdef::community[]
`custom`::: The connector performs a snapshot according to the implementation specified by the xref:{context}-property-snapshot-mode-custom-name[`snapshot.mode.custom.name`] property, which defines a custom implementation of the `io.debezium.spi.snapshot.Snapshotter` interface.
endif::community[]
[horizontal]
Default value::: `initial`
ifdef::community[]
[id="{context}-property-snapshot-mode-configuration-based-snapshot-data"]
xref:{context}-property-snapshot-mode-configuration-based-snapshot-data[`snapshot.mode.configuration.based.snapshot.data`]::
If the `snapshot.mode` is set to `configuration_based`, set this property to specify whether the connector includes table data when it performs a snapshot.
[horizontal]
Default value::: `false`
endif::community[]
ifdef::community[]
[id="{context}-property-snapshot-mode-configuration-based-snapshot-on-data-error"]
xref:{context}-property-snapshot-mode-configuration-based-snapshot-on-data-error[`snapshot.mode.configuration.based.snapshot.on.data.error`]::
If the `snapshot.mode` is set to `configuration_based`, set this property to specify whether the connector includes table data in a snapshot in the event that data is no longer available in the transaction log.
[horizontal]
Default value::: `false`
endif::community[]
ifdef::community[]
[id="{context}-property-snapshot-mode-configuration-based-snapshot-on-schema-error"]
xref:{context}-property-snapshot-mode-configuration-based-snapshot-on-schema-error[`snapshot.mode.configuration.based.snapshot.on.schema.error`]::
If the `snapshot.mode` is set to `configuration_based`, set this property to specify whether the connector includes table schema in a snapshot if the schema history topic is not available.
[horizontal]
Default value::: `false`
endif::community[]
ifdef::community[]
[id="{context}-property-snapshot-mode-configuration-based-snapshot-schema"]
xref:{context}-property-snapshot-mode-configuration-based-snapshot-schema[`snapshot.mode.configuration.based.snapshot.schema`]::
If the `snapshot.mode` is set to `configuration_based`, set this property to specify whether the connector includes the table schema when it performs a snapshot.
[horizontal]
Default value::: `false`
endif::community[]
ifdef::community[]
[id="{context}-property-snapshot-mode-configuration-based-start-stream"]
xref:{context}-property-snapshot-mode-configuration-based-start-stream[`snapshot.mode.configuration.based.start.stream`]::
If the `snapshot.mode` is set to `configuration_based`, set this property to specify whether the connector begins to stream change events after a snapshot completes.
[horizontal]
Default value::: `false`
endif::community[]
ifdef::community[]
[id="{context}-property-snapshot-mode-custom-name"]
xref:{context}-property-snapshot-mode-custom-name[`snapshot.mode.custom.name`]::
If `snapshot.mode` is set to `custom`, use this setting to specify the name of the custom implementation that is provided in the `name()` method that is defined in the 'io.debezium.spi.snapshot.Snapshotter' interface.
After a connector restart, {prodname} calls the specified custom implementation to determine whether to perform a snapshot.
For more information, see xref:connector-custom-snapshot[custom snapshotter SPI].
[horizontal]
Default value::: No default
endif::community[]
[id="{context}-property-snapshot-query-mode"]
xref:{context}-property-snapshot-query-mode[`snapshot.query.mode`]::
Specifies how the connector queries data while performing a snapshot. +
Set one of the following options:
`select_all` (default)::: The connector uses a `select all` query to retrieve rows from captured tables, optionally adjusting the columns selected based on the column `include` and `exclude` list configurations.
ifdef::community[]
`custom`::: The connector performs a snapshot query according to the implementation specified by the xref:{context}-property-snapshot-snapshot-query-mode-custom-name[`snapshot.query.mode.custom.name`] property, which defines a custom implementation of the `io.debezium.spi.snapshot.SnapshotQuery` interface. +
endif::community[]
+
This setting enables you to manage snapshot content in a more flexible manner compared to using the xref:{context}-property-snapshot-select-statement-overrides[`snapshot.select.statement.overrides`] property.
[horizontal]
Default value::: `select_all`
ifdef::community[]
[id="{context}-property-snapshot-snapshot-query-mode-custom-name"]
xref:{context}-property-snapshot-snapshot-query-mode-custom-name[`snapshot.query.mode.custom.name`]::
When xref:{context}-property-snapshot-query-mode[`snapshot.query.mode`] is set as `custom`, use this setting to specify the name of the custom implementation provided in the `name()` method that is defined by the 'io.debezium.spi.snapshot.SnapshotQuery' interface.
For more information, see xref:connector-custom-snapshot[custom snapshotter SPI].
[horizontal]
Default value::: No default
endif::community[]
[id="{context}-property-snapshot-select-statement-overrides"]
xref:{context}-property-snapshot-select-statement-overrides[`snapshot.select.statement.overrides`]::
Specifies the table rows to include in a snapshot.
Use the property if you want a snapshot to include only a subset of the rows in a table.
This property affects snapshots only.
It does not apply to events that the connector reads from the log.
+
The property contains a comma-separated list of fully-qualified table names in the form `_<databaseName>.<tableName>_`. For example, +
+
`+"snapshot.select.statement.overrides": "inventory.products,customers.orders"+` +
+
For each table in the list, add a further configuration property that specifies the `SELECT` statement for the connector to run on the table when it takes a snapshot.
The specified `SELECT` statement determines the subset of table rows to include in the snapshot.
Use the following format to specify the name of this `SELECT` statement property: +
+
`snapshot.select.statement.overrides._<databaseName>_._<tableName>_`
For example,
`snapshot.select.statement.overrides.customers.orders` +
+
From a `customers.orders` table that includes the soft-delete column, `delete_flag`, add the following properties if you want a snapshot to include only those records that are not soft-deleted:
+
----
"snapshot.select.statement.overrides": "customer.orders",
"snapshot.select.statement.overrides.customer.orders": "SELECT * FROM [customers].[orders] WHERE delete_flag = 0 ORDER BY id DESC"
----
+
In the resulting snapshot, the connector includes only the records for which `delete_flag = 0`.
[horizontal]
Default value::: No default
[id="{context}-property-snapshot-tables-order-by-row-count"]
xref:{context}-property-snapshot-tables-order-by-row-count[`snapshot.tables.order.by.row.count`]::
Specifies the order in which the connector processes tables when it performs an initial snapshot.
Set one of the following options:
`descending`::: The connector snapshots tables in order, based on the number of rows from the highest to the lowest.
`ascending`::: The connector snapshots tables in order, based on the number of rows, from lowest to highest.
`disabled`::: The connector disregards row count when performing an initial snapshot.
[horizontal]
Default value::: `disabled`
ifdef::community[]
[id="{context}-property-source-struct-version"]
xref:{context}-property-source-struct-version[`source.struct.version`]::
Schema version for the `source` block in {prodname} events. {prodname} 0.10 introduced a few breaking changes to the structure of the `source` block in order to unify the exposed structure across all the connectors. +
+
By setting this option to `v1`, the structure used in earlier versions can be produced. However, this setting is not recommended and is planned for removal in a future {prodname} version.
endif::community[]
[horizontal]
Default value::: `v2`
[id="{context}-property-streaming-delay-ms"]
xref:"{context}-property-streaming-delay-ms[`streaming.delay.ms`]::
Specifies the time, in milliseconds, that the connector delays the start of the streaming process after it completes a snapshot.
Setting a delay interval helps to prevent the connector from restarting snapshots in the event that a failure occurs immediately after the snapshot completes, but before the streaming process begins.
Set a delay value that is higher than the value of the {link-kafka-docs}/#connectconfigs_offset.flush.interval.ms[`offset.flush.interval.ms`] property that is set for the Kafka Connect worker.
[horizontal]
Default value::: `0`
[id="{context}-property-table-ignore-builtin"]
xref:{context}-property-table-ignore-builtin[`table.ignore.builtin`]::
A Boolean value that specifies whether built-in system tables should be ignored.
This applies regardless of the table include and exclude lists.
By default, changes that occur to the values in system tables are excluded from capture, and {prodname} does not generate events for system table changes.
[horizontal]
Default value::: `true`
[id="{context}-property-topic-cache-size"]
xref:{context}-property-topic-cache-size[`topic.cache.size`]::
Specifies the number of topic names that can be stored in memory in a bounded concurrent hash map.
The connector uses the cache to help determine the topic name that corresponds to a data collection.
[horizontal]
Default value::: `10000`
[id="{context}-property-topic-delimiter"]
xref:{context}-property-topic-delimiter[`topic.delimiter`]::
Specifies the delimiter that the connector inserts between components of the topic name.
[horizontal]
Default value::: `.`
[id="{context}-property-topic-heartbeat-prefix"]
xref:{context}-property-topic-heartbeat-prefix[`topic.heartbeat.prefix`]::
Specifies the name of the topic to which the connector sends heartbeat messages.
The topic name takes the following format: +
+
_topic.heartbeat.prefix_._topic.prefix_ +
+
For example, if the topic prefix is `fulfillment`, the default topic name is `__debezium-heartbeat.fulfillment`.
[horizontal]
Default value::: `__debezium-heartbeat`
[id="{context}-property-topic-naming-strategy"]
xref:{context}-property-topic-naming-strategy[`topic.naming.strategy`]::
The name of the `TopicNamingStrategy` class that the connector uses.
The specified strategy determines how the connector names the topics that store event records for data changes, schema changes, transactions, heartbeats, and so forth.
[horizontal]
Default value::: `io.debezium.schema.DefaultTopicNamingStrategy`
[id="{context}-property-topic-transaction"]
xref:{context}-property-topic-transaction[`topic.transaction`]::
Specifies the name of the topic to which the connector sends transaction metadata messages.
The topic name takes the following pattern: +
+
_topic.prefix_._topic.transaction_ +
+
For example, if the topic prefix is `fulfillment`, the default topic name is `fulfillment.transaction`.
[horizontal]
Default value::: `transaction`
[id="{context}-property-use-nongraceful-disconnect"]
xref:{context}-property-use-nongraceful-disconnect[`use.nongraceful.disconnect`]::
A Boolean value that specifies whether the binary log client's keepalive thread sets the `SO_LINGER` socket option to `0` to immediately close stale TCP connections. +
Set the value to `true` if the connector experiences deadlocks in `SSLSocketImpl.close`. +
ifdef::community[]
For more information, see https://github.com/osheroff/mysql-binlog-connector-java/issues/133[Issue 133] in the https://github.com/osheroff/mysql-binlog-connector-java[mysql-binlog-connector-java] GitHub repository.
endif::community[]
[horizontal]
Default value::: false

View File

@ -0,0 +1,581 @@
The following configuration properties are _required_ unless a default value is available.
[id="{context}-property-bigint-unsigned-handling-mode"]
xref:{context}-property-bigint-unsigned-handling-mode[`bigint.unsigned.handling.mode`]::
Specifies how BIGINT UNSIGNED columns should be represented in change events.
Set one of the following options:
`long`::: Uses Java `long` data types to represent BIGINT UNSIGNED column values.
Although the `long` type does not offer the greatest precision, it is easy implement in most consumers.
In most environments, this is the preferred setting.
`precise`::: Uses `java.math.BigDecimal` data types to represent values.
The connector uses the Kafka Connect `org.apache.kafka.connect.data.Decimal` data type to represent values in encoded binary format.
Set this option if the connector typically works with values larger than 2^63.
The `long` data type cannot convey values of that size.
[horizontal]
Default value::: `long`
[id="{context}-property-binary-handling-mode"]
xref:{context}-property-binary-handling-mode[`binary.handling.mode`]::
Specifies how the connector represents values for binary columns, such as, `blob`, `binary`, `varbinary`, in change events.
Set one of the following options:
`bytes`::: Represents binary data as a byte array.
`base64`::: Represents binary data as a base64-encoded String.
`base64-url-safe`::: Represents binary data as a base64-url-safe-encoded String.
`hex`::: Represents binary data as a hex-encoded (base16) String.
[horizontal]
Default value::: `bytes`
[id="{context}-property-column-exclude-list"]
xref:{context}-property-column-exclude-list[`column.exclude.list`]::
An optional, comma-separated list of regular expressions that match the fully-qualified names of columns to exclude from change event record values.
Other columns in the source record are captured as usual.
Fully-qualified names for columns are of the form _databaseName_._tableName_._columnName_. +
+
To match the name of a column, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the column; it does not match substrings that might be present in a column name.
If you include this property in the configuration, do not also set the `column.include.list` property.
[horizontal]
Default value::: _empty string_
[id="{context}-property-column-include-list"]
xref:{context}-property-column-include-list[`column.include.list`]::
An optional, comma-separated list of regular expressions that match the fully-qualified names of columns to include in change event record values.
Other columns are omitted from the event record.
Fully-qualified names for columns are of the form _databaseName_._tableName_._columnName_. +
+
To match the name of a column, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the column; it does not match substrings that might be present in a column name. +
If you include this property in the configuration, do not set the `column.exclude.list` property.
[horizontal]
Default value::: _empty string_
[id="{context}-property-column-mask-hash"]
xref:{context}-property-column-mask-hash[`column.mask.hash._hashAlgorithm_.with.salt._salt`_]::
[id="{context}-property-column-mask-hash-v2"]
xref:{context}-property-column-mask-hash-v2[`column.mask.hash.v2._hashAlgorithm_.with.salt._salt_`]::
An optional, comma-separated list of regular expressions that match the fully-qualified names of character-based columns.
Fully-qualified names for columns are of the form `_<databaseName>_._<tableName>_._<columnName>_`. +
To match the name of a column {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the column; the expression does not match substrings that might be present in a column name.
In the resulting change event record, the values for the specified columns are replaced with pseudonyms.
+
A pseudonym consists of the hashed value that results from applying the specified _hashAlgorithm_ and _salt_.
Based on the hash function that is used, referential integrity is maintained, while column values are replaced with pseudonyms.
Supported hash functions are described in the {link-java7-standard-names}[MessageDigest section] of the Java Cryptography Architecture Standard Algorithm Name Documentation. +
+
In the following example, `CzQMA0cB5K` is a randomly selected salt.
+
----
column.mask.hash.SHA-256.with.salt.CzQMA0cB5K = inventory.orders.customerName, inventory.shipment.customerName
----
+
If necessary, the pseudonym is automatically shortened to the length of the column.
The connector configuration can include multiple properties that specify different hash algorithms and salts. +
+
Depending on the _hashAlgorithm_ used, the _salt_ selected, and the actual data set, the resulting data set might not be completely masked. +
+
Hashing strategy version 2 ensures fidelity of values that are hashed in different places or systems.
[horizontal]
Default value::: No default
[id="{context}-property-column-mask-with-length-chars"]
xref:{context}-property-column-mask-with-length-chars[`column.mask.with._length_.chars`]::
An optional, comma-separated list of regular expressions that match the fully-qualified names of character-based columns.
Set this property if you want the connector to mask the values for a set of columns, for example, if they contain sensitive data.
Set `_length_` to a positive integer to replace data in the specified columns with the number of asterisk (`*`) characters specified by the _length_ in the property name.
Set _length_ to `0` (zero) to replace data in the specified columns with an empty string.
+
The fully-qualified name of a column observes the following format: _databaseName_._tableName_._columnName_.
To match the name of a column, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the column; the expression does not match substrings that might be present in a column name.
+
You can specify multiple properties with different lengths in a single configuration.
[horizontal]
Default value::: No default
[id="{context}-property-column-propagate-source-type"]
xref:{context}-property-column-propagate-source-type[`column.propagate.source.type`]::
An optional, comma-separated list of regular expressions that match the fully-qualified names of columns for which you want the connector to emit extra parameters that represent column metadata.
When this property is set, the connector adds the following fields to the schema of event records:
* `pass:[_]pass:[_]debezium.source.column.type`
* `pass:[_]pass:[_]debezium.source.column.length`
* `pass:[_]pass:[_]debezium.source.column.scale` +
These parameters propagate a column's original type name and length (for variable-width types), respectively. +
Enabling the connector to emit this extra data can assist in properly sizing specific numeric or character-based columns in sink databases. +
+
The fully-qualified name of a column observes one of the following formats: _databaseName_._tableName_._columnName_, or _databaseName_._schemaName_._tableName_._columnName_. +
To match the name of a column, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the column; the expression does not match substrings that might be present in a column name.
[horizontal]
Default value::: No default
[id="{context}-property-column-truncate-to-length-chars"]
xref:{context}-property-column-truncate-to-length-chars[`column.truncate.to._length_.chars`]::
An optional, comma-separated list of regular expressions that match the fully-qualified names of character-based columns.
Set this property if you want to truncate the data in a set of columns when it exceeds the number of characters specified by the _length_ in the property name.
Set `length` to a positive integer value, for example, `column.truncate.to.20.chars`.
+
The fully-qualified name of a column observes the following format: _databaseName_._tableName_._columnName_.
To match the name of a column, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the column; the expression does not match substrings that might be present in a column name.
+
You can specify multiple properties with different lengths in a single configuration.
[horizontal]
Default value::: No default
[id="{context}-property-connect-timeout-ms"]
xref:{context}-property-connect-timeout-ms[`connect.timeout.ms`]::
A positive integer value that specifies the maximum time in milliseconds that the connector waits to establish a connection to the {connector-name} database server before the connection request times out.
[horizontal]
Default value::: `30000` (30 seconds)
[id="{context}-property-connector-class"]
xref:{context}-property-connector-class[`connector.class`]::
The name of the Java class for the connector.
Always specify
ifdef::MARIADB[]
`io.debezium.connector.mariadb.MariaDbConnector`
endif::MARIADB[]
ifdef::MYSQL[]
`io.debezium.connector.mysql.MySqlConnector`
endif::MYSQL[]
for the {connector-name} connector.
[horizontal]
Default value::: No default
[id="{context}-property-database-exclude-list"]
xref:{context}-property-database-exclude-list[`database.exclude.list`]::
An optional, comma-separated list of regular expressions that match the names of databases from which you do not want the connector to capture changes.
The connector captures changes in any database that is not named in the `database.exclude.list`. +
+
To match the name of a database, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the database; it does not match substrings that might be present in a database name. +
If you include this property in the configuration, do not also set the `database.include.list` property.
[horizontal]
Default value::: _empty string_
[id="{context}-property-database-hostname"]
xref:{context}-property-database-hostname[`database.hostname`]::
The IP address or hostname of the {connector-name} database server.
[horizontal]
Default value::: No default
[id="{context}-property-database-include-list"]
xref:{context}-property-database-include-list[`database.include.list`]::
An optional, comma-separated list of regular expressions that match the names of the databases from which the connector captures changes.
The connector does not capture changes in any database whose name is not in `database.include.list`.
By default, the connector captures changes in all databases. +
+
To match the name of a database, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the database; it does not match substrings that might be present in a database name. +
If you include this property in the configuration, do not also set the `database.exclude.list` property.
[horizontal]
Default value::: _empty string_
ifdef::MYSQL[]
[id="{context}-property-database-jdbc-driver"]
xref:{context}-property-database-jdbc-driver[`database.jdbc.driver`]::
Specifies the name of the driver class that the connector uses.
You can use this setting to specify a driver other than the one that is packaged with the connector.
[horizontal]
Default value::: `com.mysql.cj.jdbc.Driver`
endif::MYSQL[]
[id="{context}-property-database-password"]
xref:{context}-property-database-password[`database.password`]::
The password of the {connector-name} user that the connector uses to connect to the {connector-name} database server.
[horizontal]
Default value::: No default
[id="{context}-property-database-port"]
xref:{context}-property-database-port[`database.port`]::
Integer port number of the {connector-name} database server.
[horizontal]
Default value::: `3306`
ifdef::MYSQL[]
[id="{context}-property-database-protocol"]
xref:{context}-property-database-protocol[`database.protocol`]::
Specifies the JDBC protocol that the driver connection string uses to connect to the database.
[horizontal]
Default value::: `jdbc:mysql`
endif::MYSQL[]
[id="{context}-property-database-server-id"]
xref:{context}-property-database-server-id[`database.server.id`]::
The numeric ID of this database client.
The specified ID must be unique across all currently running database processes in the {connector-name} cluster.
To enable it to read the binlog, the connector uses this unique ID to join the {connector-name} database cluster as another server.
[horizontal]
Default value::: No default
[id="{context}-property-database-user"]
xref:{context}-property-database-user[`database.user`]::
The name of the {connector-name} user that the connector uses to connect to the {connector-name} database server.
[horizontal]
Default value::: No default
[id="{context}-property-decimal-handling-mode"]
xref:{context}-property-decimal-handling-mode[`decimal.handling.mode`]::
Specifies how the connector handles values for `DECIMAL` and `NUMERIC` columns in change events. +
Set one of the following options:
`precise` (default)::: Uses `java.math.BigDecimal` values in binary form to represent values precisely.
`double`::: Uses the `double` data type to represent values.
This option can result in a loss of precision, but it is easier for most consumers to use.
`string`::: Encodes values as formatted strings.
This option is easy to consume, but can result in the loss of semantic information about the real type.
[horizontal]
Default value::: `precise`
[id="{context}-property-event-deserialization-failure-handling-mode"]
xref:{context}-property-event-deserialization-failure-handling-mode[`event.deserialization.failure.handling.mode`]::
Specifies how the connector reacts after an exception occurs during deserialization of binlog events.
This option is deprecated, please use xref:{context}-property-event-processing-failure-handling-mode[`event.processing.failure.handling.mode`] option instead.
`fail`::: Propagates the exception, which indicates the problematic event and its binlog offset, and causes the connector to stop.
`warn`::: Logs the problematic event and its binlog offset and then skips the event.
`ignore`::: Passes over the problematic event and does not log anything.
[horizontal]
Default value::: `fail`
[id="{context}-property-field-name-adjustment-mode"]
xref:{context}-property-field-name-adjustment-mode[`field.name.adjustment.mode`]::
Specifies how field names should be adjusted for compatibility with the message converter used by the connector.
Set one of the following options:
`none`::: No adjustment.
`avro`::: Replaces characters that are not valid in Avro names with underscore characters.
`avro_unicode`::: Replaces underscore characters or characters that cannot be used in Avro names with corresponding unicode, such as `$$_$$uxxxx`. +
+
[NOTE]
====
`_` is an escape sequence, similar to a backslash in Java
====
+
For more information, see: {link-prefix}:{link-avro-serialization}#avro-naming[Avro naming].
[horizontal]
Default value::: No default
[id="{context}-property-gtid-source-excludes"]
xref:{context}-property-gtid-source-excludes[`gtid.source.excludes`]::
A comma-separated list of regular expressions that match source domain IDs in the GTID set that the connector uses to find the binlog position on the {connector-name} server.
When this property is set, the connector uses only the GTID ranges that have source UUIDs that do not match any of the specified `exclude` patterns. +
+
To match the value of a GTID, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the GTID's domain identifier. +
If you include this property in the configuration, do not also set the `gtid.source.includes` property.
[horizontal]
Default value::: No default
[id="{context}-property-gtid-source-includes"]
xref:{context}-property-gtid-source-includes[`gtid.source.includes`]::
A comma-separated list of regular expressions that match source domain IDs in the GTID set used that the connector uses to find the binlog position on the {connector-name} server.
When this property is set, the connector uses only the GTID ranges that have source UUIDs that match one of the specified `include` patterns. +
+
To match the value of a GTID, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the GTID's domain identifier. +
If you include this property in the configuration, do not also set the `gtid.source.excludes` property.
[horizontal]
Default value::: No default
[id="{context}-property-include-query"]
xref:{context}-property-include-query[`include.query`]::
Boolean value that specifies whether the connector should include the original SQL query that generated the change event. +
+
If you set this option to `true` then you must also configure {connector-name} with the `binlog_annotate_row_events` option set to `ON`.
When `include.query` is `true`, the query is not present for events that the snapshot process generates. +
+
Setting `include.query` to `true` might expose tables or fields that are explicitly excluded or masked by including the original SQL statement in the change event.
For this reason, the default setting is `false`. +
+
For more information about configuring the database to return the original `SQL` statement for each log event, see xref:enable-query-log-events[Enabling query log events].
[horizontal]
Default value::: `false`
[id="{context}-property-include-schema-changes"]
xref:{context}-property-include-schema-changes[`include.schema.changes`]::
Boolean value that specifies whether the connector publishes changes that occur to the database schema to a Kafka topic with the name of the database server ID.
Each schema change event that the connector captures uses a key that contains the database name and a value that includes the DDL statements that describe the change.
This setting does not affect how the connector records schema changes in its internal database schema history.
[horizontal]
Default value::: `true`
[id="{context}-property-include-schema-comments"]
xref:{context}-property-include-schema-comments[`include.schema.comments`]::
Boolean value that specifies whether the connector parses and publishes table and column comments on metadata objects.
NOTE: When you set this option to `true`, the schema comments that the connector includes can add a significant amount of string data to each schema object.
Increasing the number and size of logical schema objects increases the amount of memory that the connector uses.
[horizontal]
Default value::: `false`
[id="{context}-property-inconsistent-schema-handling-mode"]
xref:{context}-property-inconsistent-schema-handling-mode[`inconsistent.schema.handling.mode`]::
Specifies how the connector responds to binlog events that refer to tables that are not present in the internal schema representation.
That is, the internal representation is not consistent with the database. +
Set one of the following options:
`fail`::: The connector throws an exception that reports the problematic event and its binlog offset.
The connector then stops.
`warn`::: The connector logs the problematic event and its binlog offset, and then skips the event.
`skip`::: The connector skips the problematic event and does not report it in the log.
[horizontal]
Default value::: `fail`
[id="{context}-property-message-key-columns"]
xref:{context}-property-message-key-columns[`message.key.columns`]::
A list of expressions that specify the columns that the connector uses to form custom message keys for change event records that it publishes to the Kafka topics for specified tables. +
By default, {prodname} uses the primary key column of a table as the message key for records that it emits.
In place of the default, or to specify a key for tables that lack a primary key, you can configure custom message keys based on one or more columns.
+
To establish a custom message key for a table, list the table, followed by the columns to use as the message key.
Each list entry takes the following format: +
+
`_<fully-qualified_tableName>_:__<keyColumn>__,_<keyColumn>_` +
+
To base a table key on multiple column names, insert commas between the column names.
+
Each fully-qualified table name is a regular expression in the following format:
+
`_<databaseName>_._<tableName>_` +
+
The property can include entries for multiple tables.
Use a semicolon to separate table entries in the list. +
+
The following example sets the message key for the tables `inventory.customers` and `purchase.orders`: +
+
`inventory.customers:pk1,pk2;(.*).purchaseorders:pk3,pk4` +
+
For the table `inventory.customer`, the columns `pk1` and `pk2` are specified as the message key.
For the `purchaseorders` tables in any database, the columns `pk3` and `pk4` server as the message key.
+
There is no limit to the number of columns that you use to create custom message keys.
However, it's best to use the minimum number that are required to specify a unique key.
[horizontal]
Default value::: No default
[id="{context}-property-name"]
xref:{context}-property-name[`name`]::
Unique name for the connector.
If you attempt to use the same name to register another connector, registration fails.
This property is required by all Kafka Connect connectors.
[horizontal]
Default value::: No default
[id="{context}-property-schema-name-adjustment-mode"]
xref:{context}-property-schema-name-adjustment-mode[`schema.name.adjustment.mode`]::
Specifies how the connector adjusts schema names for compatibility with the message converter used by the connector.
Set one of the following options:
`none`::: No adjustment.
`avro`::: Replaces characters that are not valid in Avro names with underscore characters.
`avro_unicode`::: Replaces underscore characters or characters that cannot be used in Avro names with corresponding unicode, such as `$$_$$uxxxx.` +
+
NOTE: `_` is an escape sequence, similar to a backslash in Java
[horizontal]
Default value::: No default
[id="{context}-property-skip-messages-without-change"]
xref:{context}-property-skip-messages-without-change[`skip.messages.without.change`]::
Specifies whether the connector emits messages for records when it does not detect a change in the included columns.
Columns are considered to be included if they are listed in the `column.include.list`, or are not listed in the `column.exclude.list`.
Set the value to `true` to prevent the connector from capturing records when no changes are present in the included columns.
[horizontal]
Default value::: `false`
[id="{context}-property-table-exclude-list"]
xref:{context}-property-table-exclude-list[`table-exclude-list`]::
An optional, comma-separated list of regular expressions that match fully-qualified table identifiers of tables from which you do not want the connector to capture changes.
The connector captures changes in any table that is not included in `table.exclude.list`.
Each identifier is of the form _databaseName_._tableName_. +
+
To match the name of a column, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the table; it does not match substrings that might be present in a table name. +
If you include this property in the configuration, do not also set the `table.include.list` property.
[horizontal]
Default value::: _empty string_
[id="{context}-property-table-include-list"]
xref:{context}-property-table-include-list[`table.include.list`]::
An optional, comma-separated list of regular expressions that match fully-qualified table identifiers of tables whose changes you want to capture.
The connector does not capture changes in any table that is not included in `table.include.list`.
Each identifier is of the form _databaseName_._tableName_.
By default, the connector captures changes in all non-system tables in every database from which it is configured to captures changes. +
+
To match the name of a table, {prodname} applies the regular expression that you specify as an _anchored_ regular expression.
That is, the specified expression is matched against the entire name string of the table; it does not match substrings that might be present in a table name. +
If you include this property in the configuration, do not also set the `table.exclude.list` property.
[horizontal]
Default value::: _empty string_
[id="{context}-property-tasks-max"]
xref:{context}-property-tasks-max[`tasks.max`]::
The maximum number of tasks to create for this connector.
Because the {connector-name} connector always uses a single task, changing the default value has no effect.
[horizontal]
Default value::: `1`
[id="{context}-property-time-precision-mode"]
xref:{context}-property-time-precision-mode[`time.precision.mode`]::
Specifies the type of precision that the connector uses to represent time, date, and timestamps values.
Set one of the following options: +
+
`adaptive_time_microseconds` (default)::: The connector captures the date, datetime and timestamp values exactly as in the database using either millisecond, microsecond, or nanosecond precision values based on the database column's type, with the exception of TIME type fields, which are always captured as microseconds. +
+
ifdef::community[]
`adaptive` (deprecated)::: The connector captures time and timestamp values exactly as in the database using either millisecond, microsecond, or nanosecond precision values based on the data type of the column. +
endif::community[]
+
`connect`::: The connector always represents time and timestamp values using Kafka Connect's built-in representations for Time, Date, and Timestamp, which use millisecond precision regardless of the database columns' precision.
[horizontal]
Default value::: `adaptive_time_microseconds`
[id="{context}-property-tombstones-on-delete"]
xref:{context}-property-tombstones-on-delete[`tombstones.on.delete`]::
Specifies whether a _delete_ event is followed by a tombstone event.
After a source record is deleted, the connector can emit a tombstone event (the default behavior) to enable Kafka to completely delete all events that pertain to the key of the deleted row in case {link-kafka-docs}/#compaction[log compaction] is enabled for the topic.
Set one of the following options: +
+
`true` (default)::: The connector represents delete operations by emitting a _delete_ event and a subsequent tombstone event. +
`false`::: The connector emits only _delete_ events. +
[horizontal]
Default value::: `true`
[id="{context}-property-topic-prefix"]
xref:{context}-property-topic-prefix[`topic.prefix`]::
Topic prefix that provides a namespace for the particular {connector-name} database server or cluster in which {prodname} is capturing changes.
Because the topic prefix is used to name all of the Kafka topics that receive events that this connector emits, it's important that the topic prefix is unique across all connectors.
Values must contain only alphanumeric characters, hyphens, dots, and underscores. +
+
[WARNING]
====
After you set this property, do not change its value.
If you change the value, after the connector restarts, instead of continuing to emit events to the original topics, the connector emits subsequent events to topics whose names are based on the new value.
The connector is also unable to recover its database schema history topic.
====
[horizontal]
Default value::: No default

View File

@ -0,0 +1,3064 @@
= {prodname} connector for {connector-name}
tag::mariadb-mysql-intro[]
{connector-name} has a binary log (binlog) that records all operations in the order in which they are committed to the database.
This includes changes to table schemas as well as changes to the data in tables.
{connector-name} uses the binlog for replication and recovery.
The {prodname} {connector-name} connector reads the binlog, produces change events for row-level `INSERT`, `UPDATE`, and `DELETE` operations, and emits the change events to Kafka topics.
Client applications read those Kafka topics.
Because {connector-name} is typically set up to purge binlogs after a specified period of time, the {connector-name} connector performs an initial _consistent snapshot_ of each of your databases.
The {connector-name} connector reads the binlog from the point at which the snapshot was made.
ifdef::community[]
For information about the {connector-name} Database versions that are compatible with this connector, see the link:https://debezium.io/releases/[{prodname} release overview].
endif::community[]
ifdef::product[]
For information about the {connector-name} Database versions that are compatible with this connector, see the link:{LinkDebeziumSupportedConfigurations}[{NameDebeziumSupportedConfigurations}].
endif::product[]
ifdef::product[]
Information and procedures for using a {prodname} {connector-name} connector are organized as follows:
* xref:how-debezium-{context}-connectors-work[]
* xref:descriptions-of-debezium-{context}-connector-data-change-events[]
* xref:how-debezium-{context}-connectors-map-data-types[]
* xref:debezium-{context}-connector-converters[]
* xref:setting-up-{context}-to-run-a-debezium-connector[]
* xref:deployment-of-debezium-{context}-connectors[]
* xref:monitoring-debezium-{context}-connector-performance[]
* xref:how-debezium-{context}-connectors-handle-faults-and-problems[]
endif::product[]
end::mariadb-mysql-intro[]
== How the connector works
tag::how-connector-works-intro[]
An overview of the {connector-name} topologies that the connector supports is useful for planning your application.
To optimally configure and run a {prodname} {connector-name} connector, it is helpful to understand how the connector tracks the structure of tables, exposes schema changes, performs snapshots, and determines Kafka topic names.
ifdef::product[]
Details are in the following topics:
* xref:{context}-topologies-supported-by-debezium-connectors[]
* xref:supplemental-configuration-for-connecting-debezium-to-{context}[]
* xref:how-debezium-{context}-connectors-handle-database-schema-changes[]
* xref:how-debezium-{context}-connectors-expose-database-schema-changes[]
* xref:how-debezium-{context}-connectors-perform-database-snapshots[]
* xref:debezium-{context}-ad-hoc-snapshots[]
* xref:debezium-{context}-incremental-snapshots[]
* xref:default-names-of-kafka-topics-that-receive-debezium-{context}-change-event-records[]
endif::product[]
end::how-connector-works-intro[]
=== Schema history topic
tag::schema-history[]
When a database client queries a database, the client uses the databases current schema.
However, the database schema can be changed at any time, which means that the connector must be able to identify what the schema was at the time each insert, update, or delete operation was recorded.
Also, a connector cannot necessarily apply the current schema to every event.
If an event is relatively old, it's possible that it was recorded before the current schema was applied.
To ensure correct processing of events that occur after a schema change, {connector-name} includes in the transaction log not only the row-level changes that affect the data, but also the DDL statements that are applied to the database.
As the connector encounters these DDL statements in the binlog, it parses them and updates an in-memory representation of each tables schema.
The connector uses this schema representation to identify the structure of the tables at the time of each insert, update, or delete operation and to produce the appropriate change event.
In a separate database schema history Kafka topic, the connector records all DDL statements along with the position in the binlog where each DDL statement appeared.
When the connector restarts after either a crash or a graceful stop, it starts reading the binlog from a specific position, that is, from a specific point in time.
The connector rebuilds the table structures that existed at this point in time by reading the database schema history Kafka topic and parsing all DDL statements up to the point in the binlog where the connector is starting.
This database schema history topic is for internal connector use only.
Optionally, the connector can also xref:{context}-schema-change-topic[emit schema change events to a different topic that is intended for consumer applications].
When the {connector-name} connector captures changes in a table to which a schema change tool such as `gh-ost` or `pt-online-schema-change` is applied, there are helper tables created during the migration process.
You must configure the connector to capture changes that occur in these helper tables.
If consumers do not need the records the connector generates for helper tables, configure a {link-prefix}:{link-filtering}#message-filtering[single message transform (SMT)] to remove these records from the messages that the connector emits.
.Additional resources
* xref:{context}-topic-names[Default names for topics] that receive {prodname} event records.
end::schema-history[]
=== Schema change topic
tag::schema-change[]
You can configure a {prodname} {connector-name} connector to produce schema change events that describe schema changes that are applied to tables in the database.
The connector writes schema change events to a Kafka topic named `_<topicPrefix>_`, where `_topicPrefix_` is the namespace specified in the xref:{context}-property-topic-prefix[`topic.prefix`] connector configuration property.
Messages that the connector sends to the schema change topic contain a payload, and, optionally, also contain the schema of the change event message.
The schema for the schema change event has the following elements:
`name`:: The name of the schema change event message.
`type`:: The type of the change event message.
`version`:: The version of the schema. The version is an integer that is incremented each time the schema is changed.
`fields`:: The fields that are included in the change event message.
.Example: Schema of the {connector-name} connector schema change topic
The following example shows a typical schema in JSON format.
[source,json,indent=0,subs="+attributes"]
----
{
"schema": {
"type": "struct",
"fields": [
{
"type": "string",
"optional": false,
"field": "databaseName"
}
],
"optional": false,
"name": "io.debezium.connector.{context}.SchemaChangeKey",
"version": 1
},
"payload": {
"databaseName": "inventory"
}
}
----
The payload of a schema change event message includes the following elements:
`ddl`:: Provides the SQL `CREATE`, `ALTER`, or `DROP` statement that results in the schema change.
`databaseName`:: The name of the database to which the DDL statements are applied.
The value of `databaseName` serves as the message key.
`pos`:: The position in the binlog where the statements appear.
`tableChanges`:: A structured representation of the entire table schema after the schema change.
The `tableChanges` field contains an array that includes entries for each column of the table.
Because the structured representation presents data in JSON or Avro format, consumers can easily read messages without first processing them through a DDL parser.
[IMPORTANT]
====
For a table that is in capture mode, the connector not only stores the history of schema changes in the schema change topic, but also in an internal database schema history topic.
The internal database schema history topic is for connector use only, and it is not intended for direct use by consuming applications.
Ensure that applications that require notifications about schema changes consume that information only from the schema change topic.
====
[IMPORTANT]
====
Never partition the database schema history topic.
For the database schema history topic to function correctly, it must maintain a consistent, global order of the event records that the connector emits to it.
To ensure that the topic is not split among partitions, set the partition count for the topic by using one of the following methods:
* If you create the database schema history topic manually, specify a partition count of `1`.
* If you use the Apache Kafka broker to create the database schema history topic automatically, the topic is created, set the value of the link:{link-kafka-docs}/#brokerconfigs_num.partitions[Kafka `num.partitions`] configuration option to `1`.
====
[WARNING]
====
The format of the messages that a connector emits to its schema change topic is in an incubating state and is subject to change without notice.
====
.Example: Message emitted to the {connector-name} connector schema change topic
The following example shows a typical schema change message in JSON format.
The message contains a logical representation of the table schema.
[source,json,indent=0,subs="+attributes"]
----
{
"schema": { },
"payload": {
"source": { // <1>
"version": "{debezium-version}",
"connector": "{context}",
"name": "{context}",
"ts_ms": 1651535750218, // <2>
"ts_us": 1651535750218000, // <2>
"ts_ns": 1651535750218000000, // <2>
"snapshot": "false",
"db": "inventory",
"sequence": null,
"table": "customers",
"server_id": 223344,
"gtid": null,
"file": "{context}-bin.000003",
"pos": 570,
"row": 0,
"thread": null,
"query": null
},
"databaseName": "inventory", <3>
"schemaName": null,
"ddl": "ALTER TABLE customers ADD middle_name varchar(255) AFTER first_name", <4>
"tableChanges": [ <5>
{
"type": "ALTER", <6>
"id": "\"inventory\".\"customers\"", <7>
"table": { <8>
"defaultCharsetName": "utf8mb4",
"primaryKeyColumnNames": [ <9>
"id"
],
"columns": [ <10>
{
"name": "id",
"jdbcType": 4,
"nativeType": null,
"typeName": "INT",
"typeExpression": "INT",
"charsetName": null,
"length": null,
"scale": null,
"position": 1,
"optional": false,
"autoIncremented": true,
"generated": true
},
{
"name": "first_name",
"jdbcType": 12,
"nativeType": null,
"typeName": "VARCHAR",
"typeExpression": "VARCHAR",
"charsetName": "utf8mb4",
"length": 255,
"scale": null,
"position": 2,
"optional": false,
"autoIncremented": false,
"generated": false
},
{
"name": "middle_name",
"jdbcType": 12,
"nativeType": null,
"typeName": "VARCHAR",
"typeExpression": "VARCHAR",
"charsetName": "utf8mb4",
"length": 255,
"scale": null,
"position": 3,
"optional": true,
"autoIncremented": false,
"generated": false
},
{
"name": "last_name",
"jdbcType": 12,
"nativeType": null,
"typeName": "VARCHAR",
"typeExpression": "VARCHAR",
"charsetName": "utf8mb4",
"length": 255,
"scale": null,
"position": 4,
"optional": false,
"autoIncremented": false,
"generated": false
},
{
"name": "email",
"jdbcType": 12,
"nativeType": null,
"typeName": "VARCHAR",
"typeExpression": "VARCHAR",
"charsetName": "utf8mb4",
"length": 255,
"scale": null,
"position": 5,
"optional": false,
"autoIncremented": false,
"generated": false
}
],
"attributes": [ <11>
{
"customAttribute": "attributeValue"
}
]
}
}
]
}
}
----
.Descriptions of fields in messages emitted to the schema change topic
[cols="1,4,5",options="header"]
|===
|Item |Field name |Description
|1
|`source`
|The `source` field is structured exactly as standard data change events that the connector writes to table-specific topics.
This field is useful to correlate events on different topics.
|2
|`ts_ms`, `ts_us`, `ts_ns`
|Optional field that displays the time at which the connector processed the event.
The time is based on the system clock in the JVM running the Kafka Connect task. +
+
In the source object, ts_ms indicates the time that the change was made in the database. By comparing the value for payload.source.ts_ms with the value for payload.ts_ms, you can determine the lag between the source database update and Debezium.
|3
|`databaseName` +
`schemaName`
|Identifies the database and the schema that contains the change.
The value of the `databaseName` field is used as the message key for the record.
|4
|`ddl`
|This field contains the DDL that is responsible for the schema change.
The `ddl` field can contain multiple DDL statements.
Each statement applies to the database in the `databaseName` field.
Multiple DDL statements appear in the order in which they were applied to the database. +
+
Clients can submit multiple DDL statements that apply to multiple databases.
If {connector-name} applies them atomically, the connector takes the DDL statements in order, groups them by database, and creates a schema change event for each group.
If {connector-name} applies them individually, the connector creates a separate schema change event for each statement.
|5
|`tableChanges`
|An array of one or more items that contain the schema changes generated by a DDL command.
|6
|`type`
a|Describes the kind of change. The value is one of the following:
`CREATE`:: Table created.
`ALTER`:: Table modified.
`DROP`:: Table deleted.
|7
|`id`
|Full identifier of the table that was created, altered, or dropped.
In the case of a table rename, this identifier is a concatenation of `_<old>_,_<new>_` table names.
|8
|`table`
|Represents table metadata after the applied change.
|9
|`primaryKeyColumnNames`
|List of columns that compose the table's primary key.
|10
|`columns`
|Metadata for each column in the changed table.
|11
|`attributes`
|Custom attribute metadata for each table change.
|===
For more information, see xref:{context}-schema-history-topic[schema history topic].
end::schema-change[]
=== Snapshots
tag::snapshots[]
When a {prodname} {connector-name} connector is first started, it performs an initial _consistent snapshot_ of your database.
This snapshot enables the connector to establish a baseline for the current state of the database.
{prodname} can use different modes when it runs a snapshot.
The snapshot mode is determined by the xref:{context}-property-snapshot-mode[`snapshot.mode`] configuration property.
The default value of the property is `initial`.
You can customize the way that the connector creates snapshots by changing the value of the `snapshot.mode` property.
ifdef::product[]
You can find more information about snapshots in the following sections:
* xref:debezium-{context}-ad-hoc-snapshots[]
* xref:debezium-{context}-incremental-snapshots[]
endif::product[]
The connector completes a series of tasks when it performs the snapshot.
The exact steps vary with the snapshot mode and with the table locking policy that is in effect for the database.
The {prodname} {connector-name} connector completes different steps when it performs an initial snapshot that uses a xref:initial-snapshot-workflow-with-global-read-lock[global read lock] or xref:initial-snapshot-workflow-with-table-level-locks[table-level locks].
end::snapshots[]
==== Initial snapshots that use a global read lock
tag::initial-snap-global[]
You can customize the way that the connector creates snapshots by changing the value of the `snapshot.mode` property.
If you configure a different snapshot mode, the connector completes the snapshot by using a modified version of this workflow.
For information about the snapshot process in environments that do not permit global read locks, see the xref:snapshot-workflow-with-table-level-locks[snapshot workflow for table-level locks].
.Default workflow that the {prodname} {connector-name} connector uses to perform an initial snapshot with a global read lock
The following table shows the steps in the workflow that {prodname} follows to create a snapshot with a global read lock.
[cols="1a,9a",options="header",subs="+attributes"]
|===
|Step |Action
|1
a|Establish a connection to the database.
|2
|Determine the tables to be captured.
By default, the connector captures the data for all non-system tables.
After the snapshot completes, the connector continues to stream data for the specified tables.
If you want the connector to capture data only from specific tables you can direct the connector to capture the data for only a subset of tables or table elements by setting properties such as xref:{context}-property-table-include-list[`table.include.list`] or xref:{context}-property-table-exclude-list[`table.exclude.list`].
|3
|Obtain a global read lock on the tables to be captured to block _writes_ by other database clients. +
+
The snapshot itself does not prevent other clients from applying DDL that might interfere with the connector's attempt to read the binlog position and table schemas.
The connector retains the global read lock while it reads the binlog position, and releases the lock as described in a later step.
|4
ifdef::MYSQL[]
a|Start a transaction with link:https://dev.mysql.com/doc/refman/{mysql-version}/en/innodb-consistent-read.html[repeatable read semantics] to ensure that all subsequent reads within the transaction are done against the _consistent snapshot_. +
endif::MYSQL[]
ifdef::MARIADB[]
a|Start a transaction with link:https://mariadb.com/kb/en/set-transaction/#repeatable-read[repeatable read semantics] to ensure that all subsequent reads within the transaction are done against the _consistent snapshot_. +
endif::MARIADB[]
+
[NOTE]
====
The use of these isolation semantics can slow the progress of the snapshot.
If the snapshot takes too long to complete, consider using a different isolation configuration, or skip the initial snapshot and run an xref:debezium-{context}-incremental-snapshots[incremental snapshot] instead.
====
|5
|Read the current binlog position.
|6
a|Capture the structure of all tables in the database, or all tables that are designated for capture.
The connector persists schema information in its internal database schema history topic, including all necessary `DROP...` and `CREATE...` DDL statements. +
The schema history provides information about the structure that is in effect when a change event occurs.
+
[NOTE]
====
By default, the connector captures the schema of every table in the database, including tables that are not configured for capture.
If tables are not configured for capture, the initial snapshot captures only their structure; it does not capture any table data. +
+
For more information about why snapshots persist schema information for tables that you did not include in the initial snapshot, see xref:understanding-why-initial-snapshots-capture-the-schema-history-for-all-tables[Understanding why initial snapshots capture the schema for all tables].
====
|7
|Release the global read lock obtained in Step 3.
Other database clients can now write to the database.
|8
a|At the binlog position that the connector read in Step 5, the connector begins to scan the tables that are designated for capture.
During the scan, the connector completes the following tasks:
. Confirms that the table was created before the snapshot began.
If the table was created after the snapshot began, the connector skips the table.
After the snapshot is complete, and the connector transitions to streaming, it emits change events for any tables that were created after the snapshot began.
. Produces a `read` event for each row that is captured from a table.
All `read` events contain the same binlog position, which is the position that was obtained in step 5.
. Emits each `read` event to the Kafka topic for the source table.
. Releases data table locks, if applicable.
|9
|Commit the transaction.
|10
|Record the successful completion of the snapshot in the connector offsets.
|===
The resulting initial snapshot captures the current state of each row in the captured tables.
From this baseline state, the connector captures subsequent changes as they occur.
After the snapshot process begins, if the process is interrupted due to connector failure, rebalancing, or other reasons, the process restarts after the connector restarts.
After the connector completes the initial snapshot, it continues streaming from the position that it read in Step 5 so that it does not miss any updates.
If the connector stops again for any reason, after it restarts, it resumes streaming changes from where it previously left off.
After the connector restarts, if the logs have been pruned, the connector's position in the logs might no longer available.
The connector then fails, and returns an error that indicates that a new snapshot is required.
To configure the connector to automatically initiate a snapshot in this situation, set the value of the xref:{context}-property-snapshot-mode[`snapshot.mode`] property to `when_needed`.
For more tips on troubleshooting the {prodname} {connector-name} connector, see xref:{context}-when-things-go-wrong[behavior when things go wrong].
end::initial-snap-global[]
==== Initial snapshots that use table-level locks
tag::initial-snap-table-lock[]
In some database environments, administrators do not permit global read locks.
If the {prodname} {connector-name} connector detects that global read locks are not permitted, the connector uses table-level locks when it performs snapshots.
For the connector to perform a snapshot that uses table-level locks, the database account that the {prodname} connector uses to connect to {connector-name} must have `LOCK TABLES` privileges.
.Default workflow that the {prodname} {connector-name} connector uses to perform an initial snapshot with table-level locks
The following workflow lists the steps that {prodname} takes to create a snapshot with table-level read locks.
For information about the snapshot process in environments that do not permit global read locks, see the xref:initial-snapshot-workflow-with-global-read-lock[snapshot workflow for global read locks].
[id="snapshot-workflow-with-table-level-locks"]
[cols="1,9",options="header",subs="+attributes"]
|===
|Step |Action
|1
|Establish a connection to the database.
|2
|Determine the tables to be captured.
By default, the connector captures all non-system tables.
To have the connector capture a subset of tables or table elements, you can set a number of `include` and `exclude` properties to filter the data, for example, xref:{context}-property-table-include-list[`table.include.list`] or xref:{context}-property-table-exclude-list[`table.exclude.list`].
|3
|Obtain table-level locks.
|4
ifdef::MYSQL[]
a|Start a transaction with link:https://dev.mysql.com/doc/refman/{mysql-version}/en/innodb-consistent-read.html[repeatable read semantics] to ensure that all subsequent reads within the transaction are done against the _consistent snapshot_.
endif::MYSQL[]
ifdef::MARIADB[]
a|Start a transaction with link:https://mariadb.com/kb/en/set-transaction/#repeatable-read[repeatable read semantics] to ensure that all subsequent reads within the transaction are done against the _consistent snapshot_.
endif::MARIADB[]
// |5
// |Read and filter the names of the databases and tables.
|5
a|Read the current binlog position.
|6
a|Read the schema of the databases and tables for which the connector is configured to capture changes.
The connector persists schema information in its internal database schema history topic, including all necessary `DROP...` and `CREATE...` DDL statements. +
The schema history provides information about the structure that is in effect when a change event occurs.
+
[NOTE]
====
By default, the connector captures the schema of every table in the database, including tables that are not configured for capture.
If tables are not configured for capture, the initial snapshot captures only their structure; it does not capture any table data.
For more information about why snapshots persist schema information for tables that you did not include in the initial snapshot, see xref:understanding-why-initial-snapshots-capture-the-schema-history-for-all-tables[Understanding why initial snapshots capture the schema for all tables].
====
|7
a|At the binlog position that the connector read in Step 5, the connector begins to scan the tables that are designated for capture.
During the scan, the connector completes the following tasks:
. Confirms that the table was created before the snapshot began.
If the table was created after the snapshot began, the connector skips the table.
After the snapshot is complete, and the connector transitions to streaming, it emits change events for any tables that were created after the snapshot began.
. Produces a `read` event for each row that is captured from a table.
All `read` events contain the same binlog position, which is the position that was obtained in step 5.
. Emits each `read` event to the Kafka topic for the source table.
. Releases data table locks, if applicable.
|8
a|Commit the transaction.
|9
|Release the table-level locks.
Other database clients can now write to any previously locked tables.
|10
a|Record the successful completion of the snapshot in the connector offsets.
|===
[id="{context}-connector-snapshot-mode-options"]
.Settings for `snapshot.mode` connector configuration property
[cols="30%a,70%a",options="header"]
|===
|Setting |Description
|`always`
|The connector performs a snapshot every time that it starts.
The snapshot includes the structure and data of the captured tables.
Specify this value to populate topics with a complete representation of the data from the captured tables every time that the connector starts.
After the snapshot completes, the connector begins to stream event records for subsequent database changes.
|`initial`
|The connector performs a database snapshot as described in the xref:initial-snapshot-workflow-with-global-read-lock[default workflow for creating an initial snapshot].
After the snapshot completes, the connector begins to stream event records for subsequent database changes.
|`initial_only`
|The connector performs a database snapshot.
After the snapshot completes, the connector stops, and does not stream event records for subsequent database changes.
|`schema_only`
|Deprecated, see `no_data`.
|`no_data`
|The connector captures the structure of all relevant tables, performing all the steps described in the xref:initial-snapshot-workflow-with-global-read-lock[default workflow for creating an initial snapshot], except that it does not create `READ` events to represent the data set at the point of the connector's start-up (Step 7.2).
|`never`
|When the connector starts, rather than performing a snapshot, it immediately begins to stream event records for subsequent database changes.
This option is under consideration for future deprecation, in favor of the `no_data` option.
|`schema_only_recovery`
|Deprecated, see `recovery`.
|`recovery`
|Set this option to restore a database schema history topic that is lost or corrupted.
After a restart, the connector runs a snapshot that rebuilds the topic from the source tables.
You can also set the property to periodically prune a database schema history topic that experiences unexpected growth. +
+
WARNING: Do not use this mode to perform a snapshot if schema changes were committed to the database after the last connector shutdown.
|`when_needed`
|After the connector starts, it performs a snapshot only if it detects one of the following circumstances:
* It cannot detect any topic offsets.
* A previously recorded offset specifies a log position that is not available on the server.
ifdef::community[]
|`configuration_based`
|Set the snapshot mode to `configuration_based` to control snapshot behavior through the set of connector properties that have the prefix 'snapshot.mode.configuration.based'.
endif::community[]
ifdef::community[]
|`custom`
|The `custom` snapshot mode lets you inject your own implementation of the `io.debezium.spi.snapshot.Snapshotter` interface.
Set the `snapshot.mode.custom.name` configuration property to the name provided by the `name()` method of your implementation.
The name is specified on the classpath of your Kafka Connect cluster.
If you use the `EmbeddedEngine`, the name is included in the connector JAR file.
For more information, see xref:connector-custom-snapshot[custom snapshotter SPI].
endif::community[]
|===
For more information, see xref:{context}-property-snapshot-mode[`snapshot.mode`] in the table of connector configuration properties.
end::initial-snap-table-lock[]
==== Understanding why initial snapshots capture the schema history for all tables
tag::why-snapshot-captures-history-all[]
The initial snapshot that a connector runs captures two types of information:
Table data::
Information about `INSERT`, `UPDATE`, and `DELETE` operations in tables that are named in the connector's xref:{context}-property-table-include-list[`table.include.list`] property.
Schema data::
DDL statements that describe the structural changes that are applied to tables.
Schema data is persisted to both the internal schema history topic, and to the connector's schema change topic, if one is configured.
After you run an initial snapshot, you might notice that the snapshot captures schema information for tables that are not designated for capture.
By default, initial snapshots are designed to capture schema information for every table that is present in the database, not only from tables that are designated for capture.
Connectors require that the table's schema is present in the schema history topic before they can capture a table.
By enabling the initial snapshot to capture schema data for tables that are not part of the original capture set, {prodname} prepares the connector to readily capture event data from these tables should that later become necessary.
If the initial snapshot does not capture a table's schema, you must add the schema to the history topic before the connector can capture data from the table.
In some cases, you might want to limit schema capture in the initial snapshot.
This can be useful when you want to reduce the time required to complete a snapshot.
Or when {prodname} connects to the database instance through a user account that has access to multiple logical databases, but you want the connector to capture changes only from tables in a specific logic database.
.Additional information
* xref:{context}-capturing-data-from-tables-not-captured-by-the-initial-snapshot-no-schema-change[Capturing data from tables not captured by the initial snapshot (no schema change)]
* xref:{context}-capturing-data-from-new-tables-with-schema-changes[Capturing data from tables not captured by the initial snapshot (schema change)]
* Setting the xref:{context}-property-database-history-store-only-captured-tables-ddl[`schema.history.internal.store.only.captured.tables.ddl`] property to specify the tables from which to capture schema information.
* Setting the xref:{context}-property-database-history-store-only-captured-databases-ddl[`schema.history.internal.store.only.captured.databases.ddl`] property to specify the logical databases from which to capture schema changes.
end::snapshot-captures-history-all[]
==== Capturing data from tables not captured by the initial snapshot (no schema change)
tag::cap-tbls-not-in-initial-no-schema-chg[]
In some cases, you might want the connector to capture data from a table whose schema was not captured by the initial snapshot.
Depending on the connector configuration, the initial snapshot might capture the table schema only for specific tables in the database.
If the table schema is not present in the history topic, the connector fails to capture the table, and reports a missing schema error.
You might still be able to capture data from the table, but you must perform additional steps to add the table schema.
.Prerequisites
* You want to capture data from a table with a schema that the connector did not capture during the initial snapshot.
* In the transaction log, all entries for the table use the same schema.
For information about capturing data from a new table that has undergone structural changes, see xref:{context}-capturing-data-from-new-tables-with-schema-changes[Capturing data from tables not captured by the initial snapshot (schema change)].
.Procedure
1. Stop the connector.
2. Remove the internal database schema history topic that is specified by the xref:{context}-property-database-history-kafka-topic[`schema.history.internal.kafka.topic property`].
3. Apply the following changes to the connector configuration:
.. Set the xref:{context}-property-snapshot-mode[`snapshot.mode`] to `schema_only_recovery`.
.. Set the value of xref:{context}-property-database-history-store-only-captured-tables-ddl[`schema.history.internal.store.only.captured.tables.ddl`] to `false`.
.. Add the tables that you want the connector to capture to `table.include.list`.
This guarantees that in the future, the connector can reconstruct the schema history for all tables.
4. Restart the connector.
The snapshot recovery process rebuilds the schema history based on the current structure of the tables.
5. (Optional) After the snapshot completes, initiate an xref:debezium-{context}-incremental-snapshots[incremental snapshot] to capture existing data for newly added tables along with changes to other tables that occurred while that connector was off-line.
6. (Optional) Reset the `snapshot.mode` back to `schema_only` to prevent the connector from initiating recovery after a future restart.
end::cap-tbls-not-in-initial-no-schema-chg[]
==== Capturing data from tables not captured by the initial snapshot (schema change)
tag::cap-tbls-not-in-initial-schema-chg[]
If a schema change is applied to a table, records that are committed before the schema change have different structures than those that were committed after the change.
When {prodname} captures data from a table, it reads the schema history to ensure that it applies the correct schema to each event.
If the schema is not present in the schema history topic, the connector is unable to capture the table, and an error results.
If you want to capture data from a table that was not captured by the initial snapshot, and the schema of the table was modified, you must add the schema to the history topic, if it is not already available.
You can add the schema by running a new schema snapshot, or by running an initial snapshot for the table.
.Prerequisites
* You want to capture data from a table with a schema that the connector did not capture during the initial snapshot.
* A schema change was applied to the table so that the records to be captured do not have a uniform structure.
.Procedure
Initial snapshot captured the schema for all tables (`store.only.captured.tables.ddl` was set to `false`)::
1. Edit the xref:{context}-property-table-include-list[`table.include.list`] property to specify the tables that you want to capture.
2. Restart the connector.
3. Initiate an xref:debezium-{context}-incremental-snapshots[incremental snapshot] if you want to capture existing data from the newly added tables.
Initial snapshot did not capture the schema for all tables (`store.only.captured.tables.ddl` was set to `true`)::
If the initial snapshot did not save the schema of the table that you want to capture, complete one of the following procedures:
Procedure 1: Schema snapshot, followed by incremental snapshot:::
In this procedure, the connector first performs a schema snapshot.
You can then initiate an incremental snapshot to enable the connector to synchronize data.
1. Stop the connector.
2. Remove the internal database schema history topic that is specified by the xref:{context}-property-database-history-kafka-topic[`schema.history.internal.kafka.topic property`].
3. Clear the offsets in the configured Kafka Connect link:{link-kafka-docs}/#connectconfigs_offset.storage.topic[`offset.storage.topic`].
For more information about how to remove offsets, see the link:https://debezium.io/documentation/faq/#how_to_remove_committed_offsets_for_a_connector[{prodname} community FAQ].
+
[WARNING]
====
Removing offsets should be performed only by advanced users who have experience in manipulating internal Kafka Connect data.
This operation is potentially destructive, and should be performed only as a last resort.
====
4. Set values for properties in the connector configuration as described in the following steps:
.. Set the value of the xref:{context}-property-snapshot-mode[`snapshot.mode`] property to `schema_only`.
.. Edit the xref:{context}-property-table-include-list[`table.include.list`] to add the tables that you want to capture.
5. Restart the connector.
6. Wait for {prodname} to capture the schema of the new and existing tables.
Data changes that occurred any tables after the connector stopped are not captured.
7. To ensure that no data is lost, initiate an xref:debezium-{context}-incremental-snapshots[incremental snapshot].
Procedure 2: Initial snapshot, followed by optional incremental snapshot:::
In this procedure the connector performs a full initial snapshot of the database.
As with any initial snapshot, in a database with many large tables, running an initial snapshot can be a time-consuming operation.
After the snapshot completes, you can optionally trigger an incremental snapshot to capture any changes that occur while the connector is off-line.
1. Stop the connector.
2. Remove the internal database schema history topic that is specified by the xref:{context}-property-database-history-kafka-topic[`schema.history.internal.kafka.topic property`].
3. Clear the offsets in the configured Kafka Connect link:{link-kafka-docs}/#connectconfigs_offset.storage.topic[`offset.storage.topic`].
For more information about how to remove offsets, see the link:https://debezium.io/documentation/faq/#how_to_remove_committed_offsets_for_a_connector[{prodname} community FAQ].
+
[WARNING]
====
Removing offsets should be performed only by advanced users who have experience in manipulating internal Kafka Connect data.
This operation is potentially destructive, and should be performed only as a last resort.
====
4. Edit the xref:{context}-property-table-include-list[`table.include.list`] to add the tables that you want to capture.
5. Set values for properties in the connector configuration as described in the following steps:
.. Set the value of the xref:{context}-property-snapshot-mode[`snapshot.mode`] property to `initial`.
.. (Optional) Set xref:{context}-property-database-history-store-only-captured-tables-ddl[`schema.history.internal.store.only.captured.tables.ddl`] to `false`.
6. Restart the connector.
The connector takes a full database snapshot.
After the snapshot completes, the connector transitions to streaming.
7. (Optional) To capture any data that changed while the connector was off-line, initiate an xref:debezium-{context}-incremental-snapshots[incremental snapshot].
end::cap-tbls-not-in-initial-schema-chg[]
==== Read-only incremental snapshots
tag::readonly-incremental[]
The {prodname} {connector-name} connector allows for running incremental snapshots with a read-only connection to the database.
To run an incremental snapshot with read-only access, the connector uses the executed global transaction IDs (GTID) set as high and low watermarks.
The state of a chunk's window is updated by comparing the GTIDs of binary log (binlog) events or the server's heartbeats against low and high watermarks.
To switch to a read-only implementation, set the value of the xref:{context}-property-read-only[`read.only`] property to `true`.
.Prerequisites
* xref:enable-{context}-gtids[Enable {connector-name} GTIDs].
* If the connector reads from a multi-threaded replica (that is, a replica for which the value of `replica_parallel_workers` is greater than `0`)
you must set one of the following options:
** `replica_preserve_commit_order=ON`
** `slave_preserve_commit_order=ON`
end::readonly-incremental[]
==== Ad hoc read-only incremental snapshots
tag::adhoc-ro-incremental[]
When the {connector-name} connection is read-only, you can use any of the {link-prefix}:{link-signalling}#sending-signals-to-a-debezium-connector[available signaling channels] without the requirement to use the `source` channel.
end::adhoc-ro-incremental[]
=== Topic names
tag::topic-names[]
By default, the {connector-name} connector writes change events for all of the `INSERT`, `UPDATE`, and `DELETE` operations that occur in a table to a single Apache Kafka topic that is specific to that table.
The connector uses the following convention to name change event topics:
_topicPrefix.databaseName.tableName_
Suppose that `fulfillment` is the topic prefix, `inventory` is the database name, and the database contains tables named `orders`, `customers`, and `products`.
The {prodname} {connector-name} connector emits events to three Kafka topics, one for each table in the database:
----
fulfillment.inventory.orders
fulfillment.inventory.customers
fulfillment.inventory.products
----
The following list provides definitions for the components of the default name:
_topicPrefix_:: The topic prefix as specified by the xref:{context}-property-topic-prefix[`topic.prefix`] connector configuration property.
_schemaName_:: The name of the schema in which the operation occurred.
_tableName_:: The name of the table in which the operation occurred.
The connector applies similar naming conventions to label its internal database schema history topics, xref:{context}-schema-change-topic[schema change topics], and xref:{context}-transaction-metadata[transaction metadata topics].
If the default topic name do not meet your requirements, you can configure custom topic names.
To configure custom topic names, you specify regular expressions in the logical topic routing SMT.
For more information about using the logical topic routing SMT to customize topic naming, see {link-prefix}:{link-topic-routing}#topic-routing[Topic routing].
end::topic-names[]
=== Transaction metadata
tag::trans-meta[]
{prodname} can generate events that represent transaction boundaries and that enrich data change event messages.
[NOTE]
.Limits on when {prodname} receives transaction metadata
====
{prodname} registers and receives metadata only for transactions that occur after you deploy the connector.
Metadata for transactions that occur before you deploy the connector is not available.
====
{prodname} generates transaction boundary events for the `BEGIN` and `END` delimiters in every transaction.
Transaction boundary events contain the following fields:
`status`:: `BEGIN` or `END`.
`id`:: String representation of the unique transaction identifier.
`ts_ms`:: The time of a transaction boundary event (`BEGIN` or `END` event) at the data source.
If the data source does not provide {prodname} with the event time, then the field instead represents the time at which {prodname} processes the event.
`event_count` (for `END` events):: Total number of events emitted by the transaction.
`data_collections` (for `END` events):: An array of pairs of `data_collection` and `event_count` elements that indicates the number of events that the connector emits for changes that originate from a data collection.
.Example
[source,json,indent=0,subs="+attributes"]
----
{
"status": "BEGIN",
"id": "0e4d5dcd-a33b-11ea-80f1-02010a22a99e:10",
"ts_ms": 1486500577125,
"event_count": null,
"data_collections": null
}
{
"status": "END",
"id": "0e4d5dcd-a33b-11ea-80f1-02010a22a99e:10",
"ts_ms": 1486500577691,
"event_count": 2,
"data_collections": [
{
"data_collection": "s1.a",
"event_count": 1
},
{
"data_collection": "s2.a",
"event_count": 1
}
]
}
----
Unless overridden via the xref:{context}-property-topic-transaction[`topic.transaction`] option,
the connector emits transaction events to the xref:{context}-property-topic-prefix[`_<topic.prefix>_`]`.transaction` topic.
.Change data event enrichment
When transaction metadata is enabled the data message `Envelope` is enriched with a new `transaction` field.
This field provides information about every event in the form of a composite of fields:
`id`:: String representation of unique transaction identifier.
`total_order`:: The absolute position of the event among all events generated by the transaction.
`data_collection_order`:: The per-data collection position of the event among all events that were emitted by the transaction.
Following is an example of a message:
[source,json,indent=0,subs="+attributes"]
----
{
"before": null,
"after": {
"pk": "2",
"aa": "1"
},
"source": {
...
},
"op": "c",
"ts_ms": "1580390884335",
"ts_us": "1580390884335472",
"ts_ns": "1580390884335472987",
"transaction": {
"id": "0e4d5dcd-a33b-11ea-80f1-02010a22a99e:10",
"total_order": "1",
"data_collection_order": "1"
}
}
----
end::trans-meta[]
== Data change events
tag::data-chg-events[]
The {prodname} {connector-name} connector generates a data change event for each row-level `INSERT`, `UPDATE`, and `DELETE` operation. Each event contains a key and a value. The structure of the key and the value depends on the table that was changed.
{prodname} and Kafka Connect are designed around _continuous streams of event messages_. However, the structure of these events may change over time, which can be difficult for consumers to handle. To address this, each event contains the schema for its content or, if you are using a schema registry, a schema ID that a consumer can use to obtain the schema from the registry. This makes each event self-contained.
The following skeleton JSON shows the basic four parts of a change event. However, how you configure the Kafka Connect converter that you choose to use in your application determines the representation of these four parts in change events. A `schema` field is in a change event only when you configure the converter to produce it. Likewise, the event key and event payload are in a change event only if you configure a converter to produce it. If you use the JSON converter and you configure it to produce all four basic change event parts, change events have this structure:
[source,json,index=0]
----
{
"schema": { //<1>
...
},
"payload": { //<2>
...
},
"schema": { //<3>
...
},
"payload": { //<4>
...
},
}
----
.Overview of change event basic content
[cols="1,2,7",options="header"]
|===
|Item |Field name |Description
|1
|`schema`
|The first `schema` field is part of the event key. It specifies a Kafka Connect schema that describes what is in the event key's `payload` portion. In other words, the first `schema` field describes the structure of the primary key, or the unique key if the table does not have a primary key, for the table that was changed. +
+
It is possible to override the table's primary key by setting the xref:{context}-property-message-key-columns[`message.key.columns` connector configuration property]. In this case, the first schema field describes the structure of the key identified by that property.
|2
|`payload`
|The first `payload` field is part of the event key. It has the structure described by the previous `schema` field, and it contains the key for the row that was changed.
|3
|`schema`
|The second `schema` field is part of the event value. It specifies the Kafka Connect schema that describes what is in the event value's `payload` portion. In other words, the second `schema` describes the structure of the row that was changed. Typically, this schema contains nested schemas.
|4
|`payload`
|The second `payload` field is part of the event value. It has the structure described by the previous `schema` field and it contains the actual data for the row that was changed.
|===
By default, the connector streams change event records to topics with names that are the same as the event's originating table. See xref:{context}-topic-names[topic names].
[WARNING]
====
The {connector-name} connector ensures that all Kafka Connect schema names adhere to the link:http://avro.apache.org/docs/current/spec.html#names[Avro schema name format]. This means that the logical server name must start with a Latin letter or an underscore, that is, a-z, A-Z, or pass:[_]. Each remaining character in the logical server name and each character in the database and table names must be a Latin letter, a digit, or an underscore, that is, a-z, A-Z, 0-9, or pass:[_]. If there is an invalid character it is replaced with an underscore character.
This can lead to unexpected conflicts if the logical server name, a database name, or a table name contains invalid characters, and the only characters that distinguish names from one another are invalid and thus replaced with underscores.
====
ifdef::product[]
More details are in the following topics:
* xref:about-keys-in-debezium-{context}-change-events[]
* xref:about-values-in-debezium-{context}-change-events[]
endif::product[]
end::data-chg-events[]
=== Change event keys
tag::event-keys[]
A change event's key contains the schema for the changed table's key and the changed row's actual key. Both the schema and its corresponding payload contain a field for each column in the changed table's `PRIMARY KEY` (or unique constraint) at the time the connector created the event.
Consider the following `customers` table, which is followed by an example of a change event key for this table.
[source,sql]
----
CREATE TABLE customers (
id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE KEY
) AUTO_INCREMENT=1001;
----
Every change event that captures a change to the `customers` table has the same event key schema. For as long as the `customers` table has the previous definition, every change event that captures a change to the `customers` table has the following key structure. In JSON, it looks like this:
[source,json,index=0]
----
{
"schema": { <1>
"type": "struct",
"name": "{context}-server-1.inventory.customers.Key", <2>
"optional": false, <3>
"fields": [ <4>
{
"field": "id",
"type": "int32",
"optional": false
}
]
},
"payload": { <5>
"id": 1001
}
}
----
.Description of change event key
[cols="1,2,7",options="header"]
|===
|Item |Field name |Description
|1
|`schema`
|The schema portion of the key specifies a Kafka Connect schema that describes what is in the key's `payload` portion.
|2
|`{context}-server-1.inventory.customers.Key`
a|Name of the schema that defines the structure of the key's payload. This schema describes the structure of the primary key for the table that was changed. Key schema names have the format _connector-name_._database-name_._table-name_.`Key`. In this example: +
* `{context}-server-1` is the name of the connector that generated this event. +
* `inventory` is the database that contains the table that was changed. +
* `customers` is the table that was updated.
|3
|`optional`
|Indicates whether the event key must contain a value in its `payload` field. In this example, a value in the key's payload is required. A value in the key's payload field is optional when a table does not have a primary key.
|4
|`fields`
|Specifies each field that is expected in the `payload`, including each field's name, type, and whether it is required.
|5
|`payload`
|Contains the key for the row for which this change event was generated. In this example, the key, contains a single `id` field whose value is `1001`.
|===
end::event-keys[]
=== Change event values
tag::event-values[]
The value in a change event is a bit more complicated than the key. Like the key, the value has a `schema` section and a `payload` section. The `schema` section contains the schema that describes the `Envelope` structure of the `payload` section, including its nested fields. Change events for operations that create, update or delete data all have a value payload with an envelope structure.
Consider the same sample table that was used to show an example of a change event key:
[source,sql]
----
CREATE TABLE customers (
id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE KEY
) AUTO_INCREMENT=1001;
----
The value portion of a change event for a change to this table is described for:
* <<{context}-create-events,_create_ events>>
* <<{context}-update-events,_update_ events>>
* <<{context}-primary-key-updates,Primary key updates>>
* <<{context}-delete-events,_delete_ events>>
* <<{context}-tombstone-events,Tombstone events>>
* <<{context}-truncate-events,_truncate_ events>>
end::event-values[]
=== _create_ events
tag::create-events[]
The following example shows the value portion of a change event that the connector generates for an operation that creates data in the `customers` table:
[source,json,options="nowrap",subs="+attributes"]
----
{
"schema": { // <1>
"type": "struct",
"fields": [
{
"type": "struct",
"fields": [
{
"type": "int32",
"optional": false,
"field": "id"
},
{
"type": "string",
"optional": false,
"field": "first_name"
},
{
"type": "string",
"optional": false,
"field": "last_name"
},
{
"type": "string",
"optional": false,
"field": "email"
}
],
"optional": true,
"name": "{context}-server-1.inventory.customers.Value", // <2>
"field": "before"
},
{
"type": "struct",
"fields": [
{
"type": "int32",
"optional": false,
"field": "id"
},
{
"type": "string",
"optional": false,
"field": "first_name"
},
{
"type": "string",
"optional": false,
"field": "last_name"
},
{
"type": "string",
"optional": false,
"field": "email"
}
],
"optional": true,
"name": "{context}-server-1.inventory.customers.Value",
"field": "after"
},
{
"type": "struct",
"fields": [
{
"type": "string",
"optional": false,
"field": "version"
},
{
"type": "string",
"optional": false,
"field": "connector"
},
{
"type": "string",
"optional": false,
"field": "name"
},
{
"type": "int64",
"optional": false,
"field": "ts_ms"
},
{
"type": "int64",
"optional": false,
"field": "ts_us"
},
{
"type": "int64",
"optional": false,
"field": "ts_ns"
},
{
"type": "boolean",
"optional": true,
"default": false,
"field": "snapshot"
},
{
"type": "string",
"optional": false,
"field": "db"
},
{
"type": "string",
"optional": true,
"field": "table"
},
{
"type": "int64",
"optional": false,
"field": "server_id"
},
{
"type": "string",
"optional": true,
"field": "gtid"
},
{
"type": "string",
"optional": false,
"field": "file"
},
{
"type": "int64",
"optional": false,
"field": "pos"
},
{
"type": "int32",
"optional": false,
"field": "row"
},
{
"type": "int64",
"optional": true,
"field": "thread"
},
{
"type": "string",
"optional": true,
"field": "query"
}
],
"optional": false,
"name": "io.debezium.connector.{context}.Source", // <3>
"field": "source"
},
{
"type": "string",
"optional": false,
"field": "op"
},
{
"type": "int64",
"optional": true,
"field": "ts_ms"
},
{
"type": "int64",
"optional": true,
"field": "ts_us"
},
{
"type": "int64",
"optional": true,
"field": "ts_ns"
}
],
"optional": false,
"name": "{context}-server-1.inventory.customers.Envelope" // <4>
},
"payload": { // <5>
"op": "c", // <6>
"ts_ms": 1465491411815, // <7>
"ts_us": 1465491411815437, // <7>
"ts_ns": 1465491411815437158, // <7>
"before": null, // <8>
"after": { // <9>
"id": 1004,
"first_name": "Anne",
"last_name": "Kretchmar",
"email": "annek@noanswer.org"
},
"source": { // <10>
"version": "{debezium-version}",
"connector": "{context}",
"name": "{context}-server-1",
"ts_ms": 0,
"ts_us": 0,
"ts_ns": 0,
"snapshot": false,
"db": "inventory",
"table": "customers",
"server_id": 0,
"gtid": null,
"file": "{context}-bin.000003",
"pos": 154,
"row": 0,
"thread": 7,
"query": "INSERT INTO customers (first_name, last_name, email) VALUES ('Anne', 'Kretchmar', 'annek@noanswer.org')"
}
}
}
----
.Descriptions of _create_ event value fields
[cols="1,2,7",options="header"]
|===
|Item |Field name |Description
|1
|`schema`
|The value's schema, which describes the structure of the value's payload.
A change event's value schema is the same in every change event that the connector generates for a particular table.
|2
|`name`
a|In the `schema` section, each `name` field specifies the schema for a field in the value's payload. +
+
`{context}-server-1.inventory.customers.Value` is the schema for the payload's `before` and `after` fields.
This schema is specific to the `customers` table. +
+
Names of schemas for `before` and `after` fields are of the form `_logicalName_._tableName_.Value`, which ensures that the schema name is unique in the database.
This means that when using the {link-prefix}:{link-avro-serialization}#avro-serialization[Avro converter], the resulting Avro schema for each table in each logical source has its own evolution and history.
|3
|`name`
|`io.debezium.connector.{context}.Source` is the schema for the payload's `source` field.
This schema is specific to the {connector-name} connector.
The connector uses it for all events that it generates.
|4
|`name`
|`{context}-server-1.inventory.customers.Envelope` is the schema for the overall structure of the payload, where `{context}-server-1` is the connector name, `inventory` is the database, and `customers` is the table.
|5
|`payload`
|The value's actual data.
This is the information that the change event is providing. +
+
It may appear that the JSON representations of the events are much larger than the rows they describe.
This is because the JSON representation must include the schema and the payload portions of the message.
However, by using the {link-prefix}:{link-avro-serialization}#avro-serialization[Avro converter], you can significantly decrease the size of the messages that the connector streams to Kafka topics.
|6
|`op`
a| Mandatory string that describes the type of operation that caused the connector to generate the event.
In this example, `c` indicates that the operation created a row. Valid values are:
* `c` = create
* `u` = update
* `d` = delete
* `r` = read (applies to only snapshots)
|7
|`ts_ms`, `ts_us`, `ts_ns`
a| Optional field that displays the time at which the connector processed the event.
The time is based on the system clock in the JVM running the Kafka Connect task. +
+
In the `source` object, `ts_ms` indicates the time that the change was made in the database.
By comparing the value for `payload.source.ts_ms` with the value for `payload.ts_ms`, you can determine the lag between the source database update and {prodname}.
|8
|`before`
| An optional field that specifies the state of the row before the event occurred.
When the `op` field is `c` for create, as it is in this example, the `before` field is `null` since this change event is for new content.
|9
|`after`
| An optional field that specifies the state of the row after the event occurred.
In this example, the `after` field contains the values of the new row's `id`, `first_name`, `last_name`, and `email` columns.
|10
|`source`
a| Mandatory field that describes the source metadata for the event.
This field contains information that you can use to compare this event with other events, with regard to the origin of the events, the order in which the events occurred, and whether events were part of the same transaction. The source metadata includes:
* {prodname} version
* Connector name
* binlog name where the event was recorded
* binlog position
* Row within the event
* If the event was part of a snapshot
* Name of the database and table that contain the new row
* ID of the {connector-name} thread that created the event (non-snapshot only)
* {connector-name} server ID (if available)
* Timestamp for when the change was made in the database
ifdef::MARIADB[]
If the xref:enable-query-log-events[`binlog_annotate_row_events`] MariaDB configuration option is enabled and the connector configuration `include.query` property is enabled, the `source` field also provides the `query` field, which contains the original SQL statement that caused the change event.
endif::MARIADB[]
|===
end::create-events[]
=== _update_ events
tag::update-events[]
The value of a change event for an update in the sample `customers` table has the same schema as a _create_ event for that table. Likewise, the event value's payload has the same structure. However, the event value payload contains different values in an _update_ event. Here is an example of a change event value in an event that the connector generates for an update in the `customers` table:
[source,json,options="nowrap",subs="+attributes"]
----
{
"schema": { ... },
"payload": {
"before": { // <1>
"id": 1004,
"first_name": "Anne",
"last_name": "Kretchmar",
"email": "annek@noanswer.org"
},
"after": { // <2>
"id": 1004,
"first_name": "Anne Marie",
"last_name": "Kretchmar",
"email": "annek@noanswer.org"
},
"source": { // <3>
"version": "{debezium-version}",
"name": "{context}-server-1",
"connector": "{context}",
"name": "{context}-server-1",
"ts_ms": 1465581029100,
"ts_ms": 1465581029100000,
"ts_ms": 1465581029100000000,
"snapshot": false,
"db": "inventory",
"table": "customers",
"server_id": 223344,
"gtid": null,
"file": "{context}-bin.000003",
"pos": 484,
"row": 0,
"thread": 7,
"query": "UPDATE customers SET first_name='Anne Marie' WHERE id=1004"
},
"op": "u", // <4>
"ts_ms": 1465581029523, // <5>
"ts_ms": 1465581029523758, // <6>
"ts_ms": 1465581029523758914 // <7>
}
}
----
.Descriptions of _update_ event value fields
[cols="1,2,7",options="header"]
|===
|Item |Field name |Description
|1
|`before`
|An optional field that specifies the state of the row before the event occurred. In an _update_ event value, the `before` field contains a field for each table column and the value that was in that column before the database commit. In this example, the `first_name` value is `Anne.`
|2
|`after`
| An optional field that specifies the state of the row after the event occurred. You can compare the `before` and `after` structures to determine what the update to this row was. In the example, the `first_name` value is now `Anne Marie`.
|3
|`source`
a|Mandatory field that describes the source metadata for the event. The `source` field structure has the same fields as in a _create_ event, but some values are different, for example, the sample _update_ event is from a different position in the binlog. The source metadata includes:
* {prodname} version
* Connector name
* binlog name where the event was recorded
* binlog position
* Row within the event
* If the event was part of a snapshot
* Name of the database and table that contain the updated row
* ID of the {connector-name} thread that created the event (non-snapshot only)
* {connector-name} server ID (if available)
* Timestamp for when the change was made in the database
ifdef::MARIADB[]
If the xref:enable-query-log-events[`binlog_annotate_row_events`] MariaDB configuration option is enabled and the connector configuration `include.query` property is enabled, the `source` field also provides the `query` field, which contains the original SQL statement that caused the change event.
endif::MARIADB[]
|4
|`op`
a|Mandatory string that describes the type of operation. In an _update_ event value, the `op` field value is `u`, signifying that this row changed because of an update.
|5
|`ts_ms`
a| Optional field that displays the time at which the connector processed the event.
The time is based on the system clock in the JVM running the Kafka Connect task. +
+
In the `source` object, `ts_ms` indicates the time that the change was made in the database. By comparing the value for `payload.source.ts_ms` with the value for `payload.ts_ms`, you can determine the lag between the source database update and {prodname}.
|6
|`ts_us`
a|Optional field that displays the time at which the connector processed the event, in microseconds.
The time is based on the system clock in the JVM running the Kafka Connect task.
|7
|`ts_ns`
a|Optional field that displays the time at which the connector processed the event, in nanoseconds.
The time is based on the system clock in the JVM running the Kafka Connect task.
|===
[NOTE]
====
Updating the columns for a row's primary/unique key changes the value of the row's key. When a key changes, {prodname} outputs _three_ events: a `DELETE` event and a xref:{context}-tombstone-events[tombstone event] with the old key for the row, followed by an event with the new key for the row. Details are in the next section.
====
end::update-events[]
=== Primary key updates
tag::pkey-updates[]
An `UPDATE` operation that changes a row's primary key field(s) is known
as a primary key change. For a primary key change, in place of an `UPDATE` event record, the connector emits a `DELETE` event record for the old key and a `CREATE` event record for the new (updated) key. These events have the usual structure and content, and in addition, each one has a message header related to the primary key change:
* The `DELETE` event record has `__debezium.newkey` as a message header. The value of this header is the new primary key for the updated row.
* The `CREATE` event record has `__debezium.oldkey` as a message header. The value of this header is the previous (old) primary key that the updated row had.
end::pkey-updates[]
=== _delete_ events
tag::del-events[]
The value in a _delete_ change event has the same `schema` portion as _create_ and _update_ events for the same table. The `payload` portion in a _delete_ event for the sample `customers` table looks like this:
[source,json,options="nowrap",subs="+attributes"]
----
{
"schema": { ... },
"payload": {
"before": { // <1>
"id": 1004,
"first_name": "Anne Marie",
"last_name": "Kretchmar",
"email": "annek@noanswer.org"
},
"after": null, // <2>
"source": { // <3>
"version": "{debezium-version}",
"connector": "{context}",
"name": "{context}-server-1",
"ts_ms": 1465581902300,
"ts_us": 1465581902300000,
"ts_ns": 1465581902300000000,
"snapshot": false,
"db": "inventory",
"table": "customers",
"server_id": 223344,
"gtid": null,
"file": "{context}-bin.000003",
"pos": 805,
"row": 0,
"thread": 7,
"query": "DELETE FROM customers WHERE id=1004"
},
"op": "d", // <4>
"ts_ms": 1465581902461, // <5>
"ts_us": 1465581902461842, // <6>
"ts_ns": 1465581902461842579 // <7>
}
}
----
.Descriptions of _delete_ event value fields
[cols="1,2,7",options="header"]
|===
|Item |Field name |Description
|1
|`before`
|Optional field that specifies the state of the row before the event occurred. In a _delete_ event value, the `before` field contains the values that were in the row before it was deleted with the database commit.
|2
|`after`
| Optional field that specifies the state of the row after the event occurred. In a _delete_ event value, the `after` field is `null`, signifying that the row no longer exists.
|3
|`source`
a|Mandatory field that describes the source metadata for the event. In a _delete_ event value, the `source` field structure is the same as for _create_ and _update_ events for the same table. Many `source` field values are also the same. In a _delete_ event value, the `ts_ms` and `pos` field values, as well as other values, might have changed. But the `source` field in a _delete_ event value provides the same metadata:
* {prodname} version
* Connector name
* binlog name where the event was recorded
* binlog position
* Row within the event
* If the event was part of a snapshot
* Name of the database and table that contain the updated row
* ID of the {connector-name} thread that created the event (non-snapshot only)
* {connector-name} server ID (if available)
* Timestamp for when the change was made in the database
ifdef::MARIADB[]
If the xref:enable-query-log-events[`binlog_annotate_row_events`] MariaDB configuration option is enabled and the connector configuration `include.query` property is enabled, the `source` field also provides the `query` field, which contains the original SQL statement that caused the change event.
endif::MARIADB[]
|4
|`op`
a|Mandatory string that describes the type of operation. The `op` field value is `d`, signifying that this row was deleted.
|5
|`ts_ms`
a|Optional field that displays the time at which the connector processed the event.
The time is based on the system clock in the JVM running the Kafka Connect task. +
+
In the `source` object, `ts_ms` indicates the time that the change was made in the database. By comparing the value for `payload.source.ts_ms` with the value for `payload.ts_ms`, you can determine the lag between the source database update and {prodname}.
|6
|`ts_us`
a|Optional field that displays the time at which the connector processed the event, in microseconds.
The time is based on the system clock in the JVM running the Kafka Connect task.
|7
|`ts_ns`
a|Optional field that displays the time at which the connector processed the event, in nanoseconds.
The time is based on the system clock in the JVM running the Kafka Connect task.
|===
A _delete_ change event record provides a consumer with the information it needs to process the removal of this row. The old values are included because some consumers might require them in order to properly handle the removal.
{connector-name} connector events are designed to work with link:{link-kafka-docs}/#compaction[Kafka log compaction]. Log compaction enables removal of some older messages as long as at least the most recent message for every key is kept. This lets Kafka reclaim storage space while ensuring that the topic contains a complete data set and can be used for reloading key-based state.
end::del-events[]
=== Tombstone events
tag::tombstone-events[]
When a row is deleted, the _delete_ event value still works with log compaction, because Kafka can remove all earlier messages that have that same key.
However, for Kafka to remove all messages that have that same key, the message value must be `null`.
To make this possible, after the {prodname} {connector-name} connector emits a _delete_ event, the connector emits a special tombstone event that has the same key but a `null` value.
end::tombstone-events[]
=== _truncate_ events
tag::truncate-events[]
A _truncate_ change event signals that a table has been truncated.
The message key is `null` in this case, the message value looks like this:
[source,json,indent=0,subs="+attributes"]
----
{
"schema": { ... },
"payload": {
"source": { // <1>
"version": "{debezium-version}",
"name": "{context}-server-1",
"connector": "{context}",
"name": "{context}-server-1",
"ts_ms": 1465581029100,
"ts_us": 1465581029100000,
"ts_ns": 1465581029100000000,
"snapshot": false,
"db": "inventory",
"table": "customers",
"server_id": 223344,
"gtid": null,
"file": "{context}-bin.000003",
"pos": 484,
"row": 0,
"thread": 7,
"query": "UPDATE customers SET first_name='Anne Marie' WHERE id=1004"
},
"op": "t", // <2>
"ts_ms": 1465581029523, // <3>
"ts_us": 1465581029523468, // <4>
"ts_ns": 1465581029523468471 // <5>
}
}
----
.Descriptions of _truncate_ event value fields
[cols="1,2,7",options="header"]
|===
|Item |Field name |Description
|1
|`source`
a|Mandatory field that describes the source metadata for the event. In a _truncate_ event value, the `source` field structure is the same as for _create_, _update_, and _delete_ events for the same table, provides this metadata:
* {prodname} version
* Connector type and name
* Binlog name where the event was recorded
* Binlog position
* Row within the event
* If the event was part of a snapshot
* Name of the database and table
* ID of the {connector-name} thread that truncated the event (non-snapshot only)
* {connector-name} server ID (if available)
* Timestamp for when the change was made in the database
|2
|`op`
a|Mandatory string that describes the type of operation. The `op` field value is `t`, signifying that this table was truncated.
|3
|`ts_ms`
a|Optional field that displays the time at which the connector processed the event.
The time is based on the system clock in the JVM running the Kafka Connect task. +
+
In the `source` object, `ts_ms` indicates the time that the change was made in the database. By comparing the value for `payload.source.ts_ms` with the value for `payload.ts_ms`, you can determine the lag between the source database update and {prodname}.
|4
|`ts_us`
a|Optional field that displays the time at which the connector processed the event, in microseconds. The time is based on the system clock in the JVM running the Kafka Connect task.
|5
|`ts_ns`
a|Optional field that displays the time at which the connector processed the event, in nanoseconds. The time is based on the system clock in the JVM running the Kafka Connect task.
|===
In case a single `TRUNCATE` statement applies to multiple tables,
one _truncate_ change event record for each truncated table will be emitted.
[NOTE]
====
A _truncate_ event represents a change that applies to an entire table, and it does not have a message key.
In topics that span multiple partition, the order of change events that apply to an entire table is is not guaranteed.
That is, there is no ordering guarantee for (_create_, _update_, etc.), or for the _truncate_ events for that table.
When a consumer reads events from different partition, it might read an _update_ event for a table from one partition only after it reads a _truncate_ event for the same table from a second partition.
====
end::truncate-events[]
== Data type mappings
tag::data-type-mappings[]
The {prodname} {connector-name} connector represents changes to rows with events that are structured like the table in which the row exists. The event contains a field for each column value.
The {connector-name} data type of that column dictates how {prodname} represents the value in the event.
Columns that store strings are defined in {connector-name} with a character set and collation.
The {connector-name} connector uses the column's character set when reading the binary representation of the column values in the binlog events.
The connector can map {connector-name} data types to both _literal_ and _semantic_ types.
* *Literal type*: how the value is represented using Kafka Connect schema types.
* *Semantic type*: how the Kafka Connect schema captures the meaning of the field (schema name).
If the default data type conversions do not meet your needs, you can {link-prefix}:{link-custom-converters}#custom-converters[create a custom converter] for the connector.
ifdef::product[]
Details are in the following sections:
* xref:{context}-basic-types[]
* xref:{context}-temporal-types[]
* xref:{context}-decimal-types[]
* xref:{context}-boolean-values[]
* xref:{context}-spatial-types[]
endif::product[]
end::data-type-mappings[]
=== Basic types
tag::basic-data-types[]
The following table shows how the connector maps basic {connector-name} data types.
.Descriptions of basic type mappings
[cols="25%a,20%a,55%a",options="header",subs="+attributes"]
|===
|{connector-name} type |Literal type |Semantic type
|`BOOLEAN, BOOL`
|`BOOLEAN`
a|_n/a_
|`BIT(1)`
|`BOOLEAN`
a|_n/a_
|`BIT(>1)`
|`BYTES`
a|`io.debezium.data.Bits` +
+
The `length` schema parameter contains an integer that represents the number of bits. The `byte[]` contains the bits in _little-endian_ form and is sized to contain the specified number of bits. For example, where `n` is bits: +
`numBytes = n/8 + (n%8== 0 ? 0 : 1)`
|`TINYINT`
|`INT16`
a|_n/a_
|`SMALLINT[(M)]`
|`INT16`
a|_n/a_
|`MEDIUMINT[(M)]`
|`INT32`
a|_n/a_
|`INT, INTEGER[(M)]`
|`INT32`
a|_n/a_
|`BIGINT[(M)]`
|`INT64`
a|_n/a_
|`REAL[(M,D)]`
|`FLOAT32`
a|_n/a_
|`FLOAT[(P)]`
|`FLOAT32` or `FLOAT64`
a|The precision is used only to determine storage size.
A precision `P` from 0 to 23 results in a 4-byte single-precision `FLOAT32` column.
A precision `P` from 24 to 53 results in an 8-byte double-precision `FLOAT64` column.
ifdef::MARIADB[]
|`FLOAT(M,D)`
|`FLOAT64`
a|_n/a_
endif::MARIADB[]
|`DOUBLE[(M,D)]`
|`FLOAT64`
a|_n/a_
|`CHAR(M)]`
|`STRING`
a|_n/a_
|`VARCHAR(M)]`
|`STRING`
a|_n/a_
|`BINARY(M)]`
|`BYTES` or `STRING`
a|_n/a_ +
+
Either the raw bytes (the default), a base64-encoded String, or a base64-url-safe-encoded String, or a hex-encoded String, based on the xref:{context}-property-binary-handling-mode[`binary.handling.mode`] connector configuration property setting.
|`VARBINARY(M)]`
|`BYTES` or `STRING`
a|_n/a_ +
+
Either the raw bytes (the default), a base64-encoded String, or a base64-url-safe-encoded String, or a hex-encoded String, based on the xref:{context}-property-binary-handling-mode[`binary.handling.mode`] connector configuration property setting.
|`TINYBLOB`
|`BYTES` or `STRING`
a|_n/a_ +
+
Either the raw bytes (the default), a base64-encoded String, or a base64-url-safe-encoded String, or a hex-encoded String, based on the xref:{context}-property-binary-handling-mode[`binary.handling.mode`] connector configuration property setting.
|`TINYTEXT`
|`STRING`
a|_n/a_
|`BLOB`
|`BYTES` or `STRING`
a|_n/a_ +
+
Either the raw bytes (the default), a base64-encoded String, or a base64-url-safe-encoded String, or a hex-encoded String, based on the xref:{context}-property-binary-handling-mode[`binary.handling.mode`] connector configuration property setting. +
+
Only values with a size of up to 2GB are supported. It is recommended to externalize large column values, using the claim check pattern.
|`TEXT`
|`STRING`
a|_n/a_ +
+
Only values with a size of up to 2GB are supported. It is recommended to externalize large column values, using the claim check pattern.
|`MEDIUMBLOB`
|`BYTES` or `STRING`
a|_n/a_ +
+
Either the raw bytes (the default), a base64-encoded String, or a base64-url-safe-encoded String, or a hex-encoded String, based on the xref:{context}-property-binary-handling-mode[`binary.handling.mode`] connector configuration property setting.
|`MEDIUMTEXT`
|`STRING`
a|_n/a_
|`LONGBLOB`
|`BYTES` or `STRING`
a|_n/a_ +
+
Either the raw bytes (the default), a base64-encoded String, or a base64-url-safe-encoded String, or a hex-encoded String, based on the xref:{context}-property-binary-handling-mode[`binary.handling.mode`] connector configuration property setting. +
+
Only values with a size of up to 2GB are supported. It is recommended to externalize large column values, using the claim check pattern.
|`LONGTEXT`
|`STRING`
a|_n/a_ +
+
Only values with a size of up to 2GB are supported. It is recommended to externalize large column values, using the claim check pattern.
|`JSON`
|`STRING`
a|`io.debezium.data.Json` +
+
Contains the string representation of a `JSON` document, array, or scalar.
|`ENUM`
|`STRING`
a|`io.debezium.data.Enum` +
+
The `allowed` schema parameter contains the comma-separated list of allowed values.
|`SET`
|`STRING`
a|`io.debezium.data.EnumSet` +
+
The `allowed` schema parameter contains the comma-separated list of allowed values.
|`YEAR[(2\|4)]`
|`INT32`
|`io.debezium.time.Year`
|`TIMESTAMP[(M)]`
|`STRING`
a|`io.debezium.time.ZonedTimestamp` +
+
In link:https://www.iso.org/iso-8601-date-and-time-format.html[ISO 8601] format with microsecond precision.
{connector-name} allows `M` to be in the range of `0-6`.
|===
end::basic-data-types[]
=== Temporal types
tag::temporal-data-types[]
Excluding the `TIMESTAMP` data type, {connector-name} temporal types depend on the value of the `time.precision.mode` connector configuration property. For `TIMESTAMP` columns whose default value is specified as `CURRENT_TIMESTAMP` or `NOW`, the value `1970-01-01 00:00:00` is used as the default value in the Kafka Connect schema.
{connector-name} allows zero-values for `DATE`, `DATETIME`, and `TIMESTAMP` columns because zero-values are sometimes preferred over null values.
The {connector-name} connector represents zero-values as null values when the column definition allows null values, or as the epoch day when the column does not allow null values.
.Temporal values without time zones
The `DATETIME` type represents a local date and time such as "2018-01-13 09:48:27". As you can see, there is no time zone information. Such columns are converted into epoch milliseconds or microseconds based on the columns precision by using UTC.
The `TIMESTAMP` type represents a timestamp without time zone information.
It is converted by {connector-name} from the server (or sessions) current time zone into UTC when writing and from UTC into the server (or session's) current time zone when reading back the value. For example:
* `DATETIME` with a value of `2018-06-20 06:37:03` becomes `1529476623000`.
* `TIMESTAMP` with a value of `2018-06-20 06:37:03` becomes `2018-06-20T13:37:03Z`.
Such columns are converted into an equivalent `io.debezium.time.ZonedTimestamp` in UTC based on the server (or sessions) current time zone.
The time zone will be queried from the server by default.
ifdef::MARIADB[]
If this fails, it must be specified explicitly by the database `timezone` {connector-name} configuration option.
For example, if the databases time zone (either globally or configured for the connector by means of the `timezone` option) is "America/Los_Angeles", the TIMESTAMP value "2018-06-20 06:37:03" is represented by a `ZonedTimestamp` with the value "2018-06-20T13:37:03Z".
endif::MARIADB[]
The time zone of the JVM running Kafka Connect and {prodname} does not affect these conversions.
More details about properties related to temporal values are in the documentation for xref:{context}-connector-properties[{connector-name} connector configuration properties].
time.precision.mode=adaptive_time_microseconds(default)::
The {connector-name} connector determines the literal type and semantic type based on the column's data type definition so that events represent exactly the values in the database. All time fields are in microseconds. Only positive `TIME` field values in the range of `00:00:00.000000` to `23:59:59.999999` can be captured correctly.
+
.Mappings when `time.precision.mode=adaptive_time_microseconds`
[cols="25%a,20%a,55%a",options="header",subs="+attributes"]
|===
|{connector-name} type |Literal type |Semantic type
|`DATE`
|`INT32`
a|`io.debezium.time.Date` +
Represents the number of days since the epoch.
|`TIME[(M)]`
|`INT64`
a|`io.debezium.time.MicroTime` +
Represents the time value in microseconds and does not include time zone information.
{connector-name} allows `M` to be in the range of `0-6`.
|`DATETIME, DATETIME(0), DATETIME(1), DATETIME(2), DATETIME(3)`
|`INT64`
a|`io.debezium.time.Timestamp` +
Represents the number of milliseconds past the epoch and does not include time zone information.
|`DATETIME(4), DATETIME(5), DATETIME(6)`
|`INT64`
a|`io.debezium.time.MicroTimestamp` +
Represents the number of microseconds past the epoch and does not include time zone information.
|===
time.precision.mode=connect::
The {connector-name} connector uses defined Kafka Connect logical types. This approach is less precise than the default approach and the events could be less precise if the database column has a _fractional second precision_ value of greater than `3`. Values in only the range of `00:00:00.000` to `23:59:59.999` can be handled. Set `time.precision.mode=connect` only if you can ensure that the `TIME` values in your tables never exceed the supported ranges. The `connect` setting is expected to be removed in a future version of {prodname}.
+
.Mappings when `time.precision.mode=connect`
[cols="25%a,20%a,55%a",options="header",subs="+attributes"]
|===
|{connector-name} type |Literal type |Semantic type
|`DATE`
|`INT32`
a|`org.apache.kafka.connect.data.Date` +
Represents the number of days since the epoch.
|`TIME[(M)]`
|`INT64`
a|`org.apache.kafka.connect.data.Time` +
Represents the time value in microseconds since midnight and does not include time zone information.
|`DATETIME[(M)]`
|`INT64`
a|`org.apache.kafka.connect.data.Timestamp` +
Represents the number of milliseconds since the epoch, and does not include time zone information.
|===
end::temporal-types-cont[]
=== Decimal types
tag::decimal-data-types[]
{prodname} connectors handle decimals according to the setting of the xref:{context}-property-decimal-handling-mode[`decimal.handling.mode`] connector configuration property.
decimal.handling.mode=precise::
+
.Mappings when `decimal.handling.mode=precise`
[cols="30%a,15%a,55%a",options="header",subs="+attributes"]
|===
|{connector-name} type |Literal type |Semantic type
|`NUMERIC[(M[,D])]`
|`BYTES`
a|`org.apache.kafka.connect.data.Decimal` +
The `scale` schema parameter contains an integer that represents how many digits the decimal point shifted.
|`DECIMAL[(M[,D])]`
|`BYTES`
a|`org.apache.kafka.connect.data.Decimal` +
The `scale` schema parameter contains an integer that represents how many digits the decimal point shifted.
|===
decimal.handling.mode=double::
+
.Mappings when `decimal.handling.mode=double`
[cols="30%a,30%a,40%a",options="header",subs="+attributes"]
|===
|{connector-name} type |Literal type |Semantic type
|`NUMERIC[(M[,D])]`
|`FLOAT64`
a|_n/a_
|`DECIMAL[(M[,D])]`
|`FLOAT64`
a|_n/a_
|===
decimal.handling.mode=string::
+
.Mappings when `decimal.handling.mode=string`
[cols="30%a,30%a,40%a",options="header",subs="+attributes"]
|===
|{connector-name} type |Literal type |Semantic type
|`NUMERIC[(M[,D])]`
|`STRING`
a|_n/a_
|`DECIMAL[(M[,D])]`
|`STRING`
a|_n/a_
|===
end::decimal-data-types[]
=== Boolean values
tag::boolean-values[]
{connector-name} handles the `BOOLEAN` value internally in a specific way.
The `BOOLEAN` column is internally mapped to the `TINYINT(1)` data type.
When the table is created during streaming then it uses proper `BOOLEAN` mapping as {prodname} receives the original DDL.
During snapshots, {prodname} executes `SHOW CREATE TABLE` to obtain table definitions that return `TINYINT(1)` for both `BOOLEAN` and `TINYINT(1)` columns. {prodname} then has no way to obtain the original type mapping and so maps to `TINYINT(1)`.
To enable you to convert source columns to Boolean data types, {prodname} provides a `TinyIntOneToBooleanConverter` {link-prefix}:{link-custom-converters}#custom-converters[custom converter] that you can use in one of the following ways:
* Map all `TINYINT(1)` or `TINYINT(1) UNSIGNED` columns to `BOOLEAN` types.
* Enumerate a subset of columns by using a comma-separated list of regular expressions. +
To use this type of conversion, you must set the xref:{context}-property-converters[`converters`] configuration property with the `selector` parameter, as shown in the following example:
+
[source]
----
converters=boolean
boolean.type=io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter
boolean.selector=db1.table1.*, db1.table2.column1
----
* NOTE: In some cases, the database may not show the length of `tinyint unsigned` when the snapshot executes `SHOW CREATE TABLE`, which means this converter doesn't work. The new option `length.checker` can solve this issue, the default value is `true`. Disable the `length.checker` and specify the columns that need to be converted to `selected` property instead of converting all columns based on type, as shown in the following example:
+
[source]
----
converters=boolean
boolean.type=io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter
boolean.length.checker=false
boolean.selector=db1.table1.*, db1.table2.column1
----
end::boolean-values[]
=== Spatial types
tag::spatial-data-types[]
Currently, the {prodname} {connector-name} connector supports the following spatial data types.
.Description of spatial type mappings
[cols="35%a,15%a,50%a",options="header",subs="+attributes"]
|===
|{connector-name} type |Literal type |Semantic type
|`GEOMETRY, +
LINESTRING, +
POLYGON, +
MULTIPOINT, +
MULTILINESTRING, +
MULTIPOLYGON, +
GEOMETRYCOLLECTION`
|`STRUCT`
a|`io.debezium.data.geometry.Geometry` +
Contains a structure with two fields:
* `srid (INT32`: spatial reference system ID that defines the type of geometry object stored in the structure
* `wkb (BYTES)`: binary representation of the geometry object encoded in the Well-Known-Binary (wkb) format. See the link:https://www.opengeospatial.org/standards/sfa[Open Geospatial Consortium] for more details.
|===
end::spatial-data-types[]
== Custom converters
tag::custom-converters[]
By default, the {prodname} {connector-name} connector provides several `CustomConverter` implementations for {connector-name} data types.
These custom converters provide alternative mappings for specific data types based on the connector configuration.
To add a `CustomConverter` to the connector, follow the instructions in the {link-prefix}:{link-custom-converters}#custom-converters[Custom Converters documentation].
end::custom-converters[]
=== `TINYINT(1)` to Boolean
tag::tinyint-boolean-conv[]
By default, during a connector snapshot, the {prodname} {connector-name} connector obtains column types from the JDBC driver, which assigns the `TINYINT(1)` type to `BOOLEAN` columns.
{prodname} then uses these JDBC column types to define the schema for the snapshot events.
After the connector transitions from the snapshot to the streaming phase, the change event schema that results from the default mapping can lead to inconsistent mappings for `BOOLEAN` columns.
To help ensure that {connector-name} emits `BOOLEAN` columns uniformly, you can apply the custom `TinyIntOneToBooleanConverter`, as shown in the following configuration example.
.Example: `TinyIntOneToBooleanConverter` configuration
[source]
----
converters=tinyint-one-to-boolean
converters.tinyint-one-to-boolean.type=io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter
converters.tinyint-one-to-boolean.selector=.*.MY_TABLE.DATA
converters.tinyint-one-to-boolean.length.checker=false
----
In the preceding example, the `selector` and `length.checker` properties are optional.
By default, the converter checks that `TINYINT` data types conform to a length of `1`.
If `length.checker` to `false`, the converter does not explicitly confirm that the `TINYINT` data type conforms to a length of `1`.
The `selector` designates the tables or columns to convert, based on the supplied regular expression.
If you omit the `selector` property, the converter maps all `TINYINT` columns to logical `BOOL` field types.
If you do not configure a `selector` option, and you want to map `TINYINT` columns to `TINYINT(1)`, omit the `length.checker` property, or set its value to `true`.
end::tinyint-boolean-conv[]
=== JDBC sink data types
tag::jdbc-sink-data-types[]
If you integrate the {prodname} JDBC sink connector with a {prodname} {connector-name} source connector, the {connector-name} connector emits some column attributes differently during the snapshot and streaming phases.
For the JDBC sink connector to consistently consume changes from both the snapshot and streaming phase, you must include the `JdbcSinkDataTypesConverter` converter as part of the {connector-name} source connector configuration, as shown in the following example:
.Example: `JdbcSinkDataTypesConverter` configuration
[source]
----
converters=jdbc-sink
converters.jdbc-sink.type=io.debezium.connector.binlog.converters.JdbcSinkDataTypesConverter
converters.jdbc-sink.selector.boolean=.*.MY_TABLE.BOOL_COL
converters.jdbc-sink.selector.real=.*.MY_TABLE.REAL_COL
converters.jdbc-sink.selector.string=.*.MY_TABLE.STRING_COL
converters.jdbc-sink.treat.real.as.double=true
----
In the preceding example, the `selector.*` and `treat.real.as.double` configuration properties are optional.
The `selector.*` properties specify comma-separated lists of regular expressions that specify which tables and columns that the converter applies to.
By default, the converter applies the following rules apply to all Boolean, real, and string-based column data types, across all tables:
* `BOOLEAN` data types are always emitted as `INT16` logical types, with `1` representing `true` and `0` representing `false`
* `REAL` data types are always emitted as `FLOAT64` logical types.
* String-based columns always include the `__debezium.source.column.character_set` schema parameter that contains the column's character set.
For each data type, you can configure a selector rule to override the default scope and apply the selector to specific tables and columns only.
For example, to set the scope of the Boolean converter, add the following rule to the connector configuration, as in the preceding example: `converters.jdbc-sink.selector.boolean=.*.MY_TABLE.BOOL_COL`
end::jdbc-sink-data-types[]
== Setting up the database
tag::setting-up-db[]
Some {connector-name} setup tasks are required before you can install and run a {prodname} connector.
ifdef::product[]
Details are in the following sections:
* xref:creating-a-{context}-user-for-a-debezium-connector[]
* xref:enabling-the-{context}-binlog-for-debezium[]
* xref:enabling-{context}-gtids-for-debezium[]
* xref:configuring-{context}-session-timeouts-for-debezium[]
* xref:enabling-query-log-events-for-debezium-{context}-connectors[]
endif::product[]
end::setting-up-db[]
=== Creating a user
tag::creating-a-db-user[]
A {prodname} {connector-name} connector requires a {connector-name} user account.
This {connector-name} user must have appropriate permissions on all databases for which the {prodname} {connector-name} connector captures changes.
.Prerequisites
* A {connector-name} server.
* Basic knowledge of SQL commands.
.Procedure
. Create the {connector-name} user:
+
[source,SQL]
----
{context}> CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
----
. Grant the required permissions to the user:
+
[source,SQL]
----
{context}> GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'user' IDENTIFIED BY 'password';
----
+
For a description of the required permissions, see xref:permissions-explained-{context}-connector[].
+
IMPORTANT: If using a hosted option such as Amazon RDS or Amazon Aurora that does not allow a global read lock, table-level locks are used to create the _consistent snapshot_. In this case, you need to also grant `LOCK TABLES` permissions to the user that you create. See xref:{context}-snapshots[snapshots] for more details.
. Finalize the user's permissions:
+
[source,SQL]
----
{context}> FLUSH PRIVILEGES;
----
[[permissions-explained-{context}-connector]]
.Descriptions of user permissions
[cols="3,7",options="header",subs="+attributes"]
|===
|Keyword |Description
|`SELECT`
|Enables the connector to select rows from tables in databases. This is used only when performing a snapshot.
|`RELOAD`
|Enables the connector the use of the `FLUSH` statement to clear or reload internal caches, flush tables, or acquire locks. This is used only when performing a snapshot.
|`SHOW DATABASES`
|Enables the connector to see database names by issuing the `SHOW DATABASE` statement. This is used only when performing a snapshot.
|`REPLICATION SLAVE`
|Enables the connector to connect to and read the {connector-name} server binlog.
|`REPLICATION CLIENT`
a|Enables the connector the use of the following statements:
* `SHOW MASTER STATUS`
* `SHOW SLAVE STATUS`
* `SHOW BINARY LOGS`
The connector always requires this.
|`ON`
|Identifies the database to which the permissions apply.
|`TO 'user'`
|Specifies the user to grant the permissions to.
|`IDENTIFIED BY 'password'`
|Specifies the user's {connector-name} password.
|===
end::creating-a-db-user[]
=== Enabling the binlog
tag::enabling-binlog[]
You must enable binary logging for {connector-name} replication.
The binary logs record transaction updates for replication tools to propagate changes.
.Prerequisites
* A {connector-name} server.
* Appropriate {connector-name} user privileges.
.Procedure
. Check whether the `log-bin`options is enabled:
+
ifdef::MARIADB[]
[source,SQL]
----
mariadb> SHOW VARIABLES LIKE '%log_bin%';
----
endif::MARIADB[]
ifdef::MYSQL[]
[source,SQL]
----
// for MySql 5.x
mysql> SELECT variable_value as "BINARY LOGGING STATUS (log-bin) ::"
FROM information_schema.global_variables WHERE variable_name='log_bin';
// for MySql 8.x
mysql> SELECT variable_value as "BINARY LOGGING STATUS (log-bin) ::"
FROM performance_schema.global_variables WHERE variable_name='log_bin';
----
endif::MYSQL[]
. If the binlog is `OFF`, add the properties in the following table to the configuration file for the {connector-name} server:
+
[source,properties]
----
server-id = 223344 # Querying variable is called server_id, e.g. SELECT variable_value FROM information_schema.global_variables WHERE variable_name='server_id';
log_bin = {context}-bin
binlog_format = ROW
binlog_row_image = FULL
binlog_expire_logs_seconds = 864000
----
. Confirm your changes by checking the binlog status once more:
+
ifdef::MARIADB[]
[source,SQL]
----
{context}> SHOW VARIABLES LIKE '%log_bin%';
----
endif::MARIADB[]
ifdef::MYSQL[]
[source,SQL]
----
// for MySql 5.x
{context}> SELECT variable_value as "BINARY LOGGING STATUS (log-bin) ::"
FROM information_schema.global_variables WHERE variable_name='log_bin';
// for MySql 8.x
{context}> SELECT variable_value as "BINARY LOGGING STATUS (log-bin) ::"
FROM performance_schema.global_variables WHERE variable_name='log_bin';
----
endif::MYSQL[]
. If you run {connector-name} on Amazon RDS, you must enable automated backups for your database instance for binary logging to occur.
If the database instance is not configured to perform automated backups, the binlog is disabled, even if you apply the settings described in the previous steps.
[[binlog-configuration-properties-{context}-connector]]
.Descriptions of {connector-name} binlog configuration properties
[cols="1,4",options="header",subs="+attributes"]
|===
|Property |Description
|`server-id`
|The value for the `server-id` must be unique for each server and replication client in the {connector-name} cluster.
|`log_bin`
|The value of `log_bin` is the base name of the sequence of binlog files.
|`binlog_format`
|The `binlog-format` must be set to `ROW` or `row`.
|`binlog_row_image`
|The `binlog_row_image` must be set to `FULL` or `full`.
|`binlog_expire_logs_seconds`
|The `binlog_expire_logs_seconds` corresponds to deprecated system variable `expire_logs_days`.
This is the number of seconds for automatic binlog file removal.
The default value is `2592000`, which equals 30 days.
Set the value to match the needs of your environment.
For more information, see xref:{context}-purges-binlog-files-used-by-debezium[{connector-name} purges binlog files].
|===
end::enabling-binlog[]
=== Configuring session timeouts
tag::cfg-session-timeouts[]
When an initial consistent snapshot is made for large databases, your established connection could timeout while the tables are being read.
You can prevent this behavior by configuring `interactive_timeout` and `wait_timeout` in your {connector-name} configuration file.
.Prerequisites
* A {connector-name} server.
* Basic knowledge of SQL commands.
* Access to the {connector-name} configuration file.
.Procedure
. Configure `interactive_timeout`:
+
[source,SQL,subs="+attributes,+quotes"]
----
{context}> interactive_timeout=<duration-in-seconds>
----
. Configure `wait_timeout`:
+
[source,SQL,subs="+attributes,+quotes"]
----
{context}> wait_timeout=<duration-in-seconds>
----
.Descriptions of {connector-name} session timeout options
[cols="3,7",options="header",subs="+attributes"]
|===
|Option |Description
|`interactive_timeout`
a|The number of seconds the server waits for activity on an interactive connection before closing it.
For more information see the:
ifdef::MARIADB[]
link:https://mariadb.com/kb/en/server-system-variables/#interactive_timeout[MariaDB documentation].
endif::MARIADB[]
ifdef::MYSQL::[]
link:https://dev.mysql.com/doc/refman/{mysql-version}/en/server-system-variables.html#sysvar_interactive_timeout[MySQL documentation].
endif::MYSQL[]
|`wait_timeout`
a|The number of seconds that the server waits for activity on a non-interactive connection before closing it.
ifdef::MARIADB[]
For more information, see the link:https://mariadb.com/kb/en/server-system-variables/#wait_timeout[MariaDB documentation].
endif::MARIADB[]
ifdef::MYSQL[]
For more information, see the link:https://dev.mysql.com/doc/refman/{mysql-version}/en/server-system-variables.html#sysvar_interactive_timeout[MySQL documentation].
endif::MYSQL[]
|===
end::cfg-session-timeouts[]
=== Validating binlog row value options
tag::validate-binlog-row-options[]
Check `binlog_row_value_options` variable, and make sure that value is **not** set to `PARTIAL_JSON`, since in such case connector might fail to consume *UPDATE* events.
.Prerequisites
* A {connector-name} server.
* Basic knowledge of SQL commands.
* Access to the {connector-name} configuration file.
.Procedure
. Check current variable value
+
[source,SQL,subs="+attributes,+quotes"]
----
{context}> show global variables where variable_name = 'binlog_row_value_options';
----
. Result
+
[source,SQL]
----
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| binlog_row_value_options | |
+--------------------------+-------+
----
. If the value of the variable is set to `PARTIAL_JSON`, run the following command to unset it:
+
[source,SQL,subs="+attributes,+quotes"]
----
{context}> set @@global.binlog_row_value_options="" ;
----
end::validate-binlog-row-options[]
== Deployment
tag::deployment[]
ifdef::community[]
To deploy a {prodname} {connector-name} connector, you install the {prodname} {connector-name} connector archive, configure the connector, and start the connector by adding its configuration to Kafka Connect.
.Prerequisites
* link:https://zookeeper.apache.org/[Apache Zookeeper], link:http://kafka.apache.org/[Apache Kafka], and link:{link-kafka-docs}.html#connect[Kafka Connect] are installed.
* {connector-name} Server is installed and is xref:setting-up-{context}[set up to work with the {prodname} connector].
.Procedure
ifeval::['{page-version}' == 'master']
ifdef::MARIADB[]
. Download the {prodname} link:{link-mariadb-plugin-snapshot}[MariaDB connector plug-in].
endif::MARIADB[]
ifdef::MYSQL[]
. Download the {prodname} link:{link-mysql-plugin-snapshot}[MySQL connector plug-in].
endif::MYSQL[]
endif::[]
ifeval::['{page-version}' != 'master']
ifdef::MARIADB[]
. Download the {prodname} link:https://repo1.maven.org/maven2/io/debezium/debezium-connector-mariadb/{debezium-version}/debezium-connector-mariadb-{debezium-version}-plugin.tar.gz[MariaDB connector plug-in].
endif::MARIADB[]
ifdef::MYSQL[]
. Download the {prodname} link:https://repo1.maven.org/maven2/io/debezium/debezium-connector-mysql/{debezium-version}/debezium-connector-mysql-{debezium-version}-plugin.tar.gz[MySQL connector plug-in].
endif::MYSQL[]
endif::[]
. Extract the files into your Kafka Connect environment.
. Add the directory with the JAR files to {link-kafka-docs}/#connectconfigs[Kafka Connect's `plugin.path`].
. xref:{context}-example-configuration[Configure the connector] and xref:{context}-adding-configuration[add the configuration to your Kafka Connect cluster.]
. Restart your Kafka Connect process to pick up the new JAR files.
If you are working with immutable containers, see link:https://quay.io/organization/debezium[{prodname}'s Container images] for Apache Zookeeper, Apache Kafka, {connector-name}, and Kafka Connect with the {connector-name} connector already installed and ready to run.
You can also xref:operations/openshift.adoc[run {prodname} on Kubernetes and OpenShift].
endif::community[]
ifdef::product[]
You can use either of the following methods to deploy a {prodname} {connector-name} connector:
* xref:openshift-streams-{context}-connector-deployment[Use {StreamsName} to automatically create an image that includes the connector plug-in].
+
This is the preferred method.
* xref:deploying-debezium-{context}-connectors[Build a custom Kafka Connect container image from a Dockerfile].
.Additional resources
* xref:descriptions-of-debezium-{context}-connector-configuration-properties[]
end::deployment[]
=== Deploying connectors by building a custom Kafka Connect container image from a Dockerfile
tag::deploy-via-dockerfile[]
To deploy a {prodname} {connector-name} connector, you must build a custom Kafka Connect container image that contains the {prodname} connector archive, and then push this container image to a container registry.
You then need to create the following custom resources (CRs):
* A `KafkaConnect` CR that defines your Kafka Connect instance.
The `image` property in the CR specifies the name of the container image that you create to run your {prodname} connector.
You apply this CR to the OpenShift instance where link:https://access.redhat.com/products/red-hat-amq#streams[Red Hat {StreamsName}] is deployed.
{StreamsName} offers operators and images that bring Apache Kafka to OpenShift.
* A `KafkaConnector` CR that defines your {prodname} {connector-name} connector.
Apply this CR to the same OpenShift instance where you apply the `KafkaConnect` CR.
.Prerequisites
* {connector-name} is running and you completed the steps to xref:setting-up-{context}-to-run-a-debezium-connector[set up {connector-name} to work with a {prodname} connector].
* {StreamsName} is deployed on OpenShift and is running Apache Kafka and Kafka Connect.
For more information, see link:{LinkDeployManageStreamsOpenShift}[{NameDeployManageStreamsOpenShift}].
* Podman or Docker is installed.
* You have an account and permissions to create and manage containers in the container registry (such as `quay.io` or `docker.io`) to which you plan to add the container that will run your Debezium connector.
.Procedure
. Create the {prodname} {connector-name} container for Kafka Connect:
.. Create a Dockerfile that uses `{DockerKafkaConnect}` as the base image.
For example, from a terminal window, enter the following command:
+
=====================================================================
[source,shell,subs="+attributes,+quotes"]
----
cat <<EOF >debezium-container-for-{context}.yaml // <1>
FROM {DockerKafkaConnect}
USER root:root
RUN mkdir -p /opt/kafka/plugins/debezium // <2>
RUN cd /opt/kafka/plugins/debezium/ \
&& curl -O {red-hat-maven-repository}debezium/debezium-connector-{connector-file}/{debezium-version}-redhat-{debezium-build-number}/debezium-connector-{connector-file}-{debezium-version}-redhat-{debezium-build-number}-plugin.zip \
&& unzip debezium-connector-{connector-file}-{debezium-version}-redhat-{debezium-build-number}-plugin.zip \
&& rm debezium-connector-{connector-file}-{debezium-version}-redhat-{debezium-build-number}-plugin.zip
RUN cd /opt/kafka/plugins/debezium/
USER 1001
EOF
----
=====================================================================
+
[cols="1,7",options="header"]
|===
|Item |Description
|1
|You can specify any file name that you want.
|2
|Specifies the path to your Kafka Connect plug-ins directory.
If your Kafka Connect plug-ins directory is in a different location, replace this path with the actual path of your directory.
|===
+
The command creates a Dockerfile with the name `debezium-container-for-{context}.yaml` in the current directory.
.. Build the container image from the `debezium-container-for-{context}.yaml` Docker file that you created in the previous step.
From the directory that contains the file, open a terminal window and enter one of the following commands:
+
[source,shell,options="nowrap",subs="+attributes,+quotes"]
----
podman build -t debezium-container-for-{context}:latest .
----
+
[source,shell,options="nowrap",subs="+attributes,+quotes"]
----
docker build -t debezium-container-for-{context}:latest .
----
The preceding commands build a container image with the name `debezium-container-for-{context}`.
.. Push your custom image to a container registry, such as `quay.io` or an internal container registry.
The container registry must be available to the OpenShift instance where you want to deploy the image.
Enter one of the following commands:
+
[source,shell,subs="attributes,+quotes"]
----
podman push _<myregistry.io>_/debezium-container-for-{context}:latest
----
+
[source,shell,subs="attributes,+quotes"]
----
docker push _<myregistry.io>_/debezium-container-for-{context}:latest
----
.. Create a new {prodname} {connector-name} `KafkaConnect` custom resource (CR).
For example, create a `KafkaConnect` CR with the name `dbz-connect.yaml` that specifies `annotations` and `image` properties.
The following example shows an excerpt from a `dbz-connect.yaml` file that describes a `KafkaConnect` custom resource. +
+
=====================================================================
[source,yaml,subs="+attributes"]
----
apiVersion: {KafkaConnectApiVersion}
kind: KafkaConnect
metadata:
name: my-connect-cluster
annotations:
strimzi.io/use-connector-resources: "true" // <1>
spec:
#...
image: debezium-container-for-{context} // <2>
...
----
=====================================================================
+
[cols="1,7",options="header"]
|===
|Item |Description
|1
|`metadata.annotations` indicates to the Cluster Operator that `KafkaConnector` resources are used to configure connectors in this Kafka Connect cluster.
|2
|`spec.image` specifies the name of the image that you created to run your Debezium connector.
This property overrides the `STRIMZI_DEFAULT_KAFKA_CONNECT_IMAGE` variable in the Cluster Operator.
|===
.. Apply the `KafkaConnect` CR to the OpenShift Kafka Connect environment by entering the following command:
+
[source,shell,options="nowrap"]
----
oc create -f dbz-connect.yaml
----
+
The command adds a Kafka Connect instance that specifies the name of the image that you created to run your {prodname} connector.
. Create a `KafkaConnector` custom resource that configures your {prodname} {connector-name} connector instance.
+
You configure a {prodname} {connector-name} connector in a `.yaml` file that specifies the configuration properties for the connector.
The connector configuration might instruct {prodname} to produce events for a subset of the schemas and tables, or it might set properties so that {prodname} ignores, masks, or truncates values in specified columns that are sensitive, too large, or not needed.
+
The following example configures a {prodname} connector that connects to a {connector-name} host, `192.168.99.100`, on port `3306`,
and captures changes to the `inventory` database.
`dbserver1` is the server's logical name.
+
.{connector-name} `inventory-connector.yaml`
[source,yaml,options="nowrap",subs="+attributes"]
----
apiVersion: {KafkaConnectApiVersion}
kind: KafkaConnector
metadata:
name: inventory-connector-{context} // <1>
labels:
strimzi.io/cluster: my-connect-cluster
spec:
class: io.debezium.connector.{context}.MariaDbConnector
tasksMax: 1 // <2>
config: // <3>
database.hostname: {context} // <4>
database.port: 3306
database.user: debezium
database.password: dbz
database.server.id: 184054 // <5>
topic.prefix: inventory-connector-{context} // <6>
table.include.list: inventory // <7>
schema.history.internal.kafka.bootstrap.servers: my-cluster-kafka-bootstrap:9092 // <8>
schema.history.internal.kafka.topic: schema-changes.inventory // <9>
----
+
.Descriptions of connector configuration settings
[cols="1,7",options="header",subs="+attributes"]
|===
|Item |Description
|1
|The name of the connector.
|2
|Only one task should operate at any one time.
Because the {connector-name} connector reads the {connector-name} servers `binlog`,
using a single connector task ensures proper order and event handling.
The Kafka Connect service uses connectors to start one or more tasks that do the work,
and it automatically distributes the running tasks across the cluster of Kafka Connect services.
If any of the services stop or crash,
those tasks will be redistributed to running services.
|3
|The connectors configuration.
|4
|The database host, which is the name of the container running the {connector-name} server (`{context}`).
|5
|Unique ID of the connector.
|6
|Topic prefix for the {connector-name} server or cluster.
This name is used as the prefix for all Kafka topics that receive change event records.
|7
|The connector captures changes from the `inventory` table only.
|8
|The list of Kafka brokers that this connector will use to write and recover DDL statements to the database schema history topic.
Upon restart, the connector recovers the schemas of the database that existed at the point in time in the binlog when the connector should begin reading.
|9
|The name of the database schema history topic. This topic is for internal use only and should not be used by consumers.
|===
. Create your connector instance with Kafka Connect.
For example, if you saved your `KafkaConnector` resource in the `inventory-connector.yaml` file, you would run the following command:
+
[source,shell,options="nowrap"]
----
oc apply -f inventory-connector.yaml
----
+
The preceding command registers `inventory-connector` and the connector starts to run against the `inventory` database as defined in the `KafkaConnector` CR.
endif::product[]
end::deploy-via-dockerfile[]
tag::connector-config-example[]
Following is an example of the configuration for a connector instance that captures data from a {connector-name} server on port 3306 at 192.168.99.100, which we logically name `fullfillment`.
Typically, you configure the {prodname} {connector-name} connector in a JSON file by setting the configuration properties that are available for the connector.
You can choose to produce events for a subset of the schemas and tables in a database.
Optionally, you can ignore, mask, or truncate columns that contain sensitive data, that are larger than a specified size, or that you do not need.
[source,json]
----
{
"name": "inventory-connector", // <1>
"config": {
"connector.class": "io.debezium.connector.{context}.MariaDbConnector", // <2>
"database.hostname": "192.168.99.100", // <3>
"database.port": "3306", // <4>
"database.user": "debezium-user", // <5>
"database.password": "debezium-user-pw", // <6>
"database.server.id": "184054", <7>
"topic.prefix": "fullfillment", // <8>
"database.include.list": "inventory", // <9>
"schema.history.internal.kafka.bootstrap.servers": "kafka:9092", // <10>
"schema.history.internal.kafka.topic": "schemahistory.fullfillment", // <11>
"include.schema.changes": "true" // <12>
}
}
----
<1> Connector's name when registered with the Kafka Connect service.
<2> Connector's class name.
<3> {connector-name} server address.
<4> {connector-name} server port number.
<5> {connector-name} user with the appropriate privileges.
<6> {connector-name} user's password.
<7> Unique ID of the connector.
<8> Topic prefix for the {connector-name} server or cluster.
<9> List of databases hosted by the specified server.
<10> List of Kafka brokers that the connector uses to write and recover DDL statements to the database schema history topic.
<11> Name of the database schema history topic. This topic is for internal use only and should not be used by consumers.
<12> Flag that specifies if the connector should generate events for DDL changes and emit them to the `fulfillment` schema change topic for use by consumers.
endif::community[]
For the complete list of the configuration properties that you can set for the {prodname} {connector-name} connector,
see xref:{context}-connector-properties[{connector-name} connector configuration properties].
ifdef::community[]
You can send this configuration with a `POST` command to a running Kafka Connect service.
The service records the configuration and starts one connector task that performs the following actions:
* Connects to the {connector-name} database.
* Reads change-data tables for tables in capture mode.
* Streams change event records to Kafka topics.
end::connector-config-example[]
=== Adding connector configuration
tag::add-connector-cfg[]
To start running a {connector-name} connector, configure a connector configuration, and add the configuration to your Kafka Connect cluster.
.Prerequisites
* xref:setting-up-{context}[{connector-name} is set up to work with a {prodname} connector].
* The {prodname} {connector-name} connector is installed.
.Procedure
. Create a configuration for the {connector-name} connector.
. Use the link:{link-kafka-docs}/#connect_rest[Kafka Connect REST API] to add that connector configuration to your Kafka Connect cluster.
endif::community[]
.Results
After the connector starts, it xref:{context}-snapshots[performs a consistent snapshot] of the {connector-name} databases that the connector is configured for.
The connector then starts generating data change events for row-level operations and streaming change event records to Kafka topics.
end::add-connector-cfg[]
=== Connector properties
tag::connector-props-intro[]
The {prodname} {connector-name} connector has numerous configuration properties that you can use to achieve the right connector behavior for your application.
Many properties have default values.
Information about the properties is organized as follows:
* xref:{context}-required-connector-configuration-properties[Required connector configuration properties]
* xref:{context}-advanced-connector-configuration-properties[Advanced connector configuration properties]
* xref:debezium-{context}-connector-database-history-configuration-properties[Database schema history connector configuration properties] that control how {prodname} processes events that it reads from the database schema history topic.
** xref:{context}-pass-through-database-history-properties-for-configuring-producer-and-consumer-clients[Pass-through database schema history properties]
* xref:debezium-{context}-connector-pass-through-database-driver-configuration-properties[Pass-through database driver properties] that control the behavior of the database driver.
end::connector-props-intro[]
== Monitoring
tag::monitoring-intro[]
The {prodname} {connector-name} connector provides three types of metrics that are in addition to the built-in support for JMX metrics that Zookeeper, Kafka, and Kafka Connect provide.
* xref:mariadb-snapshot-metrics[Snapshot metrics] provide information about connector operation while performing a snapshot.
* xref:mariadb-streaming-metrics[Streaming metrics] provide information about connector operation when the connector is reading the binlog.
* xref:mariadb-schema-history-metrics[Schema history metrics] provide information about the status of the connector's schema history.
{link-prefix}:{link-debezium-monitoring}#monitoring-debezium[{prodname} monitoring documentation] provides details for how to expose these metrics by using JMX.
end::monitoring-intro[]
=== Streaming metrics
tag::streaming-metrics-intro[]
Transaction-related attributes are available only if binlog event buffering is enabled.
ifdef::community[]
See xref:mariadb-property-binlog-buffer-size[`binlog.buffer.size`] in the advanced connector configuration properties for more details.
endif::community[]
end::streaming-metrics-intro[]
== Behavior when things go wrong
tag::wrong-things[]
{prodname} is a distributed system that captures all changes in multiple upstream databases; it never misses or loses an event.
When the system is operating normally or being managed carefully then {prodname} provides _exactly once_ delivery of every change event record.
If a fault does occur, the system does not lose any events.
However, while {prodname} is recovering from a fault, it might repeat some change events.
In these abnormal situations, {prodname}, like Kafka, provides _at least once_ delivery of change events.
ifdef::community[]
The rest of this section describes how {prodname} handles various kinds of faults and problems.
endif::community[]
ifdef::product[]
Details are in the following sections:
* xref:debezium-{context}-connector-configuration-and-startup-errors[]
* xref:{context}-becomes-unavailable-while-debezium-is-running[]
* xref:debezium-{context}-kafka-connect-process-stops-gracefully[]
* xref:debezium-{context}-kafka-connect-process-crashes[]
* xref:debezium-{context}-kafka-process-becomes-unavailable[]
* xref:{context}-purges-binlog-files-used-by-debezium[]
endif::product[]
[id="debezium-{context}-connector-configuration-and-startup-errors"]
Configuration and startup errors::
In the following situations, the connector fails when trying to start, reports an error or exception in the log, and stops running:
* The connector's configuration is invalid.
* The connector cannot successfully connect to the {connector-name} server by using the specified connection parameters.
* The connector is attempting to restart at a position in the binlog for which {connector-name} no longer has the history available.
In these cases, the error message has details about the problem and possibly a suggested workaround.
After you correct the configuration or address the {connector-name} problem, restart the connector.
[id="{context}-becomes-unavailable-while-debezium-is-running"]
{connector-name} becomes unavailable::
If your {connector-name} server becomes unavailable, the {prodname} {connector-name} connector fails with an error and the connector stops.
When the server is available again, restart the connector.
However, if you are connecting to a highly available {connector-name} cluster, you can restart the connector immediately.
It will connect to a different {connector-name} server in the cluster, find the location in the server's binlog that represents the last transaction, and begin reading the new server's binlog from that specific location.
[id="debezium-{context}-kafka-connect-process-stops-gracefully"]
Kafka Connect stops gracefully::
When Kafka Connect stops gracefully, there is a short delay while the {prodname} {connector-name} connector tasks are stopped and restarted on new Kafka Connect processes.
[id="debezium-{context}-kafka-connect-process-crashes"]
Kafka Connect process crashes::
If Kafka Connect crashes, the process stops and any {prodname} {connector-name} connector tasks terminate without their most recently-processed offsets being recorded.
In distributed mode, Kafka Connect restarts the connector tasks on other processes.
However, the {connector-name} connector resumes from the last offset recorded by the earlier processes.
As a result, the replacement tasks might regenerate some events that were processed before the crash, creating duplicate events.
Each change event message includes source-specific information that you can use to identify duplicate events, for example:
* Event origin
* {connector-name} server's event time
* The binlog file name and position
* GTIDs
ifdef::MYSQL[]
(if used)
endif::MYSQL[]
[id="debezium-{context}-kafka-process-becomes-unavailable"]
Kafka becomes unavailable::
The Kafka Connect framework records {prodname} change events in Kafka by using the Kafka producer API.
If the Kafka brokers become unavailable, the {prodname} {connector-name} connector pauses until the connection is reestablished, and the connector then resumes where it left off.
[id="{context}-purges-binlog-files-used-by-debezium"]
{connector-name} purges binlog files::
If the {prodname} {connector-name} connector stops for too long, the {connector-name} server purges older binlog files and the connector's last position may be lost.
When the connector is restarted, the {connector-name} server no longer has the starting point and the connector performs another initial snapshot.
If the snapshot is disabled, the connector fails with an error.
See xref:{context}-snapshots[snapshots] for details about how {connector-name} connectors perform initial snapshots.
end::wrong-things[]