为了能快速了解并处理您的问题,请提供以下基础信息:
面板:9.5.0Redis插件:7.4.2
CentOS 7.9.2009 x86_64(Py3.7.9)
我们在使用宝塔面板 Redis 插件调用接口 POST /database/redis/get_db_keylist 时,后台报了严重的内存溢出错误(MemoryError),请求参数很简单: { "search": "", "sid": 0, "limit": 10, "db_idx": 0, "p": 1}
但接口在执行 json.dumps(data) 返回数据时发生了内存爆炸,一层又一层的 fallback 都失败了,导致整个响应崩溃。
REQUEST_DATE: 2025-04-09 10:18:00 VERSION: CentOS 7.9.2009 x86_64(Py3.7.9) - 9.5.0 REMOTE_ADDR: 27.154.214.166 REQUEST_URI: POST /database/redis/get_db_keylist?REQUEST_FORM: {'data': '{"search":"","sid":0,"limit":10,"db_idx":0,"p":1}'} USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36Traceback (most recent call last): File "class/public.py", line 352, in dumps return json.dumps(data) File "/www/server/panel/pyenv/lib/python3.7/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "/www/server/panel/pyenv/lib/python3.7/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/www/server/panel/pyenv/lib/python3.7/json/encoder.py", line 257, in iterencode return _iterencode(o, 0)MemoryErrorDuring handling of the above exception, another exception occurred:Traceback (most recent call last): File "class/public.py", line 354, in dumps return json.dumps(data, ensure_ascii=False) File "/www/server/panel/pyenv/lib/python3.7/json/__init__.py", line 238, in dumps **kw).encode(obj) File "/www/server/panel/pyenv/lib/python3.7/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/www/server/panel/pyenv/lib/python3.7/json/encoder.py", line 257, in iterencode return _iterencode(o, 0)MemoryErrorDuring handling of the above exception, another exception occurred:Traceback (most recent call last): File "/www/server/panel/BTPanel/__init__.py", line 2533, in publicObject res = run_obj.run(toObject, defs, get) File "/www/server/panel/BTPanel/__init__.py", line 2484, in run result = public.GetJson(result), json_header File "class/public.py", line 366, in GetJson data = ijson_obj.dumps(data) File "class/public.py", line 356, in dumps return json.dumps({'status': False, 'msg': "错误的响应: %s" % str(data)})MemoryError
|