Skip to content

Fixes 24101: stop MSSQL GetTables/GetViews from timing out on large catalogs - #32014

Merged
akashverma0786 merged 2 commits into
mainfrom
fix-24101
Sep 3, 2026
Merged

akashverma0786 merged 2 commits into
mainfrom
fix-24101

Conversation

@akashverma0786

@akashverma0786 akashverma0786 commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #24101

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 even one — reproduced live against a real SQL Server instance with ~600k tables in one schema: GetTables took 87.7s, GetViews 44.4s, both past the 60s per-step timeout, failing the whole test connection and aborting real ingestion before it started (GetTables is a mandatory step, and test_connection() runs unconditionally before any real extraction).

Replaced both with a TOP 1, no-ORDER BY existence probe against sys.tables/sys.views — SQL Server can satisfy that with an index seek instead of a full sort, so it stays fast regardless of catalog size. 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 (master.spt_values, msdb's ~150 system tables/views) — verified directly against both.

Re-validated against the same ~600k-table instance after the fix: GetTables/GetViews now resolve in the same instant as the other checks, and the full test connection reports Successful.

Type of change:

  • Bug fix

High-level design:

N/A — small change, contained to the MSSQL connector's test-connection checks.

Tests:

Use cases covered

  • GetTables/GetViews return in milliseconds regardless of table/view count (verified live against a ~600k-table SQL Server instance).
  • A schema with zero real tables reports no tables visible with a caveat (a warning, not a failure); zero views stays silent, matching pre-existing behavior.
  • A probe against a system database (containing real Microsoft-shipped tables/views) does not report those as user data.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files updated: ingestion/tests/unit/source/database/mssql/test_connection.py
  • New tests assert the probe query shape (TOP 1, no ORDER BY, is_ms_shipped = 0) and the found/empty/caveat behavior for both GetTables and GetViews.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable — covered by unit tests plus manual validation below; no existing ingestion integration test harness spins up a large-enough MSSQL catalog to reproduce the timeout.

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  1. Reproduced the reported timeout against a real SQL Server 2022 instance with ~600k tables in one schema, via the actual metadata ingest CLI: GetTables failed after 87.7s, GetViews after 44.4s, both exceeding the per-step timeout.
  2. Applied the fix and re-ran the same CLI against the same instance: GetTables/GetViews resolve instantly, test connection reports Successful, and real ingestion proceeds.
  3. Verified is_ms_shipped = 0 directly against master and msdb — confirmed real system objects (spt_values, sysnotifications, etc.) are excluded from the probe's results.

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

Greptile Summary

The PR replaces MSSQL table and view enumeration during connection testing with bounded TOP 1 catalog probes.

  • Adds user-object existence queries over sys.tables and sys.views.
  • Preserves warning behavior for an empty table result and silent handling for an empty view result.
  • Adds unit coverage for query shape and found/empty outcomes.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
ingestion/src/metadata/ingestion/source/database/mssql/connection.py Replaces potentially unbounded reflection calls with bounded existence probes and preserves the expected evidence and caveat behavior.
ingestion/src/metadata/ingestion/source/database/mssql/queries.py Adds TOP 1 MSSQL catalog queries that exclude Microsoft-shipped objects and avoid sorting.
ingestion/tests/unit/source/database/mssql/test_connection.py Covers the bounded query shape and table/view evidence behavior for both present and empty results.

Reviews (2): Last reviewed commit: "Merge branch 'main' into fix-24101" | Re-trigger Greptile

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
@akashverma0786
akashverma0786 requested a review from a team as a code owner August 25, 2026 10:21
@akashverma0786 akashverma0786 added the safe to test Add this label to run secure Github workflows on PRs label Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

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

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 commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit e8e3a0e8972708c8f25394c603c00f6125a3f40c in Playwright run 32851059682, attempt 1.

✅ 110 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 52m 38s

⏱️ Max setup 6m 34s · max shard execution 13m 3s · max shard-job elapsed before upload 22m 1s · reporting 4s

🌐 217.40 requests/attempt · 1.79 app boots/UI scenario · 0.00% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 217.4 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 1.79 per UI scenario (216 boots / 121 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 46 0 0 0 0 0
✅ Shard ingestion-01 28 0 0 0 0 0
✅ Shard ingestion-02 36 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@gitar-bot

gitar-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Replaces full catalog sorting with a fast TOP 1 index seek in MSSQL GetTables and GetViews to prevent ingestion timeouts on large databases. No issues found.

Options

Display: compact → Showing less information.

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

@sonarqubecloud

Copy link
Copy Markdown

@akashverma0786 akashverma0786 added the To release Will cherry-pick this PR into the release branch label Sep 1, 2026
@akashverma0786
akashverma0786 added this pull request to the merge queue Sep 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-01T17:00:59Z)

Blocked the queue: py-tests-status

  • py-tests — python / Integration Tests (shard-3), python / Unit Tests & Static Checks (3.10)
  • py-tests-postgres — py-tests-status, python / Verify Expected Jobs, python / Integration Tests (shard-3), python / Integration Tests (shard-1)

@akashverma0786
akashverma0786 added this pull request to the merge queue Sep 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-03T03:26:36Z)

Blocked the queue: py-tests-status

  • py-tests — py-tests-status, python / Verify Expected Jobs, python / Integration Tests (shard-1), python / Integration Tests (shard-2), python / Integration Tests (shard-2), python / Integration Tests (shard-2)
  • py-tests-postgres — python / Integration Tests (shard-2), python / Integration Tests (shard-2), python / Integration Tests (shard-2)

@akashverma0786
akashverma0786 added this pull request to the merge queue Sep 3, 2026
Merged via the queue into main with commit f8c5d97 Sep 3, 2026
171 of 173 checks passed
@akashverma0786
akashverma0786 deleted the fix-24101 branch September 3, 2026 22:12
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Failed to cherry-pick changes to the 2.0 branch.
Please cherry-pick the changes manually.
You can find more details here.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Failed to cherry-pick changes to the 1.13 branch.
Please cherry-pick the changes manually.
You can find more details here.

Khairajani added a commit that referenced this pull request Sep 8, 2026
MSSQL drops out of this change: main's #32014 replaced its GetTables/GetViews
reflection with a TOP 1 sys.tables/sys.views existence probe, which selects no
schema, so there is no schema filter to apply. Took main's file verbatim.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Khairajani added a commit that referenced this pull request Sep 24, 2026
…ion per driver, bound query timeouts (#32574) (#33924)

Backport of #32574 to 2.0.

Resolved against 2.0 rather than taken wholesale, because the squashed commit
carries context from changes 2.0 does not have:

- the bundled UI schema copies under ui/src/jsons/ingestionSchemas and
  ui/public/jsons/connectionSchemas are deleted on 2.0, so they stay deleted;
  the description edit reaches SSIS and WhereScape through the $ref they
  already have on mssqlConnection.json
- MSSQL_GET_QUERY_STORE_STATE keeps 2.0's own statement, since the extra
  column belongs to a different change
- the GetTables/GetViews probe tests and the `replace` import they need come
  from #32014, which is not on 2.0, so neither is brought along

145 unit tests pass across the MSSQL and SSL suites.
ulixius9 added a commit that referenced this pull request Oct 21, 2026
…og (#32014) (#35906)

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)

Co-authored-by: Akash Verma <138790903+akashverma0786@users.noreply.github.com>

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

safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test Connection - Timeout GetTable

2 participants