Again ... not a developer ...
One of the changes in 3.9.x it runs through setting all defaults to core/plugins on a minor update ... at the tail end of upgrade.php a long pause while it does that. Think some have reported issues after an update and tracked it down to a setting gone missing - not verified nor reproduceable so ????
adhoc itself has been around since 3.0, however.
Might run it from command line with options to see what's up with it:
Ad hoc cron tasks.
-h, --help Print out this help
--showsql Show sql queries before they are executed
--showdebugging Show developer level debugging information
-e, --execute Run all queued adhoc tasks
-k, --keep-alive=N Keep this script alive for N seconds and poll for new adhoc tasks
-i --ignorelimits Ignore task_adhoc_concurrency_limit and task_adhoc_max_runtime limits
\$sudo -u www-data /usr/bin/php admin/cli/adhoc_task.php --execute