Repository navigation
fix(versioning): scope stream_results to the activity SELECTs instead of mutating the session connection - #44261
Conversation
… of mutating the session connection (sc-120955) Connection.execution_options mutates the connection in place, so the activity fetch permanently flipped the request session into server-side-cursor mode. On PostgreSQL every later statement on the request — Continuum's version_transaction INSERT, SAVEPOINTs, and the DBEventLogger write that follows any activity read — gets wrapped in DECLARE ... CURSOR FOR and fails with a syntax error; the event write is swallowed by the logger's handler, so activity-endpoint telemetry is silently lost on PG deployments today. The option now rides each SELECT statement. Regression test: an activity read followed by a write on the same session (the DBEventLogger shape) — control-verified on PostgreSQL 16 (reverting the fix fails the test; SQLite is unaffected either way since only PG turns stream_results into server-side cursors). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
Code Review Agent Run #5f2352Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #44261 +/- ##
==========================================
- Coverage 80.39% 80.39% -0.01%
==========================================
Files 2932 2932
Lines 174525 174525
Branches 40548 40548
==========================================
- Hits 140318 140313 -5
- Misses 31538 31543 +5
Partials 2669 2669
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
aminghadersohi
left a comment
There was a problem hiding this comment.
Reverting the two production lines reds the new test with the exact DECLARE ... CURSOR WITHOUT HOLD FOR INSERT failure on Continuum's version_transaction insert, so fix and regression test both hold up. One note inline on what the test doesn't pin.
|
The observation is correct. Moving superset/versioning/activity/queries.py |
Answers discussion_r4024252815: observe named cursors even when stream_results is removed, while asserting connection options remain clean and later writes succeed. Replace the admin helper Any return with FAB User as requested by Bito.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #9e85caActionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Prepared by Codex at Mike's request. Following up on Bito's cursor-name timing note (#44261 (comment)): could we retain the named-cursor assertion? SQLAlchemy 2.0.52's The actual PostgreSQL CI job at tested merge |
SUMMARY
The activity fetch executed its streaming SELECTs via
db.session.connection().execution_options(stream_results=True)— andConnection.execution_optionsmutates the connection in place, permanently flipping the request session into server-side-cursor mode. On PostgreSQL, every later statement on the same request — Continuum'sversion_transactionINSERT, SAVEPOINTs, and notably the DBEventLogger write that follows any activity read — then gets wrapped inDECLARE ... CURSOR WITHOUT HOLD FOR ...and fails withpsycopg2.errors.SyntaxError(the event write is swallowed by the logger's error handler, so activity-endpoint telemetry is silently lost on PG deployments today). Surfaced deterministically by sc-120488's tests, which write through the same session afterget_activity— CI traceback: run 34888050672 / job 104123743848. The fix rides the option on each SELECT statement instead — dialect-neutral, one-line, no connection mutation.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — connection semantics.
TESTING INSTRUCTIONS
pytest tests/integration_tests/versioning/activity_write_after_read_tests.py— an activity read followed by an INSERT + commit on the same session (the DBEventLogger shape). Control-verified on PostgreSQL 16: reverting the fix fails the test with the DECLARE-CURSOR syntax error; green on SQLite/MySQL either way (only PG maps stream_results to server-side cursors).ADDITIONAL INFORMATION
🤖 Generated with Claude Code
https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW