Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email firstname.lastname@example.org
From: Don Read (don_readatt.net)
Date: Fri Dec 25 2009 - 12:36:41 CST
On Fri, 25 Dec 2009 15:41:40 +0800 Eva said:
> I have a table, say its stru is like:
> domain ip noticed
> The column "noticed" is an enum value (eigher 0 or 1).
> When process one update "ip", it will set "noticed" to 0.
> Then process two know the status changed, it will do something and set "noticed" to 1.
> What the problem I meet is, when process two read ip from the table, and before it update the "noticed" to 1 (it has to do something with the ip, and this will take few seconds), process one also updated the table with new ip and noticed=0. Under this case, process two has gotten the outdated IPs (not the new ones updated by process one), since it will set noticed=1 finally so it doesn't have a chance to find it's using old IPs.
> So how to resolve this problem?
> Thanks for my newbie questions.
> Merry Holidays!
Change noticed to enum('new', 'scan', 'done') not null default 'new';
When proc two runs, it should
"UPDATE noticed='scan' WHERE noticed='new'"
Then repeat the scan with "SELECT ... WHERE noticed='scan'"
and finally it should "UPDATE domain=whatever, ... noticed='done'"
Don Read don_readatt.net
It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql