Problem/Motivation
On a site with 1000s (but not millions) of nodes, running drush sapi-rt repeats the following message 100s of times:
[notice] Successfully executed 0 pending tasks.
Finally, at the very end, it says:
> [notice] Message: Successfully executed 1 pending task.
If you run the batch via the UI by clicking on "Rebuild tracking information" and submit the confirmation form, you just see :
Successfully executed 0 pending tasks.
Completed 0 of 1. 0%
the whole time, until the very end (many minutes later) when it's finally done with everything.

Steps to reproduce
Either run drush sapi-rt
Or, click on "Rebuild tracking information" link on a SAPI index and click the confirm form and watch the batch process.
Proposed resolution
Either:
A) Don't print something at the end of each batch that we're not done yet, and only print out the single "Successfully executed 1 pending task" at the end if it succeeded, or an error message if not.
B) Print something more relevant at the end of each batch, like "processed 2350 out of 120129 items, tracking 2143" (or whatever).
I'm not yet entirely sure what this batch process is exactly doing, but it seems plausible that we'd need a single count of all entities on the system and then know we're going to investigate 100 at a time to decide if they need to be indexed or not. More or less. So, we could use the batch API to report the total # of batches we're going to need in advance, and then the progress bar would work, and we could actually see something happening in real time.
Remaining tasks
- Decide an appropriate direction.
- Implement it.
- Add/update tests about it.
- Reviews / refinements.
- RTBC.
- Commit.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3182306-3--rebuild_tracker_batch_output.patch | 858 bytes | drunken monkey |
Comments
Comment #2
dwwAdding a screenshot of the 0% progress bar (the whole time) when you run this batch via the web UI, not drush...
Comment #3
drunken monkeyWhile having a more helpful status message, as proposed in B), certainly sounds good, I’m afraid I don’t see a way to cleanly achieve this. The architecture we have running the batch is more or less completely separated from the “knowledge” of rebuilding the tracker, so I don’t see a simple method for getting information from one to the other. (Especially as this is a rather small problem, on the whole.)
However, we can probably agree that printing “Successfully executed 0 pending tasks.” will almost never be helpful, so maybe we can just skip that? Please test the attached patch and see whether that behaves more sensibly.
Comment #4
sokru commentedLooks good to me, only thing that would be nice (but seems rather big rewrite) to display some message like "On large sites this command can take a long time".
Comment #6
drunken monkeyGood to hear, thanks for your feedback. Committed.
Regarding the additional warning, that also sounds sensible. Please create a new issue for that, if you want.