Skip to content

[2.0] fix(ingestion): stop MSSQL GetTables/GetViews sorting the whole catalog (#32014) - #35906

Merged
ulixius9 merged 1 commit into
2.0from
backport/2.0-mssql-gettables-no-sort
Oct 21, 2026
Merged

ulixius9 merged 1 commit into
2.0from
backport/2.0-mssql-gettables-no-sort

Conversation

@ulixius9

@ulixius9 ulixius9 commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Backport of #32014 (f8c5d97) to 2.0. Fixes #24101 on 2.0.

On 2.0, the MSSQL test-connection GetTables/GetViews steps still reflect via inspector.get_table_names()/get_view_names(), which query INFORMATION_SCHEMA.TABLES with an ORDER BY and no row cap. On a large schema SQL Server sorts every row before returning one, so the step exceeds the 60s per-step timeout. The SIGALRM timeout then fires inside pyodbc (<class 'pyodbc.Error'> returned a result with an exception set) and leaves the connection unrecoverable (IMC06). This has been seen on 2.0 customer deployments.

The fix replaces both with a TOP 1, no-ORDER BY probe against sys.tables/sys.views filtered to is_ms_shipped = 0.

Conflict resolution

Tests

  • pytest tests/unit/source/database/mssql/ → 54 passed (2.0 models regenerated)
  • ruff format --check / ruff check (0.15) on the changed files → clean

🤖 Generated with Claude Code


Summary by Gitar

  • Behavior change:
    • GetTables now adds a caveat when no tables are visible, while GetViews stays silent when empty
    • Removed the SYSTEM_SCHEMAS filter from MssqlChecks, since the new probe replaces the schema-based listing
  • New tests:
    • Added test_connection.py cases covering the probe's found, empty, and caveat paths using a mocked run_sql
  • Probe queries:
    • Added MSSQL_TEST_GET_TABLES and MSSQL_TEST_GET_VIEWS using TOP 1 without ORDER BY to avoid sorting the full catalog

This will update automatically on new commits.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

Replaces MSSQL table and view reflection with small existence checks.

  • MSSQL connection checks look for one visible table or view.

No actionable issues found. Tests were not run during this review.

Reviews (1) · Last reviewed commit: "fix(ingestion): stop MSSQL GetTables/Get..." · Reviewed by Greptile

…og (#32014)

GetTables/GetViews used inspector.get_table_names()/get_view_names(),
which query INFORMATION_SCHEMA with an ORDER BY and no row cap. On a
schema with hundreds of thousands of tables, SQL Server has to sort
every row before returning one, which blows past the per-step
test-connection timeout and aborts real ingestion before it starts.

Replace them with a TOP 1, no-ORDER-BY existence probe against
sys.tables/sys.views, filtered to is_ms_shipped = 0 so a probe against
a system database (master, msdb) still reports on real user objects
instead of SQL Server's own tables/views.

Fixes #24101

(cherry picked from commit f8c5d97)
@ulixius9
ulixius9 requested a review from a team as a code owner October 21, 2026 15:18
@ulixius9
ulixius9 requested review from harshsoni2024 and removed request for a team October 21, 2026 15:18
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Oct 21, 2026
@gitar-bot

gitar-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · MSSQL connection checks now probe one user table or view instead of enumerating catalogs, which could miss object-specific visibility problems.

Replaces the MSSQL test-connection GetTables/GetViews schema-listing calls with a TOP 1, no-ORDER BY probe against sys.tables/sys.views filtered to is_ms_shipped = 0, so the step no longer sorts the whole catalog and exceed the 60s timeout. Adds tests for found, empty, and caveat paths. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@ulixius9
ulixius9 merged commit 912c00f into 2.0 Oct 21, 2026
51 of 56 checks passed
@ulixius9
ulixius9 deleted the backport/2.0-mssql-gettables-no-sort branch October 21, 2026 15:43
@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants