Skip to content

[NUTCH-1564] AdaptiveFetchSchedule sync_delta forces refetch of unmodified pages - #880

Merged
sebastian-nagel merged 3 commits into
apache:masterfrom
igiguere:NUTCH-1564-AdaptiveFetchSchedule-refetch
Jan 12, 2026
Merged

sebastian-nagel merged 3 commits into
apache:masterfrom
igiguere:NUTCH-1564-AdaptiveFetchSchedule-refetch

Conversation

@igiguere

@igiguere igiguere commented Jan 4, 2026 •

Copy link
Copy Markdown
Contributor

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.

Unrelated change in FetcherThread required on my side because my IDE runs on Java 21. Nutch was built separately on Java 17 too.

Tests

  • Unit tests added, illustrating a few situations based on the description of NUTCH-1564.
  • Nutch is successfully built and unit tests pass by running ant clean runtime test
  • Functional tests to be done on a long-running installation... which I don't have.

Isabelle Giguere added 2 commits January 3, 2026 16:53
In setFetchSchedule, make sure 'refTime' is not in the past.

Add unit test to reproduce the situation described in Jira.

Unrelated fix in FetcherThread
Convert the fraction of the delta to a ratio of max interval, to avoid
next fetchTime in the past.

Add unit tests for different scenarios.
@igiguere
igiguere marked this pull request as ready for review January 4, 2026 15:49
@lewismc

lewismc commented Jan 5, 2026

Copy link
Copy Markdown
Member

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.

@sebastian-nagel sebastian-nagel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 implemented as part of NUTCH-1502. Maybe you can move the unit tests from 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!

Comment thread src/java/org/apache/nutch/fetcher/FetcherThread.java
Comment thread src/java/org/apache/nutch/crawl/AdaptiveFetchSchedule.java Outdated
Comment thread src/java/org/apache/nutch/crawl/AdaptiveFetchSchedule.java Outdated
Add TestCrawlDbStatesExtended (was TODOTestCrawlDbStates)
@igiguere

igiguere commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

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 implemented as part of NUTCH-1502. Maybe you can move the unit tests from 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.

@sebastian-nagel sebastian-nagel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @igiguere!

Will merge in a few days, but waiting for a potential second review.

@sebastian-nagel
sebastian-nagel merged commit 7f724a9 into apache:master Jan 12, 2026
6 checks passed
@igiguere
igiguere deleted the NUTCH-1564-AdaptiveFetchSchedule-refetch branch February 5, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants