Copilot commented on code in PR #42277:
URL: https://github.com/apache/superset/pull/42277#discussion_r3627428500
##########
superset/db_engine_specs/gsheets.py:
##########
@@ -389,6 +389,7 @@ def validate_parameters(
}
}
},
+ future=True,
)
conn = engine.connect()
idx = 0
Review Comment:
`validate_parameters` opens a SQLAlchemy connection via `conn =
engine.connect()` but never closes it, and the early `return errors` branches
inside the loop also bypass any cleanup. With `future=True` this code will
still leak open connections/pools on repeated validation calls. Use a context
manager (`with engine.connect() as conn:`) and avoid early returns (or ensure
`conn.close()` happens before returning).
##########
superset/models/core.py:
##########
@@ -644,6 +644,8 @@ def _get_sqla_engine( # pylint: disable=too-many-locals #
noqa: C901
if cached := _ENGINE_CACHE.get(cache_key):
return cached
try:
+ if "future" not in engine_kwargs:
+ engine_kwargs["future"] = True
engine = create_engine(sqlalchemy_url, **engine_kwargs)
Review Comment:
`engine_kwargs["future"]` is added *after* the engine-cache key is computed
(`repr(sorted(engine_kwargs.items()))`). This makes the cache key not reflect
the actual kwargs passed to `create_engine`, and can also cause duplicate
cached engines if a caller explicitly sets `future=True` in `engine_params`
(different key, same behavior). Set the default `future=True` before
computing/looking up the cache key, and then call `create_engine` without
mutating kwargs afterward.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]