From 8ad2e8da5bb4276d2524bc02dfee1f16a7830d38 Mon Sep 17 00:00:00 2001 From: ebartkus Date: Thu, 18 Oct 2018 10:36:05 +0300 Subject: [PATCH] Backported fix from https://github.com/debezium/debezium/pull/527/files#diff-e2e01b9bef70513fb196acc0b855e314 --- .../io/debezium/connector/mongodb/SourceInfo.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/debezium-connector-mongodb/src/main/java/io/debezium/connector/mongodb/SourceInfo.java b/debezium-connector-mongodb/src/main/java/io/debezium/connector/mongodb/SourceInfo.java index d3467427113..5d436fbd309 100644 --- a/debezium-connector-mongodb/src/main/java/io/debezium/connector/mongodb/SourceInfo.java +++ b/debezium-connector-mongodb/src/main/java/io/debezium/connector/mongodb/SourceInfo.java @@ -295,6 +295,10 @@ public boolean setOffsetFor(String replicaSetName, Map sourceOffset) if (replicaSetName == null) throw new IllegalArgumentException("The replica set name may not be null"); if (sourceOffset == null) return false; // We have previously recorded at least one offset for this database ... + boolean initSync = booleanOffsetValue(sourceOffset, INITIAL_SYNC); + if (initSync) { + return false; + } int time = intOffsetValue(sourceOffset, TIMESTAMP); int order = intOffsetValue(sourceOffset, ORDER); Long operationId = longOffsetValue(sourceOffset, OPERATION_ID); @@ -366,4 +370,12 @@ private static long longOffsetValue(Map values, String key) { throw new ConnectException("Source offset '" + key + "' parameter value " + obj + " could not be converted to a long"); } } + + private static boolean booleanOffsetValue(Map values, String key) { + Object obj = values.get(key); + if (obj != null && obj instanceof Boolean) { + return ((Boolean) obj).booleanValue(); + } + return false; + } }