yugabyte / debezium-connector-yugabytedb

A Debezium CDC connector for the YugabyteDB database
https://docs.yugabyte.com/stable/explore/change-data-capture/using-logical-replication/yugabytedb-connector/
Apache License 2.0
12 stars 8 forks source link

[yugabyte/yugabyte-db#21940] Update tablet safe hybrid time only after batch is processed #333

Closed vaibhav-yb closed 6 months ago

vaibhav-yb commented 6 months ago

Problem

In the connector flow, we call GetChanges and then immediately set the tablet safe hybrid time from the response i.e. https://github.com/yugabyte/debezium-connector-yugabytedb/blob/main/src/main/java/io/debezium/connector/yugabytedb/YugabyteDBStreamingChangeEventSource.java#L533

Now suppose there’s a case where connector faced some errors while publishing the records from this response and it threw an error, the error handling mechanism would attempt a retry on the from_op_id but this time the tablet safe hybrid time value would be higher thus resulting in filtering of some records which would cause data loss.

Solution

This diff moves the tablet safe time updation after the records have been processed successfully by the connector.

Closes yugabyte/yugabyte-db#21940