[java client] Retry regressing counts in ITClient There's currently no sure way to read your writes, even with snapshot scans, so we can either retry counting rows or ignore it. This patch is doing the former, unless we hit some artificial timeout.
Change-Id: I1e79a6c7aaf069294a6ca40e487947d14d9f2aa7 Reviewed-on: http://gerrit.cloudera.org:8080/4597 Reviewed-by: Adar Dembo <[email protected]> Tested-by: Kudu Jenkins Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/98130e3c Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/98130e3c Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/98130e3c Branch: refs/heads/master Commit: 98130e3c40780e80dd46e9c729424554f2c77a4f Parents: f26ab7d Author: Jean-Daniel Cryans <[email protected]> Authored: Mon Oct 3 09:16:18 2016 -0700 Committer: Jean-Daniel Cryans <[email protected]> Committed: Wed Oct 5 23:30:18 2016 +0000 ---------------------------------------------------------------------- .../java/org/apache/kudu/client/ITClient.java | 38 +++++++++++++------- 1 file changed, 26 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/98130e3c/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java b/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java index d4ffec0..1ff242d 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java @@ -380,21 +380,35 @@ public class ITClient extends BaseKuduTest { * @return true if the full scan was successful, false if there was an error */ private boolean fullScan() { - KuduScanner scanner = getScannerBuilder().build(); - try { - int rowCount = countRowsInScan(scanner); - if (rowCount < lastRowCount) { - reportError("Row count regressed: " + rowCount + " < " + lastRowCount, null); - return false; + int rowCount; + DeadlineTracker deadlineTracker = new DeadlineTracker(); + deadlineTracker.setDeadline(DEFAULT_SLEEP); + + while (KEEP_RUNNING_LATCH.getCount() > 0 && !deadlineTracker.timedOut()) { + KuduScanner scanner = getScannerBuilder().build(); + + try { + rowCount = countRowsInScan(scanner); + } catch (KuduException e) { + return checkAndReportError("Got error while row counting", e); + } + + if (rowCount >= lastRowCount) { + if (rowCount > lastRowCount) { + lastRowCount = rowCount; + LOG.info("New row count {}", lastRowCount); + } + return true; } - if (rowCount > lastRowCount) { - lastRowCount = rowCount; - LOG.info("New row count {}", lastRowCount); + + // Due to the lack of KUDU-430, we need to loop until the row count stops regressing. + try { + KEEP_RUNNING_LATCH.await(50, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + // No need to do anything, we'll exit the loop once we test getCount() in the condition. } - } catch (KuduException e) { - return checkAndReportError("Got error while row counting", e); } - return true; + return !deadlineTracker.timedOut(); } private KuduScanner.KuduScannerBuilder getScannerBuilder() {
