Commit 5df3342c authored by Erick Hitter's avatar Erick Hitter
Browse files

Remove create lock

This lock has created more trouble than it's prevented, namely by exacerbating creation loops under load. When an event isn't created, code usually keeps trying; duplicates should instead be addressed during execution.
parent 6988da3b
......@@ -10,8 +10,6 @@ class Cron_Options_CPT extends Singleton {
/**
* Class properties
*/
const LOCK = 'create-jobs';
const POST_TYPE = 'a8c_cron_ctrl_event';
const POST_STATUS_PENDING = 'inherit';
const POST_STATUS_COMPLETED = 'trash';
......@@ -33,9 +31,6 @@ class Cron_Options_CPT extends Singleton {
add_filter( 'option_jetpack_sync_settings_post_types_blacklist', array( $this, 'exclude_from_jetpack_sync' ), 999 );
add_filter( 'default_option_jetpack_sync_settings_post_types_blacklist', array( $this, 'exclude_from_jetpack_sync' ), 999 );
// Lock for post insertion, to guard against endless event creation when `wp_next_scheduled()` is misused
Lock::prime_lock( self::LOCK );
// Option interception
add_filter( 'pre_option_cron', array( $this, 'get_option' ) );
add_filter( 'pre_update_option_cron', array( $this, 'update_option' ), 10, 2 );
......@@ -291,11 +286,6 @@ class Cron_Options_CPT extends Singleton {
* Also doesn't call `wp_insert_post()` because this function is needed before post types and capabilities are ready.
*/
public function create_or_update_job( $timestamp, $action, $args, $update_id = null ) {
// Limit how many events to insert at once
if ( ! Lock::check_lock( self::LOCK, JOB_CREATION_CONCURRENCY_LIMIT ) ) {
return false;
}
global $wpdb;
// Build minimum information needed to create a post
......@@ -352,9 +342,6 @@ class Cron_Options_CPT extends Singleton {
// Delete internal cache
wp_cache_delete( self::CACHE_KEY );
// Allow more events to be created
Lock::free_lock( self::LOCK );
}
/**
......
......@@ -11,11 +11,6 @@ const JOB_TIMEOUT_IN_MINUTES = 10;
const JOB_LOCK_EXPIRY_IN_MINUTES = 30;
const JOB_CONCURRENCY_LIMIT = 10;
/**
* Job creation
*/
const JOB_CREATION_CONCURRENCY_LIMIT = 5;
/**
* Locks
*/
......
......@@ -20,20 +20,6 @@ class Lock extends \WP_CLI_Command {
$this->get_reset_lock( $args, $assoc_args, $lock_name, $lock_limit, $lock_description );
}
/**
* Manage the lock that limits concurrent job creation
*
* @subcommand manage-create-lock
* @synopsis [--reset]
*/
public function manage_create_lock( $args, $assoc_args ) {
$lock_name = \Automattic\WP\Cron_Control\Cron_Options_CPT::LOCK;
$lock_limit = \Automattic\WP\Cron_Control\JOB_CREATION_CONCURRENCY_LIMIT;
$lock_description = __( 'This lock limits the number of events created concurrently.', 'automattic-cron-control' );
$this->get_reset_lock( $args, $assoc_args, $lock_name, $lock_limit, $lock_description );
}
/**
* Manage the lock that limits concurrent execution of jobs with the same action
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment