Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions redash/tasks/queries/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
QueryDetachedFromDataSourceError,
)
from redash.monitor import rq_job_ids
from redash.query_runner import NotSupported
from redash.tasks.failure_report import track_failure
from redash.utils import json_dumps, sentry
from redash.worker import get_job_logger, job
Expand Down Expand Up @@ -177,6 +178,8 @@ def refresh_schema(data_source_id):
time.time() - start_time,
)
statsd_client.incr("refresh_schema.timeout")
except NotSupported:
logger.debug("Datasource %s does not support schema refresh", ds.name)
except Exception:
logger.warning("Failed refreshing schema for the data source: %s", ds.name, exc_info=1)
statsd_client.incr("refresh_schema.error")
Expand Down
10 changes: 10 additions & 0 deletions tests/tasks/test_refresh_schemas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from mock import patch

from redash.query_runner import NotSupported
from redash.tasks import refresh_schemas
from redash.tasks.queries.maintenance import refresh_schema
from tests import BaseTestCase


Expand All @@ -23,3 +25,11 @@ def test_skips_paused_data_sources(self):
with patch("redash.tasks.queries.maintenance.refresh_schema.delay") as refresh_job:
refresh_schemas()
refresh_job.assert_called()

def test_handles_notsupported_exception(self):
ds = self.factory.data_source
with patch.object(ds, "get_schema", side_effect=NotSupported("Schema not supported")):
with patch("redash.tasks.queries.maintenance.logger") as mock_logger:
refresh_schema(ds.id)
mock_logger.debug.assert_called_once()
mock_logger.warning.assert_not_called()
Loading