Skip to content

Commit

Permalink
fix(csharp/src/Drivers/Apache): detect sever error when polling for r…
Browse files Browse the repository at this point in the history
…esponse (#2355)

Checks the return status when polling for response. 
* Must be in the `FINISHED_STATE`. Other states are invalid after
polling.
* Difficult to write tests for this without "abusing" the server to
invoke a server error.
  • Loading branch information
birschick-bq authored Dec 7, 2024
1 parent 927922f commit 7d2b719
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions csharp/src/Drivers/Apache/Hive2/HiveServer2Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ internal static async Task PollForResponseAsync(TOperationHandle operationHandle
TGetOperationStatusReq request = new(operationHandle);
statusResponse = await client.GetOperationStatus(request, cancellationToken);
} while (statusResponse.OperationState == TOperationState.PENDING_STATE || statusResponse.OperationState == TOperationState.RUNNING_STATE);

// Must be in the finished state to be valid. If not, typically a server error or timeout has occurred.
if (statusResponse.OperationState != TOperationState.FINISHED_STATE)
{
throw new HiveServer2Exception(statusResponse.ErrorMessage, AdbcStatusCode.InvalidState)
.SetSqlState(statusResponse.SqlState)
.SetNativeError(statusResponse.ErrorCode);
}
}

private string GetInfoTypeStringValue(TGetInfoType infoType)
Expand Down

0 comments on commit 7d2b719

Please sign in to comment.