Commit e0ae919f authored by Stratos Psomadakis's avatar Stratos Psomadakis

psycopg: Don't include conn info in exception

When trying to get a pooled_psycopg2 connection, the _get_pool() method
checks the connection args against the pool args and raises an exception
if the two differ. This leads to an internal server error, which results
in logging the connection and pool info / args, which include the DB
password, and, depending on the deployment, it might also send them via
email to the admins. Log the connection and pool args only when log
level is set to  debug, and remove them from the exception message, so
that they won't end up being send via email.
parent 3d37e58c
...@@ -136,8 +136,10 @@ def _get_pool(kw): ...@@ -136,8 +136,10 @@ def _get_pool(kw):
_init_pool(kw) _init_pool(kw)
if _pool_kwargs != kw: if _pool_kwargs != kw:
raise NotImplementedError(("Requested pooled psycopg2 connection with " log.debug("INIT-POOL: Requested connection args differ from pool "
"args %s != %s." % (kw, _pool_kwargs))) "args: %s != %s." % (kw, _pool_kwargs))
raise Exception("Requested pooled psycopg2 connection with args "
"that differ from the current pool args")
return _pool return _pool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment