IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Several things happening there.
Let's get the simple things out of the way first.

Transactions don't work for MyISAM tables; they have to be InnoDB. You knew that already, didn't you? :-) And then there's MySQL's AutoCommit flag, although START TRANSACTION is supposed to disable that until you do COMMIT (or ROLLBACK). But it's probably the table-type.

The problem with the query is that you're referencing the same table in the sub-query that you're trying to update. MySQL doesn't allow that. Why can't you shift the sub-query's condition to the outer UPDATE?

UPDATE queue
SET status = 'process-$PID'
WHERE status = 'pending' AND target_time > NOW()
ORDER BY target_time
LIMIT $batch_size


That's atomic, even on MyISAM tables.

Wade.

Q:Is it proper to eat cheeseburgers with your fingers?
A:No, the fingers should be eaten separately.
New Doh!
I was over-thinking it. And this is an InnoDB table, so I'm not sure why it autocommitted.

Just put in your simpler version and yup, it works.
--

Drew
     How to do atomic select without limit in subquery? - (drook) - (2)
         Several things happening there. - (static) - (1)
             Doh! - (drook)

If it nae be Scottish, it be CRRRRRRAP!
75 ms