From 550547f905c06372895f7495cf817f64d2fa5a35 Mon Sep 17 00:00:00 2001 From: Peter Kosztolanyi Date: Mon, 20 Jan 2020 19:58:51 +0000 Subject: [PATCH] [AP-483] Update bookmark only before writing state message (#12) --- setup.py | 2 +- tap_mysql/sync_strategies/binlog.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index a24a0fd..4cf4d06 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup setup(name='pipelinewise-tap-mysql', - version='1.1.2', + version='1.1.3', description='Singer.io tap for extracting data from MySQL - PipelineWise compatible', author='Stitch', url='https://github.com/transferwise/pipelinewise-tap-mysql', diff --git a/tap_mysql/sync_strategies/binlog.py b/tap_mysql/sync_strategies/binlog.py index a538f8d..5195e50 100644 --- a/tap_mysql/sync_strategies/binlog.py +++ b/tap_mysql/sync_strategies/binlog.py @@ -378,11 +378,6 @@ def _run_binlog_sync(mysql_conn, reader, binlog_streams_map, state): binlog_event.schema, binlog_event.table) - state = update_bookmarks(state, - binlog_streams_map, - reader.log_file, - reader.log_pos) - # The iterator across python-mysql-replication's fetchone method should ultimately terminate # upon receiving an EOF packet. There seem to be some cases when a MySQL server will not send # one causing binlog replication to hang. @@ -391,6 +386,10 @@ def _run_binlog_sync(mysql_conn, reader, binlog_streams_map, state): if ((rows_saved and rows_saved % UPDATE_BOOKMARK_PERIOD == 0) or (events_skipped and events_skipped % UPDATE_BOOKMARK_PERIOD == 0)): + state = update_bookmarks(state, + binlog_streams_map, + reader.log_file, + reader.log_pos) singer.write_message(singer.StateMessage(value=copy.deepcopy(state)))