From 9da343b2e1fd0c03e00cbf69d84cbca66cc95a35 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 31 Jul 2026 16:30:49 +0800 Subject: [PATCH] fix: use uuid4 instead of getID() in DSPY to avoid nanoid collision under concurrency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two getID() calls per request (DSPY + uapi_request) under 200 concurrent caused nanoid random state corruption → 34% duplicate IDs → IntegrityError. uuid4 uses OS entropy, independent of nanoid state. --- wwwroot/v1/chat/completions/index.dspy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wwwroot/v1/chat/completions/index.dspy b/wwwroot/v1/chat/completions/index.dspy index abb1fa5..75ad5bc 100644 --- a/wwwroot/v1/chat/completions/index.dspy +++ b/wwwroot/v1/chat/completions/index.dspy @@ -43,7 +43,8 @@ params_kw.llmid = llmid params_kw.llmcatelogid = catelogid debug(f'{params_kw.llmid=}') -luid = getID() +import uuid +luid = str(uuid.uuid4()) reserved = await env.reserve_balance(params_kw.llmid, userorgid, luid) if not reserved.get('ok'): debug(f'{userid=} balance not enough: {reserved}')