Closed (fixed)
Project:
Drush
Version:
7.x-5.7
Component:
Core Commands
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
26 Oct 2012 at 21:50 UTC
Updated:
8 May 2013 at 20:40 UTC
Jump to comment: Most recent file
It's possible to get drush search-index in an infinite loop, for example if you have Solr search installed but set to read only mode. search-index just iterates through, invoking hook_update_index() until the number of remaining items reaches zero. But in the case described, the number remaining never changes, so it keeps going and never completes. (If you're asking why you would run search-index with Solr set to read only, remember that you might want core search to index. Besides, this is only an example.) Perhaps we should set a limit on how long search-index can iterate without making progress and then fail with an error. Patch to follow.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | drush-infinite-search-index.patch | 855 bytes | abautu |
| #1 | drush-search-index-infinite-loop-1824510-1.patch | 1.21 KB | traviscarden |
Comments
Comment #1
traviscarden commentedHere's a patch to get things started. It just tallies consecutive unproductive iterations and fails after three with the message "Indexing stalled with @number items remaining." The test for unproductive iterations may be a little naive--it just assumes that if the number of unindexed items remaining hasn't changed from the last iteration that it didn't progress, but if nodes were added during that iteration equal in number to those indexed it would return a false positive. There's probably a slim chance of that happening, but I mention it anyway. Perhaps requiring three such instances in a row is adequate. Perhaps it needs to check that the difference between total nodes and number unindexed hasn't changed. In any case, this gets the discussion started.
Comment #2
kenorb commentedDuplicates:
#985778: search-index does not process
#880554: search-index never completes, but admin/settings/search shows site as 100% indexed
#955736: drush search-index fails
Comment #3
kenorb commentedLooks better for me:
Apart of this, that the message is repeated 3 times.
But at least doesn't gets into an infinite loop
Comment #4
moshe weitzman commentedLooks fine to me. Any objections?
Comment #5
abautu commentedIt's more or less related to your problem, but from my experience, indexing with ApacheSolr (branch 6.1) will always create an infinite loop, even for a read/write index. This happens because ApacheSolr uses variables to store current index status (compared to core search which queries the tables).
In short, drush calls a subprocess to index nodes. The subprocess will update variables, but this updates are not visible back in the main process (due to caching variables). In the main process, when drush asks again for the the indexing status, ApacheSolr uses the old variable values (instead of updated ones). The indexing runs normally, but drush always report the same number of remaining items. When indexing is completed, that's when your original problem kicks in, too.
I'm attaching a patch for this, which would complement the previous one.
Cheers,
Andrei
Comment #6
traviscarden commentedThank you, @abautu. That should probably be a separate issue. Would you create one and link to it from here?
Comment #7
abautu commentedSure. Done here: #1918922: Search-index gets into an infinite loop when using ApacheSolr due to variable caching
Comment #8
moshe weitzman commentedCommitted to 5 and 6.