justinpark opened a new pull request, #43371: URL: https://github.com/apache/superset/pull/43371
### SUMMARY `SqlExecutionResultsCommand` (used by the SQL Lab results endpoint) kept the SQLAlchemy session/connection open for the entire duration of the S3/results-backend fetch and the CPU-bound decompress → deserialize → row-expansion work that follows. None of that work touches the database, but holding a connection open for it — which can run well past this endpoint's client-side timeout for large results — was exhausting the small per-worker SQLAlchemy connection pool whenever several large-result downloads landed concurrently on the same gunicorn worker. This change warms the `query.database` relationship (needed later by `_deserialize_results_payload` for `db_engine_spec`) while the session is still open, then closes the session before fetching from the results backend, releasing the connection back to the pool for the remainder of the request. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A - backend-only change, no UI impact. ### TESTING INSTRUCTIONS 1. Run a SQL Lab query that returns a large result set. 2. Fetch results from `/api/v1/sqllab/results/` while other large-result requests are in flight on the same worker. 3. Confirm the request completes without exhausting the DB connection pool (e.g. no `QueuePool limit ... overflow` errors), and that results are still returned correctly. 4. Existing unit tests for `superset/commands/sql_lab/results.py` should continue to pass. ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- 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]
