fix(csharp): prevent infinite polling in SEA metadata queries#347
Open
msrathore-db wants to merge 2 commits intomainfrom
Open
fix(csharp): prevent infinite polling in SEA metadata queries#347msrathore-db wants to merge 2 commits intomainfrom
msrathore-db wants to merge 2 commits intomainfrom
Conversation
…nt infinite polling ExecuteMetadataSqlAsync creates internal statements with _queryTimeoutSeconds=0 (no timeout). When called via ExecuteQuery() on a metadata statement (e.g. GetTables, GetColumns), CancellationToken.None is passed through, causing PollUntilCompleteAsync's while(true) loop to run indefinitely if the server query doesn't complete within the initial 10s wait. This impacts PowerBI users who see frozen UI / infinite spinners when browsing tables or columns via the SEA (REST) protocol, with no way to cancel. Fix: wrap all metadata SQL execution with CreateMetadataTimeoutCts(), matching the pattern already used by GetObjects(). Links caller-provided tokens so either the caller or the metadata timeout can terminate the operation. Co-authored-by: Isaac
| // ExecuteMetadataCommandAsync → GetTablesAsync via ExecuteQuery()), the | ||
| // inner statement would have _queryTimeoutSeconds=0 and poll forever. | ||
| // Link the caller's token with a metadata timeout as a safety net. | ||
| using var metadataTimeoutCts = CreateMetadataTimeoutCts(); |
Collaborator
There was a problem hiding this comment.
It seems we have same bug for Thrift, can we fix that too?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ExecuteMetadataSqlAsynccreates internal statements with_queryTimeoutSeconds=0(no timeout). When called viaExecuteQuery()on a metadata statement (e.g.GetTables,GetColumns,GetCatalogs),CancellationToken.Noneis passed through, causingPollUntilCompleteAsync'swhile(true)loop to run indefinitely if the server query doesn't complete within the initial 10s REST API wait.CreateMetadataTimeoutCts()(using_waitTimeoutSeconds, default 10s), matching the pattern already used byGetObjects(). Links caller-provided tokens so either the caller or the metadata timeout can terminate the operation.TGetTablesReqRPC — a single request-response call with no SQL or polling.Root cause details
The code path:
ExecuteQuery()→ExecuteQueryAsync(CancellationToken.None)→ExecuteMetadataCommandAsync→GetTablesAsync(CancellationToken.None)→ExecuteMetadataSqlAsync(sql, CancellationToken.None)→ creates newStatementExecutionStatementwith_queryTimeoutSeconds=0→PollWithTimeoutAsyncsees<= 0→PollUntilCompleteAsync(statementId, CancellationToken.None)→ infinitewhile(true).All SEA metadata commands are affected:
GetCatalogs,GetSchemas,GetTables,GetColumns,GetColumnsExtended,GetPrimaryKeys,GetCrossReference, andGetCurrentCatalog()(SELECT CURRENT_CATALOG()).Test plan
SeaMetadataE2ETests)This pull request was AI-assisted by Isaac.