Skip to content

Backport #33919 to 2.0: [Snowflake] Bound the stored-procedure history scan and isolate its failures - #37614

Merged
mohittilala merged 1 commit into
2.0from
backport/33919-to-2.0
Nov 12, 2026
Merged

mohittilala merged 1 commit into
2.0from
backport/33919-to-2.0

Conversation

@mohittilala

@mohittilala mohittilala commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #33919 to 2.0, which fixed #33918.

Cherry-picked from d389ad69a9d by hand. Every conflict comes from one of two main changes that are not on 2.0, and this backport brings in neither of them:

Everything else applies unchanged: the two-ended bound on both halves of the history statement, the split on a Snowflake cancel, the failure isolation in the shared mixin, and dropping the default network_timeout from the connection.

The Snowflake, stored-procedure lineage and MSSQL unit tests pass on the branch. The new tests fail against 2.0's code without the fix.

Original description follows.


Snowflake lineage ingestion fails the entire run with 000604 (57014): SQL execution was cancelled by the client due to a timeout when stored-procedure lineage runs over a long queryLogDuration. Three things combine.

The history query is unbounded. The stored-procedure history query reads ACCOUNT_USAGE.QUERY_HISTORY twice, joins the two halves by session and time overlap, and sorts the whole join. Each half was bounded only by a start time, so a 365-day lookback scanned a year of history twice in one statement. Both halves are now bounded at both ends, and a statement that Snowflake cancels is retried over the two halves of its window, recursively, a capped number of times and never below a one-day window. Only a cancel is retried, identified by the server's SQLSTATE 57014, which Snowflake reports both for its own statement timeout (000630) and for a client cancel (000604). A permission or compilation error would fail identically on every half, so it is reported once instead. The child-query half reaches seven days past its window, which is Snowflake's hard ceiling on STATEMENT_TIMEOUT_IN_SECONDS, so a CALL that starts just before the window closes keeps every query it ran after the boundary on any account. The global sort is gone: nothing downstream depends on the order, since the rows are handed to a thread pool.

Our own connect argument cancelled it. #28131 set network_timeout=600 on the Snowflake connection to bound a severed socket, but the driver also arms network_timeout as a client-side cancel timer on every statement it executes, which made it a hard ten-minute cap on every Snowflake statement. The connection no longer sets any client timeout. A severed socket is still bounded, because the driver applies its own 60-second read timeout to every request when socket_timeout is unset. Anyone who wants a statement deadline can still pass network_timeout or socket_timeout in connectionArguments.

One failed statement failed the run. The stored-procedure history read had no error handling, so the exception escaped the lineage producer and the step aborted as Unhandled. Stored-procedure lineage runs before query lineage, so a cancelled history read also cost the run its query lineage. A read that fails and cannot be narrowed is now recorded against the pipeline and skipped, and the rest of the run continues.

… isolate its failures (#33919)

* Bound the Snowflake stored-procedure history read and stop a cancelled one failing the run

The stored-procedure history statement scanned the whole lookback window with no upper bound, and our own network_timeout default armed the driver's per-statement cancel timer, so a long queryLogDuration died with 000604 and took the whole run down with it, query lineage included.

The read is now bounded at both ends and split in half only when Snowflake cancels it, the socket guard moves to socket_timeout, and a read that still fails is reported against the pipeline instead of raising.

* Size the stored-procedure overlap to Snowflake's statement timeout ceiling

The two-day overlap was Snowflake's default statement timeout, but an account can raise it up to 604800 seconds, so after a split a long CALL near the window boundary could lose the child queries it ran past the overlap. Reaching the hard seven-day ceiling means no CALL on any account can outlive it.

* Stop setting a Snowflake client timeout and classify cancels by SQLSTATE only

- Drop the `socket_timeout` default: the driver already bounds every request read at 60 seconds, and any `network_timeout` default cancels long statements
- Treat an error as a cancel only when the server reports SQLSTATE 57014, so a client error that merely mentions 57014 no longer triggers a split
- Derive the window cache size from the split depth instead of a fixed number

(cherry picked from commit d389ad6)
@mohittilala
mohittilala requested a review from a team as a code owner November 12, 2026 03:31
@mohittilala mohittilala added the skip-pr-checks Bypass PR metadata validation check label Nov 12, 2026
@mohittilala
mohittilala requested review from akashverma0786 and removed request for a team November 12, 2026 03:31
@mohittilala mohittilala self-assigned this Nov 12, 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:

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

@gitar-bot

gitar-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Bounding and recursively retrying Snowflake history scans while removing the client timeout could leave stored-procedure lineage incomplete when retries exhaust.

Bounds the Snowflake stored-procedure history scan at both ends, retries cancelled statements over smaller windows, drops the client-side 600-second network timeout, and records failed history reads against the pipeline instead of aborting the run. 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

@mohittilala
mohittilala merged commit a2da900 into 2.0 Nov 12, 2026
73 of 76 checks passed
@mohittilala
mohittilala deleted the backport/33919-to-2.0 branch November 12, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants