fixer-m / snowflake-db-net-client

Snowflake .NET Client
Apache License 2.0
51 stars 14 forks source link

Socket exhaustion #42

Open misteam opened 1 year ago

misteam commented 1 year ago

There doesn't seem to be any way to dispose of the Snowflake Client once the operation is completed. Having embedded snowflake operations seems to lead to socket exhaustion.

System.IO.IOException: 'Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..' Inner Exception: SocketException: The I/O operation has been aborted because of either a thread exit or an application request.

Example:


            SnowflakeClient snowflakeClient = new SnowflakeClient(this.userName, this.password, this.account);

            var dbResults = await snowflakeClient.QueryAsync<MyObject>(sql: sqlQuery);

            List<MyObject> myObjects= new List<MyObject>();
            Parallel.ForEach(dbResults,async myObject=>
            {
                myObject.Address = await this.GetMyObjectAddressAsync(myObject.Id);
                myObject.Phones = await this.GetMyObjectPhoneNumbersAsync(myObject.Id);
                myObject.Emails = await this.GetMyObjectEmailAddressesAsync(myObject.Id);
                myObject.Employer = await this.GetMyObjectEmployerAsync(myObject.Id);
                myObject.Status = await this.GetMyObjectStatusAsync(myObject.Id);
                myObject.Tags = await this.GetMyObjectTagsAsync(myObject.Id);

                myObjects.Add(myObject);
            });
            return myObjects;