google-cloud-dotnet: Inserting lots of data to Google BigQuery randomly throws an SSL Exception
šš» GāDay!
Problem
An SSL error is randomly thrown while importing a lot of data into Google BigQuery.
Details
Iāve got a (once off) maintenance task which is trying to insert about 10mil rows into a Google BigQuery table. Code is nothing too crazy - because this is a once off import.
Randomly (well, it feels random) an SSL error thrown which crashes my app.
Authentication failed because the remote party sent a TLS alert: āDecryptErrorā.
Iāve added in some retrying ability (using Polly for .NET) and weāre back on track.
Iām not really sure how to reproduce it, but Iāve provided some info here to maybe help. Itās happened after 30/40k have been pushed up. Other times, hundreds of thousands pushed up. With Polly, it retries and it works again/continues ⦠until the next random failure ⦠which Polly retries OK and we rinse/repeat.
Environment details
PS C:\Users\justi> dotnet --info
.NET SDK:
Version: 7.0.304
Commit: 7e794e2806
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.304\
Host:
Version: 7.0.7
Architecture: x64
Commit: 5b20af47d9
- Package name and version: Google.Cloud.BigQuery.V2 v3.2.0
Hereās some sample code Iāve got which is doing this:
// Configure the retry policy with Polly
var retryPolicy = Policy.Handle<Exception>()
.WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (exception, timeSpan, retryCount, context) =>
{
// Log the exception to the console
Console.WriteLine($"Retry #{retryCount} after {timeSpan.TotalSeconds} seconds due to: {exception}");
});
try
{
// Execute the retry policy for the HTTP request
var pollyResult = await retryPolicy.ExecuteAsync(async () =>
{
var result = await client.InsertRowsAsync(destinationTable, rows, null, cancellationToken);
return result;
});
_logger.LogDebug("Finished sending all rows to Google BigQuery. Status: {bigQueryInsertStatus}", pollyResult.Status);
pollyResult.ThrowOnAnyError();
}
catch (Exception exception)
{
// Log the final exception to the console
Console.WriteLine($"Error occurred after retries: {exception}");
throw;
}
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 24
Each client has its own HttpClient, which would create a separate set of network connections. I suspect youāre running out of TCP ports or similar. I strongly suspect this will clear up the problem. I might try making a change to the repro to create a new client for each batch and see if that fixes the problem - then I could document it accordingly.
Iāve tried to reproduce this in https://github.com/jskeet/google-cloud-dotnet/tree/issue-10625 - Iāve not seen the problem yet.
My most recently attempt consisted of:
(The test took about 25 minutes from home.)
If youād be happy to run the repro code in your environment, the results would be interesting.
Youāre using
Encoding.Unicode.GetByteCount()
there, which will mean two bytes per character⦠I suspect theyāre mostly ASCII characters, so thatāll be 1 byte per character in UTF-8. That suggests itās more like 50-100 bytes per row in terms of data - with some overhead for the number of fields. Iāll edit my test accordingly, but Iād be surprised if that made a difference. Worth testing though.Hi @PureKrome,
Weāve discussed this in the team, and weād like to at least try to reproduce the problem for the sake of completeness, but we suspect we wonāt want to actually make any changes to how retries are performed⦠while it may be safe to automatically retry in your particular case, at the point where the network transport has problems weāre in unusual territory, and in many cases retrying would be the wrong approach.
Could you let us know: