fix(postgresql): fix TEIID error when getting postgresql cancellation token#18207
fix(postgresql): fix TEIID error when getting postgresql cancellation token#18207davemulford wants to merge 1 commit intoapache:masterfrom
Conversation
Using TEIID virtual databases (VDBs) in Superset requires the use of the postgres connector. In a previous update, cancelation tokens were added to allow a query to be stopped on the database server. This is a good thing, however it introduced a bug that disallowed the use of TEIID VDBs. This change wraps the `SELECT pg_backend_pid()` query in a try-catch phrase, and returns `None` upon exception.
| cursor.execute("SELECT pg_backend_pid()") | ||
| row = cursor.fetchone() | ||
| return row[0] | ||
| except Exception: |
There was a problem hiding this comment.
Minor improvement proposal: is there a more specific exception type that we could be catching here?
There was a problem hiding this comment.
I can double-check and make the change. Thanks for the review!
There was a problem hiding this comment.
I've updated the PR comment with the error being raised. It's a superset.exceptions.SupersetErrorsException. Would you like me to catch that instead of the generic exception?
There was a problem hiding this comment.
I've updated the PR comment with the error being raised. It's a
superset.exceptions.SupersetErrorsException. Would you like me to catch that instead of the generic exception?
Really? I would have thought it's a psycopg2 or at least a SQLAlchemy exception, as I assume it's coming from the cursor call. But yeah, let's make it as specific as possible if it's not too much trouble.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue |
Using TEIID virtual databases (VDBs) in Superset requires the use of the postgres connector. In a previous update, cancelation tokens were added to allow a query to be stopped on the database server. This is a good thing, however it introduced a bug that disallowed the use of TEIID VDBs.
This change wraps the
SELECT pg_backend_pid()query in a try-catch phrase, and returnsNoneupon exception.The error encountered in the Superset SQL Editor is:
SUMMARY
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION