Project

General

Profile

Actions

Bug #20088

closed

Prevent PDF Embedder from using Action Scheduler

Added by Raymond Hoh 28 days ago. Updated 26 days ago.

Status:
Resolved
Priority name:
Normal
Assignee:
Category name:
Cavalcade
Target version:
Start date:
2024-04-01
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

While looking into the performance issues from our latest maintenance update, I was monitoring Cavalcade and noticed a bunch of new 'action_scheduler_run_queue' tasks. I found that the PDF Embedder plugin added usage tracking to its plugin in their latest update: https://github.com/cuny-academic-commons/cac/commit/851b5a3fd6d8dc7921e56dcba40238ac57a7c17a#diff-6edecdd2d2a0cad82a8d177ed3113d40362970a39adea1240f444e0187c821f9

To do this, the plugin utilizes the Action Scheduler library to schedule a task that sends usage data back to the developer. (Side note: In #17672, I throttled the Action Scheduler task to run every 15 minutes instead of every minute.) Since PDF Embedder is a widely-used plugin (roughly 1700 sites use it), this can somewhat explain the performance issues directly after the maintenance update this week.

Even though usage tracking is opt-in by default, the problem with the developer's implementation is the Action Scheduler library runs all the time even when usage tracking is disabled. I've posted a new topic to the wp.org plugin support forum here: https://wordpress.org/support/topic/limit-action-scheduler-to-only-run-if-usage-tracking-is-enabled/ . Hopefully they can address this soon.

For now, I'm going to look into disabling the Action Scheduler task from the PDF Embedder plugin. Once done, I'll remove all 'action_scheduler_run_queue' Cavalcade tasks related to the PDF Embedder plugin.


Related issues

Related to CUNY Academic Commons - Bug #19971: Expected Group Forum FunctionalityNew2024-03-13

Actions
Actions #1

Updated by Raymond Hoh 28 days ago

  • Related to Bug #19971: Expected Group Forum Functionality added
Actions #2

Updated by Raymond Hoh 28 days ago

Boone / Jeremy, I figured out a way to disable Action Scheduler, but it's not pretty: https://github.com/cuny-academic-commons/cac/commit/6653da3f748f0d739d710233be54b23a9cf7f35e .

I'm using the 'action_scheduler_queue_runner_class' filter: https://github.com/cuny-academic-commons/cac/blob/5121485f3b5063065494925b668709ee03bcb596/wp-content/plugins/pdf-embedder/vendor/woocommerce/action-scheduler/classes/ActionScheduler_QueueRunner.php#L26 to add a dummy class with an empty init() method, which prevents the scheduling of the task with WordPress. I'm doing a check for The Events Calendar, which legitimately uses Action Scheduler during their migration tasks. If The Events Calendar is active, we bail from using our dummy class.

Let me know what you think before deploying on production.

Actions #3

Updated by Raymond Hoh 26 days ago

  • Status changed from New to Resolved

On the dev call, Boone suggested doing the PDF Embedder checks for Action Scheduler in our existing Cavalcade mods, this is a cleaner approach than mine, so I decided to implement this in https://github.com/cuny-academic-commons/cac/commit/ce1d84f8b98fcc66cdd6fcc3349347f0233eb8b5 .

I also did an audit of the widget-for-eventbrite-api plugin and found that Action Scheduler is only necessary when the premium version of the plugin is enabled: https://github.com/cuny-academic-commons/cac/blob/2.3.x/wp-content/plugins/widget-for-eventbrite-api/widget-for-eventbrite-api.php#L91-L94 . So based off of that, I am now limiting Action Scheduler only for premium access users of the widget-for-eventbrite-api plugin.

After deploying the fix to production, I deleted the related 'action_scheduler_run_queue' tasks and now there are ~90 queued items of this task, which is down from ~1400 before. There's still roughly a twenty-minute lag in Cavalcade, but might just need to wait it out. In the meantime, I'm going to mark this as resolved.

Update: Cavalcade queue is clear as of 11am ET, so there shouldn't be any lag at the moment for now.

Actions

Also available in: Atom PDF