How to properly avoid Mysql Race Conditions

前端 未结 3 651
既然无缘
既然无缘 2021-01-06 02:53

I know this has been asked before, but I\'m still confused and would like to avoid any problems before I go into programming if possible.

I plan on having an interna

3条回答
  •  佛祖请我去吃肉
    2021-01-06 03:19

    You may consider Transactions

    BEGING TRANSACTION;
    SELECT ownership FROM ....; 
    UPDATE table .....; // set the ownership if the table not owned yet
    COMMIT;
    

    and also you can ROLLBACK all the queries between the transaction if you caught an error !

提交回复
热议问题