Codeinwp / Codeinwp/feedzy-rss-feeds

Add transient-based mutex lock to prevent concurrent import cron execution

Open
#1,197 0 comments 1 reaction 2 assignees View on GitHub

@ineagu is already working on this.

Since Mar 23, 2026.

Dominant language
PHP
Stars
121
Forks
27
Avg merge
2d 1h
Merged PRs (30d)
11

Description

Problem

WordPress pseudo-cron can fire the same scheduled event multiple times if page loads overlap. Without a lock, the same import job can run concurrently, causing duplicate posts (TOCTOU race condition in duplicate detection) and wasted server resources.

Solution

import.php — In run_cron(), add a per-job transient lock:

  • Before each job: check get_transient('feedzy_import_lock_' . $job->ID), skip if active
  • Set transient with 10-minute TTL before running the job
  • Use finally { delete_transient($lock_key); } to ensure cleanup on both success and error
  • Log skipped jobs for debugging

Files Affected

  • includes/admin/feedzy-rss-feeds-import.php

Acceptance Criteria

  • Same import job cannot run concurrently
  • Lock is always released after job completes (success or error)
  • Skipped jobs are logged with job title and ID
  • Different import jobs can still run in parallel
  • Lock expires after 10 minutes even if cleanup fails (safety net)

Priority: High — prevents duplicate imported posts
Regression risk: Low — worst case a job is skipped once, retries on next cron cycle

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.