Skip to content

Instantly share code, notes, and snippets.

View saurabh500's full-sized avatar
Working !

Saurabh Singh saurabh500

Working !
View GitHub Profile
saurabh500 /
Last active June 12, 2024 14:30
Some SqlClient ideas

Evolution of SqlClient with DbDataSource

What we want to do ?

  1. Provide a high throughput connection pool in SqlClient.
  2. Connection pool should increase the throughput when the connections are being opened successfully and in a consistent time.
  3. Connection pool should decrease the throughput when the connections start failing or the latency for connection establishment increases.

Improve the performance of Async I/O with SqlClient

saurabh500 / Chain of
Last active June 11, 2024 23:01
Explanation of Chain of responsibilities

Chain of responsibilities in Sql Connection open.

The following handlers are used during connection establishment.

graph LR
    A[DataSourceHandler] --> B[TransportHandler]
    B --> C[PreLoginHandler]
 C --> D[LoginHandler]
saurabh500 /
Created July 24, 2020 19:42
Check environment variables in Linux for a process

Find the process id for which the environment variables need to be found

ps faux | grep 'your_process'

Result saurabh 11654 0.6 3.0 3773360 243208 pts/1 Sl 10:33 0:47 /usr/lib/jvm/java-8-openjdk-amd64/bin/java

Get the PID of the process which is 11654 in the case above

cat /proc/11654/environ

saurabh500 /
Last active May 22, 2019 01:09
Description of Debug Assert fix

When an error occurs on the connection in case of MARS, during the execution of a reader, it forces the connection to be closed. While closing the connection the TdsParserSessionPool is Disposed

During this process of tearing down the connection, the underlying packet is released at when the SNI error is read by TdsParserStateObject

In case of the Native SNI, the packet release also tears down any callbacks that are associated with the packet, and hence the ReadAsyncCallback is never triggered.

In case of managed SNI, the packet release sets the private SNIAsyncCallback _completionCallback to null.

My fix is to check if the _completionCallBack is null and if it is, then the upstream TdsParserStateobject is not notified of the error via the callback.

saurabh500 /
Last active March 9, 2018 21:08
Instructions to run the Entity Framework Core tests

The following steps should be followed to run the Entity Framework tests and how to run the tests with modified SqlClient.

  1. Clone the repo
  2. Build the repo using build.cmd or depending on the OS you are on.

Make a note of the dotnet path that the build is using. This will be needed to execute specific tests

E.g. In the following the path is C:\Users\sausing.dotnet\x64\dotnet.exe

D:\aspnet\EntityFrameworkCore>build --help
saurabh500 / gist:a0f980334cb62d79a5dbd0a1cbdd8065
Last active August 23, 2017 07:47
Integrated Auth Setup for Linux

I am outlining the steps for setting up Kerberos on Ubuntu for Integrated Authentication. The Kerberos packages are installed by default on macOS, and the configuration on macOS is the same as Ubuntu. I have tested these steps with Integrated Auth of our development version of SqlClient on Ubuntu1404, 1604 and macOS.

Joining the domain on linux doesn’t guarantee a Kerberos ticket will be generated for use by GSSAPI. The following are the minimum steps necessary to test Integrated Auth on Linux. For further automation where the tickets may need to be renewed on a regular basis or without human intervention, the users can use the KeyTab file.

For Integrated Authentication setup on Linux

  1. Install krb5-user package using apt-get. This would provide the kinit command the configurations needed to interact with Active Directory.

  2. Configure the KDC in krb5.conf file. You could also get the KDC details from the domain controller admin of the organization.

Azure Specific Features. Feature port needed.


Federated auth

  This was a new feature added to Azure Sql. Needs a port to Sql Client on .Net Core
  Needed for Federated Authentication.
saurabh500 / LocalDB.Windows.cs
Created March 24, 2017 02:52
LocalDB implementation with LazyInitialization
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.DriverManager;
public class CRUD {
public static void main(String[] args) {