I know this is old, but it happened to me over the weekend. In my situation, I know why it happened (it was due to what looks like a MySQL bug). Specifically, there was a situation where prepared statements would fail with
MySQL fetch error : Commands out of sync; you can't run this command now
. Not so coincidentally, the cron job entry record was lost in all XF2 sites, and it was not lost in XF1 sites (didn't really dig into the differences on how XF1 handles the xf_deferred table vs. XF2 xf_job). But whatever that difference is, it caused the issue for me only in XF2.
I'm not super
worried about it, because it was the first time I'd seen MySQL do something like that in what is probably 20 years now of running it, and I filed a bug report so hopefully whatever it was will be fixed going forward: https://bugs.mysql.com/bug.php?id=106588
That being said, it would be nice if XF had an integrity check of some sort so it could "self heal" if the xf_job cron record was lost (for whatever reason). For example, maybe have a hidden debug setting/timestamp of the last time there was a check to make sure the cron record exists. Add the check to XF\Job\Manager::__construct() where if more than 24 hours (or 1 hour, or whatever) has passed since it last checked for the record, add it (and log an entry into the error log so someone knows something happened to it). In my case, I didn't realize the cron tasks weren't running for awhile. Having a simple check for the record like that would make XenForo a bit more durable when something unforeseen happens to that record.