Had a similar issue ... strange error .. not seen before and server been running just fine for years!!! Don't re-call the details now, but through investigation had to do with clean up of the locks in moodledata/lock ... cron/task runs, whatever it runs, moodle locks so no new data etc. can sneak in there until the cron/task completed. Once done, lock is cleaned up/cleared.
What I did ...
removed the contents of moodledata/lock/ (after creating a quick backup of it - just in case) ... moodle repopulated on next cron run.
Issue seem to go away.
In scheduled task there are
Analytics cleanup \core\task\analytics_cleanup_task
Predict models \tool_analytics\task\predict_models
and a
Train models \tool_analytics\task\train_models
You could run the last via command line to check.
moodlecode/admin/tool/task/cli
php schedule_task.php --execute="\tool_analytics\task\train_models"
That should by pass any topics addon, shouldn't it?
'SoS', Ken