Re: mysql innodb transaction concurrency
Date: August 20, 2011 09:00AM
Hi Rick,
A final one, sorry to bother you.
I am bit worried about using cron job. Since it would be hosted on scalable cloud environment.
I am thinking like this, Please Guide me If I am wrong.
Sol
---
Instead of using cron job, System would check how many are reserved since 9 mintues (minute extra to be safe). So That I don't need cron at all.
An item has 3 states:
* In inventory, available for someone to purchase; (row lock through select for update)
* Grabbed by someone, but awaiting confirmed purchase; others are not allowed to initiate a purchase on this item; (You could provide the info "this items is 'tentatively' sold.) (lock table using select for update)
* Purchased. (lock table using select for update)
Like this
---------
1) SELECT item_id, items_rem, sell_max, sell_max_person, customer_pays FROM items WHERE item_id = ? FOR UPDATE
2)SELECT SUM(quantity) as count FROM reservations WHERE item_id = ? AND subscriber_id = ? AND created_at >= DATE_SUB( NOW(), INTERVAL 540 SECOND ) FOR UPDATE
3)SELECT SUM(quantity) as count FROM purchases WHERE item_id = ? AND user_id = ? FOR UPDATE
Will this cause any issue?
Edited 2 time(s). Last edit at 08/20/2011 09:08AM by venu gopal.