mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-05 19:16:37 +00:00
fix(asset_user): 修改创建AuthBook对象锁机制,使用select_for_update替换redis_lock3
This commit is contained in:
parent
9550ea62fb
commit
ddcd4ebbfc
@ -59,10 +59,9 @@ class AuthBook(BaseUser):
|
||||
username = kwargs['username']
|
||||
asset = kwargs['asset']
|
||||
with transaction.atomic():
|
||||
# 使用select_for_update限制并发创建相同的username、asset数据
|
||||
cls.objects.select_for_update().filter(
|
||||
username=username, asset=asset, is_latest=True
|
||||
).update(is_latest=False)
|
||||
# 使用select_for_update限制并发创建相同的username、asset条目
|
||||
instances = cls.objects.select_for_update().filter(username=username, asset=asset)
|
||||
instances.filter(is_latest=True).update(is_latest=False)
|
||||
max_version = cls.get_max_version(username, asset)
|
||||
kwargs.update({
|
||||
'version': max_version + 1,
|
||||
|
Loading…
Reference in New Issue
Block a user