@blacksein 在 天啊 面经里的gap锁/插入意向锁以为不会碰到 直到今天发现了个死锁 中发帖
去年写的代码,代码是这样的:
public void lockForUserKey(String userKey) {
ULong userIdULong = findByUserForUpdate(userKey);
if (userIdULong != null) {
return;
}
dslContext.insertInto(USER, USER.USER_KEY)
.values(userKey)
.onDuplicateKeyIgnore()
.execute();
findByUserForUpdate(userKey);
}
private @Nullable ULong findByUserForUpdate(String userKe...