问题
Need to retrieve latest data whose status is 1 and then setting status 0 for the same using LockMode Pessimistic.
so Db column are => id(autogenerated), count, category_key, status(initially 1 for all).
I have pre-populated data in db where for each category_key combination I have 10000 count....
so lets say for DG_KK I have 1 to 10000 count with status 1 and then for DG_TG I have 1 to 10000 count with status 1. Now
Now I when I pass key DG_KK as category_key then from db using atomic fetch and update using pessimistic mode need to get the count value and then update status 0
so lets say thread1 comes with key DG_KK and get the count 1 and updated status 0 if thread2 comes with key DG_KK at the same time will or should get count 2 and update status 0 for the same and so it follows. But if thread3 comes with DG_TG it will get the count 1 and it follows the same.
来源:https://stackoverflow.com/questions/64712809/updating-and-fetching-using-pessimistic-lock