Skip to content

Instantly share code, notes, and snippets.

View saurabh500's full-sized avatar
Working !

Saurabh Singh saurabh500

Working !
  • Microsoft Corp
View GitHub Profile
@saurabh500
saurabh500 / Build.md
Created September 5, 2024 18:10
Building and testing .Net core driver on linux

Requires Ubuntu 22.04

  1. Install dotnet sdk 8.0
  2. Install pwsh
dotnet build -p:OSGroup=Unix -t:BuildNetCore
dotnet build -p:OSGroup=Unix -t:BuildTestsNetCore	

Nothing to see here.

@saurabh500
saurabh500 / DiscussionClientXIO.md
Last active July 19, 2024 23:14
Streams in SQL Client

Purpose:

Starting this discussion thread to brainstorm the future of SqlClientX I/O to be performant, while adhering to the various requirements

Transport requirements

  1. Named Pipes
  2. Shared Memory (it is essentially Named pipe with a special NP path)
  3. TCP
@saurabh500
saurabh500 / SqlDbType and SqlTypes.md
Last active July 12, 2024 20:34
Json Type support in SQL Server

Any datatype support in SqlClient depends on System.Data.SqlDbType being enhanced to provide the enum for the datatype being added. At the same time, a SqlType needs to be exposed which will allows the clients to represent the internals of the JSON datatype.

SqlDbType is an enum which is shipped as part of System.Data.Common.dll in dotnet/runtime and in netfx, the type is shipped from System.Data.dll

Typically all the drivers like Npgsql and Oracle's data provider for ADO.Net have their own Types enum, which ships with the driver. NpgSqlDbType and OracleDbType

However there are implementations in dotnet/runtime which depend on SqlDbType. These implementations were ported from .Net framework and to light up the implementation, the SqlDbType had to be shipped with dotnet/runtime.

@saurabh500
saurabh500 / DbDataSources.md
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
saurabh500 / Chain of responsibilities.md
Last active July 1, 2024 17:02
Explanation of Chain of handlers

Chain of handlers 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
saurabh500 / environmentvariables.md
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
saurabh500 / DebugAssertFix.md
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 https://github.com/dotnet/corefx/blob/e89d17a0a97d5de707f24587118acc8072667b78/src/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserStateObject.cs#L2530 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
saurabh500 / RunningEfTestsWithSqlClient.md
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 https://github.com/aspnet/EntityFrameworkCore/
  2. Build the repo using build.cmd or build.sh 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
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.