How to lock a single row

后端 未结 5 501
长情又很酷
长情又很酷 2020-11-30 06:45

I have a user table with field lastusedecnumber.

I need to access and increment lastusedecnumber.

During that accessin

5条回答
  •  不知归路
    2020-11-30 07:23

    A better workaround is to create a column containting a timestamp. Whenever you want to lock the row you update it to the current time. To unlock update to a time at least x minutes in the past. Then to check if its locked check that the time stamp is at least x minutes old.

    This way if the process crashes (or the user never completes their operation) the lock effectively expires after x minutes.

提交回复
热议问题