From a66412ff5aab6459226e970ac2fe588b76bb11f5 Mon Sep 17 00:00:00 2001 From: Dmitry Khominich Date: Tue, 9 Jul 2019 13:15:26 +0300 Subject: [PATCH] reduce time spending in poll --- .../io/confluent/connect/jdbc/source/JdbcSourceTask.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/confluent/connect/jdbc/source/JdbcSourceTask.java b/src/main/java/io/confluent/connect/jdbc/source/JdbcSourceTask.java index 67d560b85b..c229cf8a0b 100644 --- a/src/main/java/io/confluent/connect/jdbc/source/JdbcSourceTask.java +++ b/src/main/java/io/confluent/connect/jdbc/source/JdbcSourceTask.java @@ -296,10 +296,11 @@ public List poll() throws InterruptedException { // If not in the middle of an update, wait for next update time final long nextUpdate = querier.getLastUpdate() + config.getInt(JdbcSourceTaskConfig.POLL_INTERVAL_MS_CONFIG); - final long untilNext = nextUpdate - time.milliseconds(); - if (untilNext > 0) { - log.trace("Waiting {} ms to poll {} next", untilNext, querier.toString()); - time.sleep(untilNext); + final long now = time.milliseconds(); + final long sleepMs = Math.min(nextUpdate - now, 100); + if (sleepMs > 0) { + log.trace("Waiting {} ms to poll {} next", nextUpdate - now, querier.toString()); + time.sleep(sleepMs); continue; // Re-check stop flag before continuing } }