104 Commits

Author SHA1 Message Date
d0d3e1b24c chore: add build/ and *.egg-info/ to .gitignore 2026-08-03 10:56:52 +08:00
278e0c4549 perf: GLOBAL_CONN_LIMIT 400→1000, maxconn 100→200 2026-07-29 17:16:24 +08:00
e117b2acaa fix: discard MySQL dead connections (OperationalError/InterfaceError) from pool
Previously sqlorContext only discarded connections on RuntimeError/OSError
('closed'/'handler is closed'). MySQL OperationalError (2014 Command Out of
Sync) and InterfaceError (0 Not connected) were not caught, causing dead
connections to be returned to the pool and reused — cascading to multiple
500 errors on /llmage/v1/chat/completions.

Now catches any Exception with known MySQL dead-connection messages
(Not connected, Command Out of Sync, Lost connection, Connection reset,
Server disconnected) and discards the connection.

Added tests: mysql_error_during_use (5 variants), business_error_not_discarded.
2026-07-28 13:45:51 +08:00
a9a02eb45b Merge branch 'main' of git.opencomputing.cn:yumoqing/sqlor 2026-07-14 14:53:25 +08:00
e83fbd9931 bugfix 2026-07-14 14:52:52 +08:00
fab420c9d9 fix: mysqlor.enter() 先 commit 结束旧事务,防止连接池复用读脏数据
aiomysql 默认 autocommit=False。连接池复用连接时,
读操作(SELECT)后不调 commit(),导致未结束的事务+REPEATABLE
READ 快照残留。之后其他实例 DELETE 了记录,这个连接复用后
仍看到旧快照,出现"读到刚删除记录"的问题。

在 enter() 开头 commit() 结束上一个使用留下的任何事务。
2026-07-01 13:17:44 +08:00
ab3ff00753 perf: skip check_alive for recently used connections (< 30s idle)
Add CHECK_ALIVE_THRESHOLD to avoid unnecessary DB round-trips when
reusing warm connections. Fixes connection storm under high concurrency
where 57% of logs were 'discarding dead connection'.
2026-06-28 23:07:45 +08:00
33d332e36d fix: handle TCPTransport closed errors with connection health checks
- Add _check_alive() to verify connections before yielding from pool
- Discard dead connections and create fresh ones automatically
- Add _discard_sqlor() helper to safely remove broken connections
- Detect and handle 'closed'/'handler is closed' RuntimeError during use
- Add unit test for connection discard behavior
2026-06-27 17:53:21 +08:00
627b955897 Fix CancelledError handling in connection pool to prevent connection leaks
Problem: High-concurrency streaming requests with client disconnects trigger
asyncio.CancelledError (BaseException in Python 3.8+), but exception handlers
only caught Exception, causing:
- yielded_sqlor.used permanently stays True
- sqlor.exit() never called
- Connection slots permanently consumed, eventual pool exhaustion

Fix:
1. SqlorPool.context(): Use try/finally instead of try/except to always
   reset yielded_sqlor.used=False, even on CancelledError
2. DBPools.sqlorContext(): Change except Exception to except BaseException,
   add finally block to always call sqlor.exit(), suppress CancelledError
   logging noise

Verification: Ad-hoc tests confirm connections properly reset on cancellation
and can be reused. Normal exceptions still propagate correctly.
2026-06-27 14:40:06 +08:00
a2ef1bc48a Fix connection pool test_sqlor causing connection pileup under high concurrency
Remove test_sqlor() validation from SqlorPool.context() which was causing:
- Every request to test ALL idle connections with SELECT 1
- Healthy connections being incorrectly deleted due to timeout under load
- Race conditions when multiple requests test the same connection
- Excessive connection creation leading to 501 Sleep connections

The new logic takes the first available connection without validation.
If a connection fails during actual use, the exception propagates naturally.
2026-06-27 14:19:24 +08:00
f6c6b4d913 fix: 全局连接数限制+空闲连接回收
- 添加全局信号量限制总连接数(400),防止超过MariaDB上限(500)
- 实现空闲连接自动回收(IDLE_TIMEOUT=300秒)
- 修复_del_sqlor中连接关闭时释放全局信号量
2026-06-27 12:54:07 +08:00
3a752f3719 fix: sor.U() skip when no fields to update (only primary keys in data) 2026-06-25 13:21:01 +08:00
Hermes Agent
8852aaefd6 移除__pycache__,添加.gitignore 2026-06-22 14:59:29 +08:00
Hermes Agent
3cc3b86d7b LIKE自动加%value%,空值跳过过滤条件 2026-06-22 14:43:32 +08:00
4abf30356e bugfix 2026-06-01 16:31:33 +08:00
23769535cd fix: dispatch delete before DBPools events 2026-05-19 01:12:48 +08:00
171486efcd bugfix 2026-05-16 16:31:09 +08:00
ac338642c6 bugfix 2026-05-16 16:26:03 +08:00
132c11ae8f bugfix 2026-05-16 16:20:50 +08:00
74a97697a5 bugfix 2026-05-16 16:16:20 +08:00
912c17dad8 bugfix 2026-04-28 14:34:29 +08:00
472ce1647a bugfix 2026-04-14 17:02:04 +08:00
0859f8162d bugfix 2026-04-14 10:38:05 +08:00
aedab9abff bugfix 2026-04-13 18:14:47 +08:00
53c58f00fc bugfix 2026-04-13 16:31:31 +08:00
12be28f5f7 bugfix 2025-12-22 17:32:25 +08:00
fb44d60283 bugfix 2025-12-22 16:47:35 +08:00
b007ed5c17 bugfix 2025-12-22 14:16:01 +08:00
59bd2cd055 bugfix 2025-12-22 14:12:02 +08:00
yumoqing
1a77d24b5a bugfix 2025-12-20 19:15:11 +08:00
6202f6e375 bugfix 2025-12-17 15:44:24 +08:00
c0c87aa489 bugfix 2025-12-17 14:13:37 +08:00
7acfa896fa bugfix 2025-12-17 13:43:43 +08:00
f8a5b4f92c bugfix 2025-12-11 15:52:19 +08:00
2b89a1f515 bugfix 2025-11-07 17:33:43 +08:00
b815d7e701 bugfix 2025-11-07 16:47:22 +08:00
yumoqing
d3c9c060ea bugfix 2025-10-31 08:35:53 +08:00
bd15c2fb8d bugfix 2025-10-28 21:04:30 +08:00
dd5f88368b bugfix 2025-10-28 21:04:05 +08:00
84d740ad3d bugfix 2025-10-28 10:17:26 +08:00
c3d7ffc118 bugfix 2025-10-28 10:15:26 +08:00
fb8153cc3a bugfix 2025-10-23 15:17:24 +08:00
b4112adde7 bugfix 2025-10-23 12:15:41 +08:00
1c694869bb bugfix 2025-10-22 15:43:02 +08:00
9b421499f4 bugfix 2025-10-22 15:41:52 +08:00
fdde66f74c bugfix 2025-10-20 17:35:02 +08:00
b9a6724cbe bugfix 2025-10-20 17:34:03 +08:00
f89b972576 bugfix 2025-10-20 17:10:43 +08:00
62514a2398 bugfix 2025-10-20 16:38:58 +08:00
6655fc6fde bugfix 2025-10-20 14:22:21 +08:00