lsabi
lsabi

Reputation: 4476

How Debezium SQL Server works under the hood

I've been looking on how the connector of Debezium for SQL Server works under the hood, but I'm not sure I've understood it correctly.

In the docs, in the section about the snapshots (see https://debezium.io/documentation/reference/stable/connectors/sqlserver.html), it says

  1. Read the maximum log sequence number (LSN) position in the server’s transaction log.

How does it read the LSN is not clear to me. Does it read it on the file level or from the server, by querying it with sys.fn_cdc_get_max_lsn() ? This query is called with a frequency as set in the polling parameter?

Thanks

Upvotes: 0

Views: 94

Answers (1)

lsabi
lsabi

Reputation: 4476

Thanks to Ben Thul for the comments, I was able to solve the doubt.

As linked in the comments, the connector relies on some queries that are being used by the driver during polling operations. The function for getting the latest LSN and comparing it with the one currently stored in Debezium has probably some optimizations. Furthermore, the other queries are used only on need, when data changes (i.e. new LSNs are pushed in the log).

For reference, below the link to the source of the connector https://github.com/debezium/debezium/blob/4955244532dac01d9e712723971ce50624d209f1/debezium-connector-sqlserver/src/main/java/io/debezium/connector/sqlserver/SqlServerConnection.java

Upvotes: 1

Related Questions