Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error: Uncaught RuntimeException: Unable to claim actions. Database error #720

Open
4 tasks
vmanthos opened this issue Apr 11, 2023 · 2 comments · May be fixed by #725
Open
4 tasks

PHP Fatal error: Uncaught RuntimeException: Unable to claim actions. Database error #720

vmanthos opened this issue Apr 11, 2023 · 2 comments · May be fixed by #725
Assignees
Labels
3rd party compatibility effort [S] 1-2 days of estimated development time priority: medium Issues which are important, but no one will go out of business. severity: moderate type: bug

Comments

@vmanthos
Copy link
Contributor

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version ✔️
  • Used the search feature to ensure that the bug hasn’t been reported before ✔️

Describe the bug

The following PHP fatal errors popped up while testing WP Rocket - TestRail Case <- Internal Link:

[11-Apr-2023 10:24:39 UTC] PHP Fatal error:  Uncaught RuntimeException: Unable to claim actions. Database error. in /var/www/example.com/htdocs/wp-content/plugins/imagify/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_DBStore.php:864
Stack trace:
#0 /var/www/example.com/htdocs/wp-content/plugins/imagify/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_DBStore.php(778): ActionScheduler_DBStore->claim_actions()
#1 /var/www/example.com/htdocs/wp-content/plugins/imagify/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_HybridStore.php(221): ActionScheduler_DBStore->stake_claim()
#2 /var/www/example.com/htdocs/wp-content/plugins/imagify/inc/Dependencies/ActionScheduler/classes/ActionScheduler_QueueRunner.php(157): ActionScheduler_HybridStore->stake_claim()
#3 /var/www/example.com/htdocs/wp-content/plugins/imagify/inc/Dependencies/ActionScheduler/classes/ActionScheduler_QueueRunner.php(136): ActionScheduler_QueueRunner->do_batch()
#4 /var/www/example.com/htdocs/wp-includes/class-wp-hook.php(308): ActionScheduler_QueueRunner->run()
#5 /var/www/example.com/htdocs/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#6 /var/www/example.com/htdocs/wp-includes/plugin.php(517): WP_Hook->do_action()
#7 /var/www/example.com/htdocs/wp-content/plugins/imagify/inc/Dependencies/ActionScheduler/classes/ActionScheduler_AsyncRequest_QueueRunner.php(52): do_action()
#8 /var/www/example.com/htdocs/wp-content/plugins/ninja-forms/includes/Libraries/BackgroundProcessing/classes/wp-async-request.php(153): ActionScheduler_AsyncRequest_QueueRunner->handle()
#9 /var/www/example.com/htdocs/wp-includes/class-wp-hook.php(308): WP_Async_Request->maybe_handle()
#10 /var/www/example.com/htdocs/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#11 /var/www/example.com/htdocs/wp-includes/plugin.php(517): WP_Hook->do_action()
#12 /var/www/example.com/htdocs/wp-admin/admin-ajax.php(188): do_action()
#13 {main}
  thrown in /var/www/example.com/htdocs/wp-content/plugins/imagify/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_DBStore.php on line 864
[11-Apr-2023 10:24:42 UTC] WordPress database error Table 'example_db.wp_actionscheduler_actions' doesn't exist for query SELECT COUNT(DISTINCT claim_id) FROM wp_actionscheduler_actions WHERE claim_id != 0 AND status IN ( 'pending', 'in-progress') made by do_action('wp_ajax_as_async_request_queue_runner'), WP_Hook->do_action, WP_Hook->apply_filters, WP_Async_Request->maybe_handle, ActionScheduler_AsyncRequest_QueueRunner->handle, ActionScheduler_AsyncRequest_QueueRunner->maybe_dispatch, ActionScheduler_AsyncRequest_QueueRunner->allow, ActionScheduler_Abstract_QueueRunner->has_maximum_concurrent_batches, ActionScheduler_HybridStore->get_claim_count, ActionScheduler_DBStore->get_claim_count
[11-Apr-2023 10:24:42 UTC] WordPress database error Table 'example_db.wp_actionscheduler_actions' doesn't exist for query SELECT a.action_id FROM wp_actionscheduler_actions a WHERE 1=1 AND a.status IN ('pending') AND a.scheduled_date_gmt <= '2023-04-11 10:24:42' LIMIT 0, 5 made by do_action('wp_ajax_as_async_request_queue_runner'), WP_Hook->do_action, WP_Hook->apply_filters, WP_Async_Request->maybe_handle, ActionScheduler_AsyncRequest_QueueRunner->handle, ActionScheduler_AsyncRequest_QueueRunner->maybe_dispatch, ActionScheduler_AsyncRequest_QueueRunner->allow, ActionScheduler_Store->has_pending_actions_due, ActionScheduler_HybridStore->query_actions, ActionScheduler_DBStore->query_actions
[11-Apr-2023 10:24:47 UTC] WordPress database error Table 'example_db.wp_actionscheduler_actions' doesn't exist for query SELECT a.action_id FROM wp_actionscheduler_actions a WHERE 1=1 AND a.hook='action_scheduler/migration_hook' AND a.status IN ('in-progress') ORDER BY a.scheduled_date_gmt ASC LIMIT 0, 1 made by require_once('wp-admin/admin.php'), require_once('wp-load.php'), require_once('/var/www/example.com/wp-config.php'), require_once('wp-settings.php'), do_action('wp_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->is_migration_scheduled, as_next_scheduled_action, ActionScheduler_Store->query_action, ActionScheduler_HybridStore->query_actions, ActionScheduler_DBStore->query_actions
[11-Apr-2023 10:24:47 UTC] WordPress database error Table 'example_db.wp_actionscheduler_actions' doesn't exist for query SELECT a.action_id FROM wp_actionscheduler_actions a WHERE 1=1 AND a.hook='action_scheduler/migration_hook' AND a.status IN ('pending') ORDER BY a.scheduled_date_gmt ASC LIMIT 0, 1 made by require_once('wp-admin/admin.php'), require_once('wp-load.php'), require_once('/var/www/example.com/wp-config.php'), require_once('wp-settings.php'), do_action('wp_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->is_migration_scheduled, as_next_scheduled_action, ActionScheduler_Store->query_action, ActionScheduler_HybridStore->query_actions, ActionScheduler_DBStore->query_actions
[11-Apr-2023 10:27:17 UTC] Cron unschedule event error for hook: rocket_critical_css_generation_cron, Error code: could_not_set, Error message: The cron event list could not be saved., Data: {"schedule":"rocket_critical_css_generation_cron_interval","args":[],"interval":300}

which is similar to this: wp-media/wp-rocket#5435,

and:

PHP Fatal error:  Uncaught InvalidArgumentException: Unidentified action 47 in /var/www/example.com/htdocs/wp-content/plugins/imagify/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_DBStore.php:1001
Stack trace:
#0 /var/www/example.com/htdocs/wp-content/plugins/imagify/inc/Dependencies/ActionScheduler/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php(70): ActionScheduler_DBStore->mark_failure()
#1 /var/www/example.com/htdocs/wp-content/plugins/imagify/inc/Dependencies/ActionScheduler/classes/ActionScheduler_QueueRunner.php(166): ActionScheduler_Abstract_QueueRunner->process_action()
#2 /var/www/example.com/htdocs/wp-content/plugins/imagify/inc/Dependencies/ActionScheduler/classes/ActionScheduler_QueueRunner.php(136): ActionScheduler_QueueRunner->do_batch()
#3 /var/www/example.com/htdocs/wp-includes/class-wp-hook.php(308): ActionScheduler_QueueRunner->run()
#4 /var/www/example.com/htdocs/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#5 /var/www/example.com/htdocs/wp-includes/plugin.php(565): WP_Hook->do_action()
#6 /var/www/example.com/htdocs/wp-cron.php(188): do_action_ref_array()
#7 {main}
  thrown in /var/www/example.com/htdocs/wp-content/plugins/imagify/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_DBStore.php on line 1001
[11-Apr-2023 11:13:28 UTC] WordPress database error Table 'example_db.wp_actionscheduler_actions' doesn't exist for query SELECT action_id FROM wp_actionscheduler_actions WHERE claim_id = 4 made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, ActionScheduler_FatalErrorMonitor->handle_unexpected_shutdown, ActionScheduler_DBStore->release_claim
[11-Apr-2023 11:13:28 UTC] WordPress database error Table 'example_db.wp_actionscheduler_claims' doesn't exist for query DELETE FROM `wp_actionscheduler_claims` WHERE `claim_id` = 4 made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, ActionScheduler_FatalErrorMonitor->handle_unexpected_shutdown, ActionScheduler_DBStore->release_claim

To Reproduce

Although not 100% reproducible the following should do the trick.

Steps to reproduce the behavior:

  1. Imagify is optimizing images.
  2. Delete the Action Scheduler tables in the database.
  3. Check the debug.log.

Expected behavior

No PHP errors should occur.

Backlog Grooming (for WP Media dev team use only)

  • Reproduce the problem
  • Identify the root cause
  • Scope a solution
  • Estimate the effort
@piotrbak piotrbak added type: bug 3rd party compatibility priority: medium Issues which are important, but no one will go out of business. severity: moderate needs: grooming labels Apr 13, 2023
@CrochetFeve0251
Copy link
Contributor

Identify the root cause

The root cause is the same as wp-media/wp-rocket#5435, AS is creating an error when it can't fetch actions when the table doesn't exists.

Scope a solution

We could apply the same solution by logging instead of failing when AS raise an error.

Estimate the effort

Effort S

@CrochetFeve0251 CrochetFeve0251 added effort [S] 1-2 days of estimated development time and removed needs: grooming labels Apr 18, 2023
@CrochetFeve0251 CrochetFeve0251 linked a pull request May 2, 2023 that will close this issue
@CrochetFeve0251 CrochetFeve0251 self-assigned this May 2, 2023
@piotrbak piotrbak added this to the 2.1.2 milestone May 22, 2023
@piotrbak piotrbak removed this from the 2.1.2 milestone Jun 29, 2023
@Mai-Saad
Copy link

Happening in this scenario:
Scenario:
1- delete AS actions table
2- fresh install and activate of the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party compatibility effort [S] 1-2 days of estimated development time priority: medium Issues which are important, but no one will go out of business. severity: moderate type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants