incubator-stormcrawler icon indicating copy to clipboard operation
incubator-stormcrawler copied to clipboard

Solr StatusUpdaterBolt overwrites the status of a URL when it is discovered again

Open dpol1 opened this issue 4 weeks ago • 2 comments

The Solr StatusUpdaterBolt sends every status as a plain add, so a DISCOVERED tuple for a URL already in the status collection replaces its record. For DISCOVERED, the OpenSearch bolt uses create and the SQL one INSERT IGNORE, which keep what is there.

A test with two bolt instances, the second standing for a restarted topology, gives:

before: {"url":"https://www.url.net/missing.html","status":"FETCH_ERROR","metadata.fetch.error.count":["1"],"nextFetchDate":"2026-11-05T11:50:02Z",...}
after:  {"url":"https://www.url.net/missing.html","status":"DISCOVERED","nextFetchDate":"2026-11-05T09:50:03Z",...}

before: {"url":"https://www.url.net/denied.html","status":"ERROR","nextFetchDate":"2026-12-06T09:55:57Z",...}
after:  {"url":"https://www.url.net/denied.html","status":"DISCOVERED","nextFetchDate":"2026-11-05T09:55:58Z",...}

The test conf has no fetchInterval.error, hence the date in the ERROR record. The FETCH_ERROR test against the OpenSearch module keeps the record.

The status updater cache hides this as long as the URL is in it. After a topology restart, or once the entry has expired or been evicted, the DISCOVERED tuple reaches Solr. I first noticed this in a crawl with the Solr archetype: in a second crawl topology, the 8 outlinks of index.html were fetched again within a minute although none was due, and URLs that failed twice ended with fetch.error.count: 1.

From the code, an ERROR URL would also become due at once with fetchInterval.error: -1. For a URL denied by robots.txt the fetcher checks again, so the URL itself would get no request. The code at 3.7.0 sends the same add. I only ran this on main.

Solr's optimistic concurrency could give the same behaviour as OpenSearch: a negative _version_ means the document must not exist, and failOnVersionConflicts=false (SOLR-13320) lets the rest of a batch through. @mvolikas, would that fit the async batches of SolrConnection? I can open a PR with the test.

Separately, the bolt acks right after addAsync, before the update reaches Solr, which is why the test has to wait for the record to appear.

dpol1 avatar Nov 06 '26 17:11 dpol1

ping @mvolikas here, when you have time ;-)

dpol1 avatar Nov 06 '26 18:11 dpol1

Yes, it seems we should only create if absent for DISCOVERED like we do for OpenSearch. The proposed fix also seems reasonable; we just need to confirm it works for both standalone + cloud mode (for multiple shards too).

mvolikas avatar Nov 08 '26 13:11 mvolikas