Skip to content

Instantly share code, notes, and snippets.

View saurabh500's full-sized avatar
🎯
Exploring

Saurabh Singh saurabh500

🎯
Exploring
View GitHub Profile
@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.

Azure Specific Features. Feature port needed.

T:System.Data.SqlClient.PoolBlockingPeriod
P:System.Data.SqlClient.SqlConnectionStringBuilder.PoolBlockingPeriod

Federated auth https://github.com/dotnet/corefx/issues/8807

T:System.Data.SqlClient.SqlAuthenticationMethod
P:System.Data.SqlClient.SqlConnection.AccessToken
T:System.Data.SqlClient.OnChangeEventHandler
T:System.Data.SqlClient.PoolBlockingPeriod
  This was a new feature added to Azure Sql. Needs a port to Sql Client on .Net Core
T:System.Data.SqlClient.SqlAuthenticationMethod
  Needed for Federated Authentication. https://github.com/dotnet/corefx/issues/8807
M:System.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Clear
M:System.Data.SqlClient.SqlBulkCopyColumnMappingCollection.RemoveAt(System.Int32)
F:System.Data.SqlClient.SqlBulkCopyOptions.AllowEncryptedValueModifications
M:System.Data.SqlClient.SqlClientFactory.System#IServiceProvider#GetService(System.Type)
@saurabh500
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) {
@saurabh500
saurabh500 / SchemaProposal.md
Last active February 4, 2016 23:03
GetColumnSchema API

API for GetColumnSchema

Problem

DbDataReader on .Net Framework, provides an API called DataTable GetSchemaTable() which was returns the metadata of the columns being read using the DbDataReader object. Because of the removal of DataTable in .Net Core this API had to be removed. DbDataReader.GetSchemaTable() needs a replacement in .Net core.

Progress

The data structure DbColumn along with the necessary attributes which should be present

xUnit.net DNX Runner (64-bit DNXCore 5.0)
Discovering: EntityFramework.MicrosoftSqlServer.FunctionalTests
Discovered: EntityFramework.MicrosoftSqlServer.FunctionalTests
Starting: EntityFramework.MicrosoftSqlServer.FunctionalTests
Microsoft.Data.Entity.SqlServer.FunctionalTests.SqlServerValueGenerationScenariosTest+DoNothingButSpecifyKeys.Insert_with_explicit_non_default_keys
Microsoft.Data.Entity.SqlServer.FunctionalTests.NullKeysSqlServerTest.Include_with_null_FKs_and_nullable_PK
System.Data.SqlClient.SqlException : The connection is broken and recovery is not possible. The connection is marked by the server as unrecoverable. No attempt was made to restore the connection.
Stack Trace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlConnection.ValidateAndReconnect(Action beforeDisconnect, Int32 timeout)