0

I have an agent i defined a job for that php agent file .but if second agent run after 1 minutes and previous agent work not finished yet .its make a problem ..... i want to flag selected rows in every agent that if another agent runs new query they haven't interference

how i change this query is the best way is make a field in that table for selected or not ?and update that field ?

db::query("SELECT 1000 FROM web-service WHERE `state`= 1 AND `fetch_id`="fetchid" ")// 

1-state = 1 is condition for my products

2-i use fetch id to imputation id to each agent what is the best way ?

4
  • 1
    I haven't seen this many agents since Matrix Revolutions. Commented Aug 3, 2012 at 15:37
  • 1
    ¿How a select query is affected by another select query? You are not showing all the relevant code Commented Aug 3, 2012 at 15:37
  • 1
    @Matt its a queue and i connect to a gateway maybe gateway responding late and agent take time for 2 minutes my job run this php file every 1 minutes Commented Aug 3, 2012 at 15:39
  • 1
    @Alfabravo i described this for matt Commented Aug 3, 2012 at 15:40

1 Answer 1

0

If I understand your question, you don't want multiple scripts working on the same rows at the same time. This is known as contention and can be solved a number of ways.

One way I have solved this problem in the past is to only run my script if it isn't already running. You can do this through a shell script as defined here: Shell script: Ensure that script isn't executed if already running

Sign up to request clarification or add additional context in comments.

4 Comments

my friend i want to 2 agnet work at the same time but with that own select products
You can add a column that flags if the product is "in use", set it after the SELECT, then update it once your script finishes.
hmm is it the best way ? for example can mysql recognize that witch rows selected now and runing ?or the best way is update a field like you for example in use?
Once your SELECT is performed, MySQL's job is done. It has no idea what you're doing until the data is manipulated again using an UPDATE.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.