Here's an example. I see that today at 13:41:22 there were several php errors, all of which look like this:
[15-Jul-2014 13:41:22 America/Vancouver] Default exception handler: Can not find data record in database table course. Debug: SELECT * FROM {course} WHERE id = ?
[array (
0 => 96133,
)]
Error code: invalidrecord
* line 1385 of \lib\dml\moodle_database.php: dml_missing_record_exception thrown
* line 1361 of \lib\dml\moodle_database.php: call to moodle_database->get_record_select()
* line 66 of \file.php: call to moodle_database->get_record()
I checked through the logs and found that someone had accessed a forum page at that time. Looking at the profile image thumbnails, I found that one of them had contextid 96133, which matches the value in the error above.
The query is looking in 'course' rather than in 'context', which is why it's not finding the record.
All that said:
a) When I loaded the forum page, all images loaded correctly.
b) Profile images not loading has been one of the more consistent manifestations of the problem.
Again I wonder, what in the code could cause the query to be done on the 'course' table one minute, and - correctly - on the 'context' table the next?