Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8579207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:33:46+00:00 2026-06-11T20:33:46+00:00

I came up with a very simple job queueing system using PHP, MySQL and

  • 0

I came up with a very simple job queueing system using PHP, MySQL and cron.

  1. Cron will call a website, which has a function that calls function A() every 2 seconds. A() searches and retrieves a row from table A
  2. Upon retrieving a row, A() will update that row with value 1 in column working
  3. A() then does something to the data in the retrieved row
  4. A() then insert a row in table B with the value obtained during processing step 3.

Problem: I notice that there are sometimes duplicate values in the table B due to function A() retrieving the same row from table A multiple times.

Which part of the design above is allowing the duplicate processing, and how should it be fixed?

Please don’t suggest something like rabbitMQ without at least showing how it can be implemented in more details. I read some of their docs and did not understand how to implement it. Thanks!

Update: I have a cron job that calls a page (which calls function c()) every minute. This function c() that does a loop 30 times which calls function A(), using sleep() to delay.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:33:48+00:00Added an answer on June 11, 2026 at 8:33 pm

    One problem could be the processing at first:

    Cron will call a function A() that searches and retrieves a row from table A every 2 seconds.

    The processing of this part of the script could take longer than two seconds on a table without indexes as such you could pick multiple rows.

    You could remedy this with an exclusive file lock.

    I have a feeling there is more than just the workflow, if you can show some basic code attached maybe there might be a problem in the code as well.

    edit

    I think it is timing judging by your last update:

    Update: I have a cron job that calls a page (which calls function c())
    every minute. This function c() that does a loop 30 times which calls
    function A(), using sleep() to delay.

    Thats a lot of jumping through hoops and I think you might have a threading problem where crons are overlapping.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using cakePHP and is making a very simple message board. I came
I'm going through an online lesson , which usually has a very simple one
I have a very simple PHP file. I had set the charset using PHP's
I am working on a very simple stopwatch using WPF but using the System.Diagnostics
Came across this code: <?php require_once 'HTTP/Session/Container/DB.php'; $s = new HTTP_Session_Container_DB('mysql://user:password@localhost/db'); ini_get('session.auto_start') or session_start();
I am attempting to create a very simple web interface for changing some system
While coding very simple program for removing blanks, tabs, newlines I came across something
I wrote a very simple encryption program to practice c++ and i came across
I've been working on a very simple crud generator for pylons. I came up
I have been developing a very simple text game using Objective C and Xcode.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.