Skip to content

fix(ingestion): cap OM and Snowflake socket waits to stop silent ingestion hangs - #28131

Merged
pmbrull merged 4 commits into
mainfrom
harshach/snowflake-ingestion-hang
May 15, 2026
Merged

pmbrull merged 4 commits into
mainfrom
harshach/snowflake-ingestion-hang

Conversation

@harshach

Copy link
Copy Markdown
Collaborator

Describe your changes:

A Snowflake metadata ingestion run was observed silently pausing in a hybrid-runner K8s pod: the pod stayed alive (no OOM, no crash), no further API calls hit the OpenMetadata server, no further log lines appeared. Pod-side logs ended at a successful Source.GET executed HTTP call to the OM server; the next expected Source executed / Sink.PATCH lines never reached the server. Streamable-log shipping continued from its daemon thread for ~13 minutes (draining its buffer) and then went quiet too.

Root cause is structural: HTTP calls from the connector to the OM server, and the SQLAlchemy/Snowflake connection itself, both go out with no read timeout. requests.Session() and the Snowflake driver keep TCP connections in pools; intermediate network devices (K8s NAT, AWS NLB default 350s, Azure LB default 4 min) silently sever idle sockets, and the next call grabs a stale connection and blocks in socket.recv forever (Linux TCP keepalive default is 2 hours).

Three minimal changes:

  • ingestion/src/metadata/ingestion/ometa/client.py: default ClientConfig.timeout to (10, 300) (10s connect, 5min read) instead of None. The existing if self._timeout guard still honours an explicit None for callers that need it.
  • ingestion/src/metadata/ingestion/source/database/snowflake/connection.py: setdefault client_session_keep_alive=True and network_timeout=600 on the connection arguments. User-supplied connectionArguments still win.
  • ingestion/setup.py: add py-spy>=0.3.14 to base_requirements so the next time a worker hangs we can py-spy dump --pid <pid> in place, without first having to install anything.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Tests:

Use cases covered

  • Snowflake ingestion in a K8s pod whose outbound TCP idle timeout (NAT/LB) is shorter than tcp_keepalive_time: previously hung indefinitely on next reuse of a half-open pooled socket, now surfaces as a requests.exceptions.ReadTimeout (caught by existing _one_request except Exception, logged, workflow continues) within 5 minutes.
  • Existing callers passing ClientConfig(timeout=None) retain the old "wait forever" behaviour (the if self._timeout guard at client.py:224 is unchanged).
  • Existing Snowflake users supplying client_session_keep_alive / network_timeout in connectionArguments continue to win via setdefault.

Unit tests

  • Not added: change is a default-value tweak in existing fields; no logic branches were introduced. Pydantic instantiation of all four shapes (default, int, None, tuple) verified locally.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable: change is a default-arg tweak with no new code paths.

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  • AST-parsed both edited files.
  • Instantiated ClientConfig in a Pydantic stand-in for default (10, 300), int=60, None, and (5, 30) overrides — all accepted.
  • Confirmed SSE streaming uses its own httpx.Client(timeout=None) in sse_client.py:82 and is unaffected.

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • I have commented on my code, particularly in hard-to-understand areas.

…ed TCP connection no longer hangs the worker

A Snowflake metadata ingestion run was observed to silently pause: the
Airflow pod stayed alive (no OOM, no crash), no further API calls hit
the OpenMetadata server, no further log lines appeared. The pod-side
log ended at `Source.GET executed in 59.057ms` -- a successful HTTP
GET to the OM server -- with the next expected `Source executed` /
`Sink.PATCH` lines never reaching the server. Streamable-log shipping
continued from its daemon thread for ~13 minutes (draining its buffer)
and then went quiet too.

Root cause is a structural one: HTTP calls from the connector to the
OM server, and the SQLAlchemy/Snowflake connection itself, both go out
with no read timeout. `requests.Session()` and the Snowflake driver
keep their TCP connections alive in pools; intermediate network
devices (K8s NAT, ingress NLB, AWS NLB default 350s, Azure LB default
4 min) silently sever idle sockets. The next call grabs a stale
connection from the pool and blocks in `socket.recv` waiting for bytes
that will never arrive. Linux TCP keepalive defaults to 2 hours.

Three minimal changes:

- `ingestion/src/metadata/ingestion/ometa/client.py`: default
  `ClientConfig.timeout` to `(10, 300)` (10s connect, 5min read)
  instead of `None`. The existing `if self._timeout` guard still
  honours an explicit `None` override for callers that need it.
- `ingestion/src/metadata/ingestion/source/database/snowflake/connection.py`:
  `setdefault` `client_session_keep_alive=True` and
  `network_timeout=600` on the connection arguments. User-supplied
  values in `connectionArguments` still win.
- `ingestion/setup.py`: add `py-spy>=0.3.14` to `base_requirements`
  so the next time a worker hangs we can `py-spy dump --pid <pid>` in
  place, without first having to install anything in the container.

After this, the same kind of dropped socket surfaces as a
`requests.exceptions.ReadTimeout` (caught by the existing
`except Exception` in `_one_request`, logged, and the workflow
continues) instead of wedging the pod indefinitely. SSE streaming
uses its own httpx client and is unaffected.
Copilot AI review requested due to automatic review settings May 14, 2026 23:02
@harshach
harshach requested a review from a team as a code owner May 14, 2026 23:02
@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels May 14, 2026
Comment thread ingestion/setup.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a real-world ingestion hang scenario caused by indefinite socket reads on (1) the OpenMetadata REST client and (2) Snowflake driver connections when pooled sockets are silently severed by NAT/LB idle timeouts. It introduces bounded timeouts/defaults to surface failures as timeouts rather than blocking forever, and adds an in-container profiling tool to simplify future debugging.

Changes:

  • Default OpenMetadata REST client timeout to (connect=10s, read=300s) while preserving the ability to explicitly disable timeouts via timeout=None.
  • Add Snowflake connection-argument defaults for client_session_keep_alive and network_timeout (with user-provided connectionArguments taking precedence via setdefault).
  • Add py-spy to ingestion base requirements to enable in-place stack sampling of hung workers.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
ingestion/src/metadata/ingestion/source/database/snowflake/connection.py Adds safe default Snowflake driver args to reduce the chance of indefinite socket hangs.
ingestion/src/metadata/ingestion/ometa/client.py Sets a bounded default requests timeout to avoid silent hangs on stale pooled HTTP connections.
ingestion/setup.py Adds py-spy to base dependencies to support post-mortem sampling/debugging inside ingestion environments.

…spy to Dockerfile

- snowflake/connection.py: drop the setdefault("client_session_keep_alive",
  True). The IngestionPipeline UI already exposes a clientSessionKeepAlive
  toggle (handled at lines 205-206); imposing a default of True here would
  silently override a user who unchecks it. Hang protection is now covered
  by network_timeout=600 alone, which bounds any silently-severed Snowflake
  socket to a 10-minute ReadTimeout instead of hanging the worker forever.
  Keep-alive only matters for Snowflake-side session expiry, which is a
  separate concern from the original hang.

- setup.py + ingestion/Dockerfile: move py-spy from base_requirements into
  the ingestion Dockerfile. The original goal — "available in the running
  container without pip install" — is met without forcing a native Rust
  binary on dev laptops, CI, and non-container installs that won't have
  CAP_SYS_PTRACE anyway.
@github-actions

Copy link
Copy Markdown
Contributor

The Python checkstyle failed.

Please run make py_format and py_format_check in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Python code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

@github-actions

github-actions Bot commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

🔴 Playwright Results — 9 failure(s), 21 flaky

✅ 4010 passed · ❌ 9 failed · 🟡 21 flaky · ⏭️ 133 skipped

Shard Passed Failed Flaky Skipped
🔴 Shard 1 267 3 1 32
🔴 Shard 2 729 6 13 27
🟡 Shard 3 783 0 1 7
🟡 Shard 4 787 0 3 18
🟡 Shard 5 708 0 1 41
🟡 Shard 6 736 0 2 8

Genuine Failures (failed on all attempts)

❌ entity-data.teardown.ts › cleanup entity data prerequisites (shard 1)
TimeoutError: page.goto: Timeout 60000ms exceeded.
Call log:
�[2m  - navigating to "http://localhost:8585/", waiting until "load"�[22m

❌ Features/DataAssetRulesDisabled.spec.ts › Verify the Spreadsheet entity item action after rules disabled (shard 1)
TimeoutError: page.goto: Timeout 60000ms exceeded.
Call log:
�[2m  - navigating to "http://localhost:8585/", waiting until "load"�[22m

❌ Features/DataAssetRulesDisabled.spec.ts › Verify the Worksheet entity item action after rules disabled (shard 1)
TimeoutError: page.goto: Timeout 60000ms exceeded.
Call log:
�[2m  - navigating to "http://localhost:8585/", waiting until "load"�[22m

❌ Features/DataQuality/DataObservabilityGovernanceTab.spec.ts › tag filter is hidden on Tag Data Observability tab (shard 2)
�[31mTest timeout of 60000ms exceeded.�[39m
❌ Features/DataQuality/DataObservabilityGovernanceTab.spec.ts › switching back to Overview tab hides the DQ dashboard (shard 2)
�[31mTest timeout of 60000ms exceeded.�[39m
❌ Features/DataQuality/DataObservabilityGovernanceTab.spec.ts › clicking Data Observability tab loads DQ dashboard widgets (shard 2)
�[31mTest timeout of 60000ms exceeded.�[39m
❌ Features/DataQuality/DataObservabilityGovernanceTab.spec.ts › DQ dashboard API carries domainFqn filter (shard 2)
�[31mTest timeout of 60000ms exceeded.�[39m
❌ Features/DataQuality/DataQuality.spec.ts › Table test case (shard 2)
�[31m"beforeAll" hook timeout of 60000ms exceeded.�[39m
❌ Features/DataQuality/DataQuality.spec.ts › TestCase with Array params value (shard 2)
�[31m"beforeAll" hook timeout of 60000ms exceeded.�[39m
🟡 21 flaky test(s) (passed on retry)
  • Pages/AuditLogs.spec.ts › should apply both User and EntityType filters simultaneously (shard 1, 1 retry)
  • Features/BulkEditEntity.spec.ts › Glossary (shard 2, 1 retry)
  • Features/DataQuality/DataObservabilityGovernanceTab.spec.ts › DQ dashboard API carries tag filter (shard 2, 2 retries)
  • Features/DataQuality/DataObservabilityGovernanceTab.spec.ts › clicking Data Observability tab loads DQ dashboard widgets (shard 2, 1 retry)
  • Features/DataQuality/DataObservabilityGovernanceTab.spec.ts › Data Observability tab absent in version history view (shard 2, 1 retry)
  • Features/DataQuality/TestCaseImportExportE2eFlow.spec.ts › Admin: Complete export-import-validate flow (shard 2, 1 retry)
  • Features/DataQuality/TestCaseResultPermissions.spec.ts › User with only VIEW cannot PATCH results (shard 2, 1 retry)
  • Features/Glossary/GlossaryHierarchy.spec.ts › should cancel move operation (shard 2, 1 retry)
  • Features/Glossary/GlossaryWorkflow.spec.ts › should display correct status badge color and icon (shard 2, 1 retry)
  • Features/KnowledgeCenterList.spec.ts › Knowledge Center List - Test infinite scroll/pagination (shard 2, 2 retries)
  • Features/KnowledgeCenterList.spec.ts › Knowledge Center List - Test add article button (shard 2, 1 retry)
  • Features/KnowledgeCenterTextEditor.spec.ts › Rich Text Editor - Text Formatting (shard 2, 1 retry)
  • Features/KnowledgeCenterTextEditor.spec.ts › Rich Text Editor - Text Formatting (shard 2, 1 retry)
  • Features/KnowledgeCenterTextEditor.spec.ts › Rich Text Editor - Text Formatting (shard 2, 1 retry)
  • Features/RTL.spec.ts › Verify Following widget functionality (shard 3, 1 retry)
  • Pages/CustomProperties.spec.ts › Set & Update all CP types on chart (shard 4, 1 retry)
  • Pages/CustomProperties.spec.ts › Set & Update all CP types on apiCollection (shard 4, 1 retry)
  • Pages/CustomProperties.spec.ts › Set & Update all CP types on apiEndpoint (shard 4, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should verify deleted user not visible in owner selection for knowledgeCenter (shard 5, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)
  • Pages/ODCSImportExport.spec.ts › Multi-object ODCS contract - object selector shows all schema objects (shard 6, 1 retry)

📦 Download artifacts

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

Copilot AI review requested due to automatic review settings May 15, 2026 03:18
@harshach harshach added the To release Will cherry-pick this PR into the release branch label May 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment on lines +205 to +212
if keep_alive := self._get_client_session_keep_alive():
connection.connectionArguments.root["client_session_keep_alive"] = keep_alive

# Bound the Snowflake socket so a silently-severed TCP connection
# (NAT/LB idle reaping in K8s/hybrid runners) surfaces as a network
# error within 10 minutes instead of hanging the worker indefinitely.
# User-supplied connectionArguments win via setdefault.
connection.connectionArguments.root.setdefault("network_timeout", 600)
Comment thread ingestion/Dockerfile
Comment on lines +105 to +109
# Ship py-spy so a hung worker can be sampled in place
# (`py-spy dump --pid <pid>`) without first installing anything in the pod.
# Container-only — kept out of setup.py to avoid forcing a native binary on
# dev laptops / CI / non-container installs.
RUN pip install "py-spy>=0.3.14"
pmbrull
pmbrull previously approved these changes May 15, 2026
…ix basedpyright static-check

The new network_timeout line called .setdefault() directly on
connection.connectionArguments.root, which is statically Optional[Dict]
(ConnectionArguments RootModel defaults to root=None). basedpyright
flags this as reportOptionalMemberAccess (configured as "error"), a
new violation not in the baseline, failing CI's --baselinemode=discard.

Guard with 'is not None' (matching the existing pattern at line 219).
Uses 'is not None' rather than truthiness because init_empty_connection_arguments()
yields an empty dict which is falsy, so a truthiness check would skip
setting the default in the common no-user-args case.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@gitar-bot

gitar-bot Bot commented May 15, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 2 resolved / 2 findings

Caps socket waits for OpenMetadata and Snowflake connections to prevent silent ingestion hangs due to stale TCP connections. Includes the addition of py-spy to production dependencies for improved future diagnostics.

✅ 2 resolved
✅ Quality: py-spy is a debug tool added to base production dependencies

📄 ingestion/setup.py:157-159
Adding py-spy>=0.3.14 to base_requirements means every installation of the ingestion framework (including developer laptops, CI, non-container environments) pulls in this native profiling binary. py-spy also requires CAP_SYS_PTRACE or root to function, so it won't even work in most environments without additional setup. It should be in a dedicated optional extras group (e.g., [debug] or [ops]) and pre-installed only in the official container images via a Dockerfile layer, rather than forcing it on all users.

✅ Edge Case: setdefault for client_session_keep_alive is partially redundant

📄 ingestion/src/metadata/ingestion/source/database/snowflake/connection.py:205-212
On line 205-206, if connection.clientSessionKeepAlive is truthy, the key is set via direct assignment (which overwrites any user-supplied value in connectionArguments). On line 211, setdefault only fires when the key is absent. This means:

  1. If the user supplied client_session_keep_alive in connectionArguments but did NOT set the dedicated clientSessionKeepAlive config field, the setdefault correctly preserves their value.
  2. If the user supplied it in connectionArguments AND set the dedicated field, line 206 overwrites their connectionArguments value (pre-existing behavior, not introduced here).

The logic works but the interaction between the explicit assignment (line 206) and setdefault (line 211) is subtle. A brief inline comment noting that line 206 intentionally takes priority over user-supplied connectionArguments would help future readers.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

Copy link
Copy Markdown

@pmbrull
pmbrull merged commit ac6c46b into main May 15, 2026
46 of 49 checks passed
@pmbrull
pmbrull deleted the harshach/snowflake-ingestion-hang branch May 15, 2026 08:10
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

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.

pmbrull added a commit that referenced this pull request May 15, 2026
…stion hangs (#28131)

* fix(ingestion): cap OM and Snowflake socket waits so a silently dropped TCP connection no longer hangs the worker

A Snowflake metadata ingestion run was observed to silently pause: the
Airflow pod stayed alive (no OOM, no crash), no further API calls hit
the OpenMetadata server, no further log lines appeared. The pod-side
log ended at `Source.GET executed in 59.057ms` -- a successful HTTP
GET to the OM server -- with the next expected `Source executed` /
`Sink.PATCH` lines never reaching the server. Streamable-log shipping
continued from its daemon thread for ~13 minutes (draining its buffer)
and then went quiet too.

Root cause is a structural one: HTTP calls from the connector to the
OM server, and the SQLAlchemy/Snowflake connection itself, both go out
with no read timeout. `requests.Session()` and the Snowflake driver
keep their TCP connections alive in pools; intermediate network
devices (K8s NAT, ingress NLB, AWS NLB default 350s, Azure LB default
4 min) silently sever idle sockets. The next call grabs a stale
connection from the pool and blocks in `socket.recv` waiting for bytes
that will never arrive. Linux TCP keepalive defaults to 2 hours.

Three minimal changes:

- `ingestion/src/metadata/ingestion/ometa/client.py`: default
  `ClientConfig.timeout` to `(10, 300)` (10s connect, 5min read)
  instead of `None`. The existing `if self._timeout` guard still
  honours an explicit `None` override for callers that need it.
- `ingestion/src/metadata/ingestion/source/database/snowflake/connection.py`:
  `setdefault` `client_session_keep_alive=True` and
  `network_timeout=600` on the connection arguments. User-supplied
  values in `connectionArguments` still win.
- `ingestion/setup.py`: add `py-spy>=0.3.14` to `base_requirements`
  so the next time a worker hangs we can `py-spy dump --pid <pid>` in
  place, without first having to install anything in the container.

After this, the same kind of dropped socket surfaces as a
`requests.exceptions.ReadTimeout` (caught by the existing
`except Exception` in `_one_request`, logged, and the workflow
continues) instead of wedging the pod indefinitely. SSE streaming
uses its own httpx client and is unaffected.

* review: address PR comments — defer keep_alive to UI toggle, move py-spy to Dockerfile

- snowflake/connection.py: drop the setdefault("client_session_keep_alive",
  True). The IngestionPipeline UI already exposes a clientSessionKeepAlive
  toggle (handled at lines 205-206); imposing a default of True here would
  silently override a user who unchecks it. Hang protection is now covered
  by network_timeout=600 alone, which bounds any silently-severed Snowflake
  socket to a 10-minute ReadTimeout instead of hanging the worker forever.
  Keep-alive only matters for Snowflake-side session expiry, which is a
  separate concern from the original hang.

- setup.py + ingestion/Dockerfile: move py-spy from base_requirements into
  the ingestion Dockerfile. The original goal — "available in the running
  container without pip install" — is met without forcing a native Rust
  binary on dev laptops, CI, and non-container installs that won't have
  CAP_SYS_PTRACE anyway.

* fix py check

* fix(ingestion): guard connectionArguments.root before setdefault to fix basedpyright static-check

The new network_timeout line called .setdefault() directly on
connection.connectionArguments.root, which is statically Optional[Dict]
(ConnectionArguments RootModel defaults to root=None). basedpyright
flags this as reportOptionalMemberAccess (configured as "error"), a
new violation not in the baseline, failing CI's --baselinemode=discard.

Guard with 'is not None' (matching the existing pattern at line 219).
Uses 'is not None' rather than truthiness because init_empty_connection_arguments()
yields an empty dict which is falsy, so a truthiness check would skip
setting the default in the common no-user-args case.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

---------

Co-authored-by: Pere Miquel Brull <[email protected]>
Co-authored-by: Claude Opus 4.7 <[email protected]>
pmbrull added a commit that referenced this pull request May 15, 2026
…stion hangs (#28131)

* fix(ingestion): cap OM and Snowflake socket waits so a silently dropped TCP connection no longer hangs the worker

A Snowflake metadata ingestion run was observed to silently pause: the
Airflow pod stayed alive (no OOM, no crash), no further API calls hit
the OpenMetadata server, no further log lines appeared. The pod-side
log ended at `Source.GET executed in 59.057ms` -- a successful HTTP
GET to the OM server -- with the next expected `Source executed` /
`Sink.PATCH` lines never reaching the server. Streamable-log shipping
continued from its daemon thread for ~13 minutes (draining its buffer)
and then went quiet too.

Root cause is a structural one: HTTP calls from the connector to the
OM server, and the SQLAlchemy/Snowflake connection itself, both go out
with no read timeout. `requests.Session()` and the Snowflake driver
keep their TCP connections alive in pools; intermediate network
devices (K8s NAT, ingress NLB, AWS NLB default 350s, Azure LB default
4 min) silently sever idle sockets. The next call grabs a stale
connection from the pool and blocks in `socket.recv` waiting for bytes
that will never arrive. Linux TCP keepalive defaults to 2 hours.

Three minimal changes:

- `ingestion/src/metadata/ingestion/ometa/client.py`: default
  `ClientConfig.timeout` to `(10, 300)` (10s connect, 5min read)
  instead of `None`. The existing `if self._timeout` guard still
  honours an explicit `None` override for callers that need it.
- `ingestion/src/metadata/ingestion/source/database/snowflake/connection.py`:
  `setdefault` `client_session_keep_alive=True` and
  `network_timeout=600` on the connection arguments. User-supplied
  values in `connectionArguments` still win.
- `ingestion/setup.py`: add `py-spy>=0.3.14` to `base_requirements`
  so the next time a worker hangs we can `py-spy dump --pid <pid>` in
  place, without first having to install anything in the container.

After this, the same kind of dropped socket surfaces as a
`requests.exceptions.ReadTimeout` (caught by the existing
`except Exception` in `_one_request`, logged, and the workflow
continues) instead of wedging the pod indefinitely. SSE streaming
uses its own httpx client and is unaffected.

* review: address PR comments — defer keep_alive to UI toggle, move py-spy to Dockerfile

- snowflake/connection.py: drop the setdefault("client_session_keep_alive",
  True). The IngestionPipeline UI already exposes a clientSessionKeepAlive
  toggle (handled at lines 205-206); imposing a default of True here would
  silently override a user who unchecks it. Hang protection is now covered
  by network_timeout=600 alone, which bounds any silently-severed Snowflake
  socket to a 10-minute ReadTimeout instead of hanging the worker forever.
  Keep-alive only matters for Snowflake-side session expiry, which is a
  separate concern from the original hang.

- setup.py + ingestion/Dockerfile: move py-spy from base_requirements into
  the ingestion Dockerfile. The original goal — "available in the running
  container without pip install" — is met without forcing a native Rust
  binary on dev laptops, CI, and non-container installs that won't have
  CAP_SYS_PTRACE anyway.

* fix py check

* fix(ingestion): guard connectionArguments.root before setdefault to fix basedpyright static-check

The new network_timeout line called .setdefault() directly on
connection.connectionArguments.root, which is statically Optional[Dict]
(ConnectionArguments RootModel defaults to root=None). basedpyright
flags this as reportOptionalMemberAccess (configured as "error"), a
new violation not in the baseline, failing CI's --baselinemode=discard.

Guard with 'is not None' (matching the existing pattern at line 219).
Uses 'is not None' rather than truthiness because init_empty_connection_arguments()
yields an empty dict which is falsy, so a truthiness check would skip
setting the default in the common no-user-args case.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

---------

Co-authored-by: Pere Miquel Brull <[email protected]>
Co-authored-by: Claude Opus 4.7 <[email protected]>
pmbrull added a commit that referenced this pull request May 15, 2026
…stion hangs (#28131)

* fix(ingestion): cap OM and Snowflake socket waits so a silently dropped TCP connection no longer hangs the worker

A Snowflake metadata ingestion run was observed to silently pause: the
Airflow pod stayed alive (no OOM, no crash), no further API calls hit
the OpenMetadata server, no further log lines appeared. The pod-side
log ended at `Source.GET executed in 59.057ms` -- a successful HTTP
GET to the OM server -- with the next expected `Source executed` /
`Sink.PATCH` lines never reaching the server. Streamable-log shipping
continued from its daemon thread for ~13 minutes (draining its buffer)
and then went quiet too.

Root cause is a structural one: HTTP calls from the connector to the
OM server, and the SQLAlchemy/Snowflake connection itself, both go out
with no read timeout. `requests.Session()` and the Snowflake driver
keep their TCP connections alive in pools; intermediate network
devices (K8s NAT, ingress NLB, AWS NLB default 350s, Azure LB default
4 min) silently sever idle sockets. The next call grabs a stale
connection from the pool and blocks in `socket.recv` waiting for bytes
that will never arrive. Linux TCP keepalive defaults to 2 hours.

Three minimal changes:

- `ingestion/src/metadata/ingestion/ometa/client.py`: default
  `ClientConfig.timeout` to `(10, 300)` (10s connect, 5min read)
  instead of `None`. The existing `if self._timeout` guard still
  honours an explicit `None` override for callers that need it.
- `ingestion/src/metadata/ingestion/source/database/snowflake/connection.py`:
  `setdefault` `client_session_keep_alive=True` and
  `network_timeout=600` on the connection arguments. User-supplied
  values in `connectionArguments` still win.
- `ingestion/setup.py`: add `py-spy>=0.3.14` to `base_requirements`
  so the next time a worker hangs we can `py-spy dump --pid <pid>` in
  place, without first having to install anything in the container.

After this, the same kind of dropped socket surfaces as a
`requests.exceptions.ReadTimeout` (caught by the existing
`except Exception` in `_one_request`, logged, and the workflow
continues) instead of wedging the pod indefinitely. SSE streaming
uses its own httpx client and is unaffected.

* review: address PR comments — defer keep_alive to UI toggle, move py-spy to Dockerfile

- snowflake/connection.py: drop the setdefault("client_session_keep_alive",
  True). The IngestionPipeline UI already exposes a clientSessionKeepAlive
  toggle (handled at lines 205-206); imposing a default of True here would
  silently override a user who unchecks it. Hang protection is now covered
  by network_timeout=600 alone, which bounds any silently-severed Snowflake
  socket to a 10-minute ReadTimeout instead of hanging the worker forever.
  Keep-alive only matters for Snowflake-side session expiry, which is a
  separate concern from the original hang.

- setup.py + ingestion/Dockerfile: move py-spy from base_requirements into
  the ingestion Dockerfile. The original goal — "available in the running
  container without pip install" — is met without forcing a native Rust
  binary on dev laptops, CI, and non-container installs that won't have
  CAP_SYS_PTRACE anyway.

* fix py check

* fix(ingestion): guard connectionArguments.root before setdefault to fix basedpyright static-check

The new network_timeout line called .setdefault() directly on
connection.connectionArguments.root, which is statically Optional[Dict]
(ConnectionArguments RootModel defaults to root=None). basedpyright
flags this as reportOptionalMemberAccess (configured as "error"), a
new violation not in the baseline, failing CI's --baselinemode=discard.

Guard with 'is not None' (matching the existing pattern at line 219).
Uses 'is not None' rather than truthiness because init_empty_connection_arguments()
yields an empty dict which is falsy, so a truthiness check would skip
setting the default in the common no-user-args case.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

---------

Co-authored-by: Pere Miquel Brull <[email protected]>
Co-authored-by: Claude Opus 4.7 <[email protected]>
@pmbrull

pmbrull commented May 15, 2026

Copy link
Copy Markdown
Member

picked by hand to 1.12.8, 1.12.9, 1.13

This branch had an error being deployed

1 failed deployment
test — b3635e7f Deployed May 15, 2026 by pmbrull via playwright-ci-postgresql (2, 6) #46919
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 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.

4 participants