Skip to content

Commit

Permalink
Merge pull request #55 from nlnwa/fix-fetch-timeout-worker-loop
Browse files Browse the repository at this point in the history
Fix potential infinite loop or exception
  • Loading branch information
johnerikhalse authored Nov 30, 2021
2 parents 30963d7 + 6c97482 commit fe99ad0
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,11 @@ public void run() {
Error err = ExtraStatusCodes.RUNTIME_EXCEPTION.toFetchError("Timeout waiting for Harvester");

try (JedisContext ctx = JedisContext.forPool(jedisPool)) {
String chgId = ctx.getJedis().lpop(CHG_TIMEOUT_KEY);
while (chgId != null) {
for (String chgId = ctx.getJedis().lpop(CHG_TIMEOUT_KEY); chgId != null; chgId = ctx.getJedis().lpop(CHG_TIMEOUT_KEY)) {
try {
CrawlHostGroup chg = frontier.getCrawlQueueManager().getCrawlHostGroup(chgId);
if (chg.getCurrentUriId().isEmpty()) {
frontier.getCrawlQueueManager().releaseCrawlHostGroup(ctx, chg.getId(), chg.getSessionToken(), 0, true);
frontier.getCrawlQueueManager().releaseCrawlHostGroup(ctx, chgId, chg.getSessionToken(), 0, true);
continue;
}
PostFetchHandler postFetchHandler = new PostFetchHandler(chg, frontier, false);
Expand All @@ -125,8 +124,6 @@ public void run() {
} catch (Exception e) {
LOG.warn("Error while getting chg {}", chgId, e);
}

chgId = ctx.getJedis().lpop(CHG_TIMEOUT_KEY);
}
} catch (Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit fe99ad0

Please sign in to comment.