cx_Oracle.DatabaseError: ORA-12592: TNS:bad packet

cx_Oracle.DatabaseError: ORA-12592: TNS:bad packet

我正在编写一个 Flask API,并且在负载测试时看到很多失败。

查看 uwsgi 日志,我看到了一些看起来有点讨厌的东西,它是:

cx_Oracle.DatabaseError: ORA-12592: TNS:bad 数据包

oracle 连接正常,因为我没有看到完全失败,但这似乎是在大多数情况下过早终止 http rest 调用的原因。

这是什么原因造成的?我正在使用 RHEL,cx_Oracle 7.23,连接到 12C 数据库。我正在使用 Oracle 瘦客户端。

Exception on /api/read/maa [GET]
Traceback (most recent call last):
  File "/ariel/anaconda3/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/ariel/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/ariel/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/ariel/anaconda3/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/ariel/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/ariel/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/ariel/anaconda3/lib/python3.7/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
    response = function(request)
  File "/ariel/anaconda3/lib/python3.7/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
    response = function(request)
  File "/ariel/anaconda3/lib/python3.7/site-packages/connexion/decorators/validation.py", line 384, in wrapper
    return function(request)
  File "/ariel/anaconda3/lib/python3.7/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
    return function(**kwargs)
  File "./registrations.py", line 58, in read_maa_non_passive
    for row in cursor_ariel.fetchall():
cx_Oracle.DatabaseError: ORA-12592: TNS:bad packet
Getting data and status code

----更新--------

当我在 cx_Oracle 中停止连接池后,我所有的问题都消失了。我最初有一个跨 Flask 应用程序共享的 oracle 连接。这让我在压力测试中失败了。因此,我尝试变得聪明并使用 SessionPooling 并获取连接并在每次服务调用时释放它们。最后我回到了“糟糕的做法”并为每个函数调用(api 端点)创建了一个与 Oracle 的全新连接,现在我在 Locust 的压力测试中获得了 100% 的成功率,即使是更大的响应30mb json 有效负载的调用。

能否请您与普通客户一起测试并返回结果?

即时客户端是常规客户端的一个子集。

对于不t/haven不阅读评论线程的人,解决方案是使用 threaded=True 启动池。

How to use Python Flask with Oracle Database