File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ def __init__(self):
2727 self .current_id .arr [0 ] = 0
2828 self .current_id .arr [1 ] = 0
2929 self .lock = AtomicShmLock (f"{ get_unique_server_name ()} _req_id_gen_lock" )
30+ self .alloced_max_req_id : int = 0
3031
3132 def _check_and_set_new_id_range (self ):
3233 need_update_range = self .current_id .arr [0 ] + MAX_BEST_OF >= self .current_id .arr [1 ]
@@ -61,6 +62,13 @@ def generate_id(self):
6162 self ._check_and_set_new_id_range ()
6263 id = self .current_id .arr [0 ]
6364 self .current_id .arr [0 ] += MAX_BEST_OF
65+
66+ # 请求 id 在 多 httpserver worker情况的极端启动情况下,可能存在请求id对应的共享内存被重新修改
67+ # 导致请求 id 错乱的问题。
68+ self .alloced_max_req_id = max (self .alloced_max_req_id , id )
69+ if id < self .alloced_max_req_id :
70+ logger .error (f"alloc req_id error, current alloc id { id } < max alloced id { self .alloced_max_req_id } " )
71+
6472 return id
6573
6674
You can’t perform that action at this time.
0 commit comments