使用分布式锁做幂等的一个坑
| 线程1 | 线程2 |
| putifabsentexpire 成功 | |
|
putifabsentexpire 成功,因为读从库 put(orderid, instanceid_threadid |
|
| get thread id == current? | |
|
认为取得锁失败,对于 1)幂等场景,直接退出即可 2)分布式锁场景,自旋 |
| 线程1 | 线程2 |
| putifabsentexpire 成功 | |
|
putifabsentexpire 成功,因为读从库 put(orderid, instanceid_threadid |
|
| get thread id == current? | |
|
认为取得锁失败,对于 1)幂等场景,直接退出即可 2)分布式锁场景,自旋 |