开发者

Ensuring app SQL select statement retrieve different rows

开发者 https://www.devze.com 2023-01-08 06:08 出处:网络
I have a MySQL InnoDB table containing \"tickets\".Tickets are either \'open\', \'locked\', \'closed\'.I have multiple remote client apps that run select queries on this table for \'open\' tickets.I w

I have a MySQL InnoDB table containing "tickets". Tickets are either 'open', 'locked', 'closed'. I have multiple remote client apps that run select queries on this table for 'open' tickets. I want to ensure that the different clients don't retrieve the same rows.

My process flow right now is:

Issue select for open... Update table set status to locked... Do stuff with the ticket Update table set status to closed.开发者_运维知识库

Obviously there's a huge gaping race condition hole there between the time a client selects and open ticket and then locks it. How do I prevent other clients accessing the same row in a non-blocking manner?

0

精彩评论

暂无评论...
验证码 换一张
取 消