Skip to content

Commit bd9a2a7

Browse files
author
wangzaijun
committed
fix
1 parent 98d9804 commit bd9a2a7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lightllm/server/req_id_generator.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)