django-sql-explorer icon indicating copy to clipboard operation
django-sql-explorer copied to clipboard

Gracefully handle NotSupportedError during schema introspection

Open gavinhodge opened this issue 1 year ago • 1 comments

In certain circumstances, a django.db.utils.NotSupportedError can be thrown during schema introspection. If this happens, the exception is unhandled and Django returns a 500 response instead of displaying query results.

To reproduce requires:

  • Postgresql running in recovery mode (typically a hot standby server). This can be simulated without a hot standby server
  • An unlogged table on the primary (ALTER TABLE table_name SET UNLOGGED)
  • Attempt to execute a query (e.g. SELECT 1) against the standby server and receive a 500 error page

Exception detail:

NotSupportedError
cannot access temporary or unlogged relations during recovery

The issue can be worked around by specifying the affected tables in the EXPLORER_SCHEMA_EXCLUDE_TABLE_PREFIXES setting, but this change makes a workaround unnecessary.

gavinhodge avatar Jan 31 '25 01:01 gavinhodge

Hi maintainers, does this need any action from my end before it can be reviewed or merged?

gavinhodge avatar Apr 09 '25 22:04 gavinhodge