You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nutch.apache.org by "igiguere (via GitHub)" <gi...@apache.org> on 2026/01/04 15:25:22 UTC
[PR] [NUTCH-1564] AdaptiveFetchSchedule sync_delta forces refetch of unmodified pages [nutch]
igiguere opened a new pull request, #880:
URL: https://github.com/apache/nutch/pull/880
### Ticket
https://issues.apache.org/jira/browse/NUTCH-1564
### Description
For a full description of the issue, please refer to the ASF Jira ticket.
### Solution
If the `offset` calculated from the `delta` (difference between last fetch time and last modification time) and `sync_delta_rate` is larger than the `max_interval`, then, the `offset` is re-calculated proportionaly to the `max_interval`.
This ensures that when the `interval` (most likely the `max_interval`) is added to the `refTime`, the resulting new `fetchTime` is not is the past, triggering an immediate re-fetch.
Note that I also played with some "brute force" ideas:
- if `offset` > `max_interval`, then set `refTime` to current `fetchTime`
- if `offset` > `max_interval`, then re-set `offset` to `offset` - `max_interval` (i.e.: 9-7=2), then, calculate `refTime` as before from that. (equivalent to `fetchTime` - 2, in the example)
The suggested approach allows a smooth-ish selection of the next fetch time, relative to the gap between fetch time and last modification time.
### Tests
Unit tests added, illustrating a few situations based on the description of NUTCH-1564.
Functional tests to be done on a long-running installation... which I don't have.
* Nutch is successfully built and unit tests pass by running `ant clean runtime test`
* there should be no conflicts when merging the pull request branch into the *recent* master branch. If there are conflicts, please try to rebase the pull request branch on top of a freshly pulled master branch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [NUTCH-1564] AdaptiveFetchSchedule sync_delta forces refetch of unmodified pages [nutch]
Posted by "igiguere (via GitHub)" <gi...@apache.org>.
igiguere commented on code in PR #880:
URL: https://github.com/apache/nutch/pull/880#discussion_r2672708846
##########
src/java/org/apache/nutch/crawl/AdaptiveFetchSchedule.java:
##########
@@ -332,17 +333,29 @@ public CrawlDatum setFetchSchedule(Text url, CrawlDatum datum,
case FetchSchedule.STATUS_UNKNOWN:
break;
}
- if (SYNC_DELTA) {
- // try to synchronize with the time of change
- long delta = (fetchTime - modifiedTime) / 1000L;
- if (delta > interval)
- interval = delta;
- refTime = fetchTime - Math.round(delta * SYNC_DELTA_RATE * 1000);
- }
// Ensure the interval does not fall outside of bounds
float minInterval = (getCustomMinInterval(url) != null) ? getCustomMinInterval(url) : MIN_INTERVAL;
float maxInterval = (getCustomMaxInterval(url) != null) ? getCustomMaxInterval(url) : MAX_INTERVAL;
+
+ if (SYNC_DELTA) {
+ // try to synchronize with the time of change
+ long delta = (fetchTime - modifiedTime);
+ if (delta > (interval * 1000))
+ interval = delta / 1000L;
+ // offset: a fraction (sync_delta_rate) of the difference between the last modification time, and the last fetch time.
+ long offset = Math.round(delta * SYNC_DELTA_RATE);
+ long maxIntervalMillis = (long) maxInterval * 1000L;
+ LOG.trace("delta (days): " + Duration.ofMillis(delta).toDays()
Review Comment:
Oops. Sorry. This was originally `System.out.println` for debugging purposes ;)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [NUTCH-1564] AdaptiveFetchSchedule sync_delta forces refetch of unmodified pages [nutch]
Posted by "lewismc (via GitHub)" <gi...@apache.org>.
lewismc commented on PR #880:
URL: https://github.com/apache/nutch/pull/880#issuecomment-3712124102
Nice work @igiguere
I haven't looked at the PR yet but will try to have a look soon.
I assigned the Jira ticket to you and also made a change inb Jira so hopefully you can self-assign in the future.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [NUTCH-1564] AdaptiveFetchSchedule sync_delta forces refetch of unmodified pages [nutch]
Posted by "igiguere (via GitHub)" <gi...@apache.org>.
igiguere commented on PR #880:
URL: https://github.com/apache/nutch/pull/880#issuecomment-3724530642
> Hi @igiguere, thanks for this fix of a long outstanding bug! Highly appreciated!
>
> There are only few minor points which should be improved, see the inline comments.
>
> One additional point: there are "deactivated" unit tests for [NUTCH-1564](https://issues.apache.org/jira/browse/NUTCH-1564) implemented as part of [NUTCH-1502](https://issues.apache.org/jira/browse/NUTCH-1502). Maybe you can move the unit tests from [TODOTestCrawlDbStates.java](https://github.com/apache/nutch/blob/master/src/test/org/apache/nutch/crawl/TODOTestCrawlDbStates.java) into TestCrawlDbStates.java and then delete the class TODOTestCrawlDbStates.java. You can then verify whether the "activated" unit tests pass per `ant test-core -Dtestcase=TestCrawlDbStates`. Thanks!
Done. I renamed TODOTestCrawlDbStates as TestCrawlDbStatesExtended to avoid a clash with the existing TestCrawlDbStates.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [NUTCH-1564] AdaptiveFetchSchedule sync_delta forces refetch of unmodified pages [nutch]
Posted by "sebastian-nagel (via GitHub)" <gi...@apache.org>.
sebastian-nagel merged PR #880:
URL: https://github.com/apache/nutch/pull/880
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [NUTCH-1564] AdaptiveFetchSchedule sync_delta forces refetch of unmodified pages [nutch]
Posted by "igiguere (via GitHub)" <gi...@apache.org>.
igiguere commented on code in PR #880:
URL: https://github.com/apache/nutch/pull/880#discussion_r2672712253
##########
src/java/org/apache/nutch/crawl/AdaptiveFetchSchedule.java:
##########
@@ -389,7 +402,8 @@ public static void main(String[] args) throws Exception {
(p.getFetchInterval() / SECONDS_PER_DAY), miss);
if (p.getFetchTime() <= curTime) {
fetchCnt++;
- fs.setFetchSchedule(new Text("http://www.example.com"), p, p
+ // why was "http://www.example.com" hard-coded here?
Review Comment:
With the comment, I got an answer, thank :) I'll remove it now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [NUTCH-1564] AdaptiveFetchSchedule sync_delta forces refetch of unmodified pages [nutch]
Posted by "igiguere (via GitHub)" <gi...@apache.org>.
igiguere commented on code in PR #880:
URL: https://github.com/apache/nutch/pull/880#discussion_r2672705143
##########
src/java/org/apache/nutch/fetcher/FetcherThread.java:
##########
@@ -389,7 +389,7 @@ public void run() {
}
continue;
}
- if (!rules.isAllowed(fit.u)) {
Review Comment:
Probably a rebase issue. I'll fix that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [NUTCH-1564] AdaptiveFetchSchedule sync_delta forces refetch of unmodified pages [nutch]
Posted by "sebastian-nagel (via GitHub)" <gi...@apache.org>.
sebastian-nagel commented on code in PR #880:
URL: https://github.com/apache/nutch/pull/880#discussion_r2671659078
##########
src/java/org/apache/nutch/crawl/AdaptiveFetchSchedule.java:
##########
@@ -389,7 +402,8 @@ public static void main(String[] args) throws Exception {
(p.getFetchInterval() / SECONDS_PER_DAY), miss);
if (p.getFetchTime() <= curTime) {
fetchCnt++;
- fs.setFetchSchedule(new Text("http://www.example.com"), p, p
+ // why was "http://www.example.com" hard-coded here?
Review Comment:
Likely, because a URL is required by the API, although it is not relevant here. It's ok to use an empty string here. But the comment should be also removed.
##########
src/java/org/apache/nutch/crawl/AdaptiveFetchSchedule.java:
##########
@@ -332,17 +333,29 @@ public CrawlDatum setFetchSchedule(Text url, CrawlDatum datum,
case FetchSchedule.STATUS_UNKNOWN:
break;
}
- if (SYNC_DELTA) {
- // try to synchronize with the time of change
- long delta = (fetchTime - modifiedTime) / 1000L;
- if (delta > interval)
- interval = delta;
- refTime = fetchTime - Math.round(delta * SYNC_DELTA_RATE * 1000);
- }
// Ensure the interval does not fall outside of bounds
float minInterval = (getCustomMinInterval(url) != null) ? getCustomMinInterval(url) : MIN_INTERVAL;
float maxInterval = (getCustomMaxInterval(url) != null) ? getCustomMaxInterval(url) : MAX_INTERVAL;
+
+ if (SYNC_DELTA) {
+ // try to synchronize with the time of change
+ long delta = (fetchTime - modifiedTime);
+ if (delta > (interval * 1000))
+ interval = delta / 1000L;
+ // offset: a fraction (sync_delta_rate) of the difference between the last modification time, and the last fetch time.
+ long offset = Math.round(delta * SYNC_DELTA_RATE);
+ long maxIntervalMillis = (long) maxInterval * 1000L;
+ LOG.trace("delta (days): " + Duration.ofMillis(delta).toDays()
Review Comment:
Especially for debug and trace logs, parameterized logging is recommended. See the [slf4j FAQ about performance](https://www.slf4j.org/faq.html#logging_performance).
However, because there are three Duration objects created, it's also ok to put the log call into a `if (LOG.isTraceEnabled())` condition.
##########
src/java/org/apache/nutch/fetcher/FetcherThread.java:
##########
@@ -389,7 +389,7 @@ public void run() {
}
continue;
}
- if (!rules.isAllowed(fit.u)) {
Review Comment:
How is this change related to NUTCH-1564?
It reverts a change done in PR #874 / NUTCH-3136. Possibly a rebase issue?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org