I ran into a problem this week where the Drupal cron job wasn't running to completion. The cause of this appeared to be in the search module - disable it and cron ran; turn it back on and cron failed. Since people probably do want to search for stuff on the site this meant digging into the Drupal 6.1.5 source.
The first port of call was the
search_cron() routine in search.module. Adding an echo statement at the start and end showed that only the former was being displayed. This implied that somewhere further down the chain was causing the process to exit. I then added an echo statement to show which hook_update_index routine was causing the problem. It turned out to be the one in node.module. From there it was a case of finding the node id with the issue. Running domainname/?=node/nodeid for one of the IDs showed a blank page where a picture node was expected to be. I tried removing this node in the Administer content section but it refused to go away.
This meant removing that record from the
node_revisions table using phpMyAdmin. The cron job then ran perfectly with the re-enabled search module.
I have no idea how the problem node became corrupted. I'm a little worried how it terminated the generation of the search index with no obvious warning (and I couldn't see anything in error_log) but I'm now aware of the impact bad nodes can have.