feat(shipping-notice): 收敛订单处理状态与履约门禁
This commit is contained in:
1 parent
bffcd55b40
commit
70dd0051b8
153 files changed
+10916
-4296
No files matched your search
@@ -381,11 +381,12 @@ def create_derived_file_asset_from_bytes(
|
||||
expires_at=expires_at,
|
||||
)
|
||||
|
||||
# [STEP] SAVEPOINT:唯一约束冲突时只回滚本插入,保留外层 Document 事务
|
||||
# [STEP] 幂等插入派生资产:先查后建规避常见唯一约束冲突;冲突时回读已有行。
|
||||
# 不使用 begin_nested SAVEPOINT:被 SAVEPOINT 语义包住的 INSERT 在同一 Session
|
||||
# 内创建多个派生资产时,其行对后续 autoflush 的 UPDATE 不可见,会触发 StaleDataError。
|
||||
try:
|
||||
with db.session.begin_nested():
|
||||
db.session.add(asset)
|
||||
db.session.flush()
|
||||
db.session.add(asset)
|
||||
db.session.flush()
|
||||
except IntegrityError:
|
||||
raced = _find_derived_by_parent_hash(parent_id=int(parent.id), content_hash=content_hash)
|
||||
if raced is not None:
|
||||
|
||||
Reference in new issue
Block a user