Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-5087

Interrupting a snapshot process can hang for some JDBC drivers

XMLWordPrintable

    • False
    • None
    • False

      What Debezium connector do you use and what version?

      Any

      What behaviour do you expect?

      Interrupting a table snapshot process causes it to stop in a timely manner and dispose of any resources properly.

      What behaviour do you see?

      While a table is undergoing a snapshot process and its initial events are streamed, any interruption (in the form of an unhandled exception or otherwise) will cause the used ResultSet to try and close.

      For some JDBC drivers, closing the ResultSet might still require fetching and discarding the remaining rows. This means that for a large query (which is typical for a table snapshot), closing it might hang until the streaming is done, or indefinitely for resource freeing purposes.

       

      The problem lies in the RelationalSnapshotChangeEventSource#createDataEventsForTable method, where the try-with-resource block will try to close a ResultSet when it might not be fully exhausted, causing the JDBC driver to enter a fetch/discard loop until all of the rows are fetched. Only then can the ResultSet properly close. The problem along with its solution (for SQL Server, which is applicable to all DBs), is described here: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/7ceee9a8-09d8-4fbd-9918-0ca065fa182e/resultsetclose-hangs-with-new-jdbc-20?forum=sqldataaccess

            Unassigned Unassigned
            mark.bereznitsky Mark Bereznitsky
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: