perf(douyu): 消除任务锁竞争并增加创建背压
This commit is contained in:
@@ -138,7 +138,10 @@ def _mark_attempt_failed(
|
||||
失败重试会新建记录或新 attempt,因此是新的一条 —— 这是对的,那是新的事实。
|
||||
"""
|
||||
completed_at = datetime.now(UTC)
|
||||
attempt_at = task.attempt_at or completed_at
|
||||
# MySQL DATETIME(0) 会按毫秒四舍五入到整秒。若 source_ref 使用内存里
|
||||
# 带微秒的原值,第一次写 13:57:13.999 会落成 13:57:14;第二次重读后
|
||||
# 幂等键变成下一秒,唯一索引就无法拦住重复事件。先截断到整秒再统一使用。
|
||||
attempt_at = task.attempt_at or completed_at.replace(microsecond=0)
|
||||
attempt_utc = (
|
||||
attempt_at.replace(tzinfo=UTC)
|
||||
if attempt_at.tzinfo is None
|
||||
|
||||
Reference in New Issue
Block a user