From d8bbf3bc413624aa7b897e54fde76883c09015e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wa=C5=9B?= Date: Tue, 7 May 2024 16:26:19 +0200 Subject: [PATCH] Make sync sleep more to avoid hitting secondary rate limits Some queries in sync that have the IN predicate can actually execute multiple requests, last longer than query delay so the next query can execute a request almost immediately after the last one. Add another explicit sleep to counter that. Queries with IN predicates are already expected to last longer than the delay, so adding a constant delay should not have too much impact to total run time. --- .../src/main/java/pl/net/was/rest/github/Sync.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/trino-rest-github/src/main/java/pl/net/was/rest/github/Sync.java b/trino-rest-github/src/main/java/pl/net/was/rest/github/Sync.java index 19d977b9..d8694227 100644 --- a/trino-rest-github/src/main/java/pl/net/was/rest/github/Sync.java +++ b/trino-rest-github/src/main/java/pl/net/was/rest/github/Sync.java @@ -1164,6 +1164,7 @@ private static boolean syncRerunJobs(Options options) insertStatement.setLong(3 + i, ids.get(i)); } rows += retryExecute(insertStatement); + MILLISECONDS.sleep(getQueryDelayMillis()); } log.info(format("Inserted %d rows, took %s", rows, Duration.ofMillis(System.currentTimeMillis() - startTime))); if (rows == 0) { @@ -1551,6 +1552,7 @@ private static boolean syncCheckSuites(Options options) long startTime = System.currentTimeMillis(); int rows = retryExecute(insertStatement); + MILLISECONDS.sleep(getQueryDelayMillis()); log.info(format("Inserted %d rows, took %s", rows, Duration.ofMillis(System.currentTimeMillis() - startTime))); } } @@ -1614,6 +1616,7 @@ private static boolean syncCheckRuns(Options options) long startTime = System.currentTimeMillis(); int rows = retryExecute(insertStatement); + MILLISECONDS.sleep(getQueryDelayMillis()); log.info(format("Inserted %d rows, took %s", rows, Duration.ofMillis(System.currentTimeMillis() - startTime))); } } @@ -1677,6 +1680,7 @@ private static boolean syncCheckRunAnnotations(Options options) long startTime = System.currentTimeMillis(); int rows = retryExecute(insertStatement); + MILLISECONDS.sleep(getQueryDelayMillis()); log.info(format("Inserted %d rows, took %s", rows, Duration.ofMillis(System.currentTimeMillis() - startTime))); } }