Fixed Division by zero fatal crash during v2.1.12 to v2.2.2 Upgrade

Steve Gibson

Active member
Affected version
v2.2.2
Dear XenForo Gods...

I decided that I'd waited long enough for the post v2.2 dust to settle and that it would likely be safe for me to upgrade from v2.1.12 to v2.2.2.

The upgrading process came to an abrupt and fatal end with this diagnostic dump:

ErrorException: [E_WARNING] Division by zero in src\XF\Job\AbstractJob.php at line 72
XF::handlePhpError() in src\XF\Job\AbstractJob.php at line 72
XF\Job\AbstractJob->calculateOptimalBatch() in src\XF\Job\PhraseRebuild.php at line 91
XF\Job\PhraseRebuild->run() in src\XF\Job\Atomic.php at line 38
XF\Job\Atomic->run() in src\XF\Job\Manager.php at line 258
XF\Job\Manager->runJobInternal() in src\XF\Job\Manager.php at line 200
XF\Job\Manager->runJobEntry() in src\XF\Job\Manager.php at line 151
XF\Job\Manager->runUnique() in src\XF\Install\Controller\AbstractController.php at line 24
XF\Install\Controller\AbstractController->manualJobRunner() in src\XF\Install\Controller\Upgrade.php at line 262
XF\Install\Controller\Upgrade->actionRunJob() in src\XF\Mvc\Dispatcher.php at line 350
XF\Mvc\Dispatcher->dispatchClass() in src\XF\Mvc\Dispatcher.php at line 261
XF\Mvc\Dispatcher->dispatchFromMatch() in src\XF\Mvc\Dispatcher.php at line 113
XF\Mvc\Dispatcher->dispatchLoop() in src\XF\Mvc\Dispatcher.php at line 55
XF\Mvc\Dispatcher->run() in src\XF\App.php at line 2300
XF\App->run() in src\XF.php at line 488
XF::runApp() in install\index.php at line 14

I will roll back to my pre-upgrade backup... but I'd love to be able to upgrade to v2.2.2

How should I proceed?? Thanks VERY much!!
 
@nicodak : Thanks, but that's what I did. There's no reason to imagine that doing the same thing again would generate a different result. I'm sure that the XenForo guys will look at the crash trace and see what happened. Then they'll suggest how I should proceed. :)
 
@nicodak : I used the one-click ACP upgrade, and everything appeared to be going well. I downloaded the new file set and crunched away on them for quite a while, perhaps 30 minutes, showing progress as it went. But rather than finishing up, the process crashed with that fatal division by zero error. It left the XenFofo board offline and inoperative. I'm in the process of recovering... but I'll need one of the XenForo developers to examine the crash details and suggest how to prevent it from recurring.
 
I saw you've got a large forum with thousands and thousands posts and it's not recommended to use ACP upgrade in this case.
You should have used the ftp method. But i understand your fears now so it is wise to wait for a XF developer's advice.
 
This isn't upgrade method related.

Have you changed the jobMaxRunTime in your src/config.php at all? If so, what have you set it to?

Overall, I can't see how this would happen unless that value has been overridden to 0 or an exceptionally large number. (The default is 8, which refers to 8 seconds.)
 
@Mike :
This isn't upgrade method related.

Have you changed the jobMaxRunTime in your src/config.php at all? If so, what have you set it to?

Overall, I can't see how this would happen unless that value has been overridden to 0 or an exceptionally large number. (The default is 8, which refers to 8 seconds.)
So... The only thing that occurs to me as a possible work-around might be to explicitly set jobMaxRunTime to some super-safe value? I don't know why your default might not have applied, since as noted I've never overwritten it. But perhaps explicitly setting it might work??

Thanks for any light you might be able to shed. :)
 
@Mike : Just to follow-up and put this one to rest... I examined the code surrounding the division by zero error and decided that I needed to have it crash again so that I could examine the call stack to see what didn't make sense.

So, fresh backups in hand, I went ahead and re-ran the control panel upgrade... And it made it past the PhraseRebuild'ing where it had died the first time and successfully finished the upgrade. So, whatever that was, it was a one-off. :)

All the best... And thanks again for the marvelous forum system! :)
 
I'm going to leave this open as we can probably make the code more defensive, though I still wish I could pinpoint the cause.

I'm not entirely surprised that it wasn't reproducible as it was probably dependent on the exact behaviour through the rebuild steps but glad to know you were able to get past it.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.3).

Change log:
Protect against a division by zero error when running jobs/cache rebuilds.
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom