Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add | Feature: SqlBatch api #1825

Merged
merged 23 commits into from Nov 9, 2023
Merged

Conversation

Wraith2
Copy link
Contributor

@Wraith2 Wraith2 commented Nov 3, 2022

Implements the core of the SqlBatch api re: #19

Implements batching and some tests to cover the basic functionality provided.

Does not implement Always Encrypted for batches. AE prepares statements by roundtripping to the server to get encryption information so there is no way to send them in a single statement unless the entire batch were prepared. I think this scenario needs some discussion about how it should be implemented with knowledge of how batching will work because an implementation is attempted.

We could really do with more tests. Anyone who is interested in this feature please feel free to work up any test scenarios you can and try them to see what the sharp edges may be and if any modifications are required.

[Edit]
There is no documentation added. If someone is going to suffer through producing documentation for these new apis they should at least be getting paid for it so I'll leave that to the MS team.

@Wraith2
Copy link
Contributor Author

Wraith2 commented Nov 4, 2022

Something is wrong with the CI builds. Even if the netfx ref build can't find IAsyncEnumerable it should still work for net6.0 builds because with net6.0 it's in-box. But all builds are failing. That implies that the net6.0 builds aren't targetting net6.0 somehow. Local clean+build+build-tests works.

I also don't understand how the net462 src project is locating IAsyncEnumerable and Task. They're used in the code and the netfx src build works, but ref build doesn't and yet there is no reference to the location that VS says task is being imported from in src. If it's a transitive dependency I can't see the parent.

@Wraith2
Copy link
Contributor Author

Wraith2 commented Nov 4, 2022

@JRahnama I'm going to pick on you since you were involved in setting up the net6 pipelines.
Have a read through this log https://sqlclientdrivers.visualstudio.com/public/_build/results?buildId=56433&view=logs&j=3fb47f8c-2cf5-56b8-faf9-acd01e45e69f&t=53c9ef8a-81a8-50fd-c40e-0dcb5a7f342a

and notice that it's from the Win SQL 2019 net6.0,AnyCPU,false,2,netstandard2.1 build run so to me that should be building for net6.0 and failing that possibly netstandard2.1. If you look at the failing step and pull out the compilation that it's failing on you get this commandline:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Roslyn\csc.exe 
/noconfig 
/unsafe- 
/checked- 
/nowarn:1701,1702,1701,1702 
/fullpaths 
/nostdlib+ 
/errorreport:prompt 
/warn:4 
/doc:D:\a\_work\1\s\src\..\artifacts\Project\bin\Windows_NT\Release\Microsoft.Data.SqlClient\ref\\netstandard2.0\Microsoft.Data.SqlClient.xml 
/define:TRACE;RELEASE;NETSTANDARD;NETSTANDARD2_0;NETSTANDARD1_0_OR_GREATER;NETSTANDARD1_1_OR_GREATER;NETSTANDARD1_2_OR_GREATER;NETSTANDARD1_3_OR_GREATER;NETSTANDARD1_4_OR_GREATER;NETSTANDARD1_5_OR_GREATER;NETSTANDARD1_6_OR_GREATER;NETSTANDARD2_0_OR_GREATER 
/highentropyva+ 
/reference:C:\Users\cloudtest\.nuget\packages\microsoft.identity.client\4.47.2\lib\netstandard2.0\Microsoft.Identity.Client.dll 
/reference:C:\Users\cloudtest\.nuget\packages\microsoft.identitymodel.abstractions\6.22.0\lib\netstandard2.0\Microsoft.IdentityModel.Abstractions.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\Microsoft.Win32.Primitives.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\mscorlib.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\netstandard.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.AppContext.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Collections.Concurrent.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Collections.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Collections.NonGeneric.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Collections.Specialized.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.ComponentModel.Composition.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.ComponentModel.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.ComponentModel.EventBasedAsync.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.ComponentModel.Primitives.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.ComponentModel.TypeConverter.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Console.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Core.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Data.Common.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Data.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Diagnostics.Contracts.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Diagnostics.Debug.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Diagnostics.FileVersionInfo.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Diagnostics.Process.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Diagnostics.StackTrace.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Diagnostics.TextWriterTraceListener.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Diagnostics.Tools.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Diagnostics.TraceSource.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Diagnostics.Tracing.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Drawing.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Drawing.Primitives.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Dynamic.Runtime.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Globalization.Calendars.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Globalization.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Globalization.Extensions.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.IO.Compression.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.IO.Compression.FileSystem.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.IO.Compression.ZipFile.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.IO.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.IO.FileSystem.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.IO.FileSystem.DriveInfo.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.IO.FileSystem.Primitives.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.IO.FileSystem.Watcher.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.IO.IsolatedStorage.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.IO.MemoryMappedFiles.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.IO.Pipes.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.IO.UnmanagedMemoryStream.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Linq.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Linq.Expressions.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Linq.Parallel.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Linq.Queryable.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.Http.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.NameResolution.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.NetworkInformation.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.Ping.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.Primitives.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.Requests.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.Security.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.Sockets.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.WebHeaderCollection.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.WebSockets.Client.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.WebSockets.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Numerics.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.ObjectModel.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Reflection.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Reflection.Extensions.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Reflection.Primitives.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Resources.Reader.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Resources.ResourceManager.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Resources.Writer.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Runtime.CompilerServices.VisualC.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Runtime.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Runtime.Extensions.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Runtime.Handles.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Runtime.InteropServices.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Runtime.InteropServices.RuntimeInformation.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Runtime.Numerics.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Runtime.Serialization.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Runtime.Serialization.Formatters.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Runtime.Serialization.Json.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Runtime.Serialization.Primitives.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Runtime.Serialization.Xml.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Security.Claims.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Security.Cryptography.Algorithms.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Security.Cryptography.Csp.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Security.Cryptography.Encoding.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Security.Cryptography.Primitives.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Security.Cryptography.X509Certificates.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Security.Principal.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Security.SecureString.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.ServiceModel.Web.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Text.Encoding.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Text.Encoding.Extensions.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Text.RegularExpressions.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Threading.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Threading.Overlapped.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Threading.Tasks.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Threading.Tasks.Parallel.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Threading.Thread.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Threading.ThreadPool.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Threading.Timer.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Transactions.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.ValueTuple.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Web.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Windows.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Xml.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Xml.Linq.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Xml.ReaderWriter.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Xml.Serialization.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Xml.XDocument.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Xml.XmlDocument.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Xml.XmlSerializer.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Xml.XPath.dll 
/reference:C:\Users\cloudtest\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Xml.XPath.XDocument.dll 
/debug- 
/debug:portable 
/filealign:512 
/optimize+ 
/pathmap:"C:\Users\cloudtest\.nuget\packages\=/_/,C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\=/_1/," 
/out:D:\a\_work\1\s\src\..\artifacts\Project\obj\Release\Microsoft.Data.SqlClient\ref\netstandard2.0\Microsoft.Data.SqlClient.dll 
/target:library 
/warnaserror+ 
/utf8output 
/deterministic+ 
/langversion:9.0 
/analyzerconfig:D:\a\_work\1\s\.editorconfig 
/analyzerconfig:D:\a\_work\1\s\src\..\artifacts\Project\obj\Release\Microsoft.Data.SqlClient\ref\netstandard2.0\Microsoft.Data.SqlClient.GeneratedMSBuildEditorConfig.editorconfig 
Microsoft.Data.SqlClient.cs 
Microsoft.Data.SqlClient.Manual.cs 
..\..\ref\System.Data.Common.Batch.cs 
..\..\ref\System.Data.Common.Batch.IAsyncDisposable.cs 
..\..\ref\Microsoft.Data.SqlClient.Batch.cs 
..\..\ref\Microsoft.Data.SqlClient.Batch.NetCoreApp.cs 
Microsoft.Data.SqlClient.NetStandard.cs 
"D:\a\_work\1\s\src\..\artifacts\Project\obj\Release\Microsoft.Data.SqlClient\ref\netstandard2.0\.NETStandard,Version=v2.0.AssemblyAttributes.cs" 
D:\a\_work\1\s\src\..\artifacts\Project\obj\Release\Microsoft.Data.SqlClient\ref\netstandard2.0\Microsoft.Data.SqlClient.AssemblyInfo.cs 
/warnaserror+:NU1605

you can see that it's doing a netstandard 2.0 build of the ref assembly. It's doing this on every leg.

How do i replicate this build configuration locally? the build docs only list netfx and netcore targets. how do i target netstandard2.0?

@JRahnama
Copy link
Member

JRahnama commented Nov 5, 2022

@Wraith2 I will provide full info on how to build and run the tests as the pipeline does, but I will do that on Monday if you don't mind. I had a very busy day setting up Kerberos testing machine on azure and it just took all my time.

@Wraith2
Copy link
Contributor Author

Wraith2 commented Nov 5, 2022

Ok, have a good weekend.

@JRahnama
Copy link
Member

@Wraith2 sorry for the delay: here is the process:

  1. Build the driver for all configurations: MSBuild -t:BuildAllConfigurations -p:GenerateNuGet=false
  2. Build NetStandard AKV: MSBuild -t:BuildAKVNetStAllOS
  3. NetFx AKV: MSBuild -t:BuildAKVNetFx
  4. Net AKC: MSBuild -t:BuildAKVNetCoreAllOS

This step builds the driver and publishes the artifacts. This is to make sure everything works fine, and builds are done with no issues.
Now there are several variables (Multipliers on pipelines)

  1. TF (Target Framework)
  2. Platform (AnyCPU, x64, x86. Currently we run pipelines for AnyCPU)
  3. ,UseManagedSNIOnWindows (true and false, we test for both)
  4. TestSet. we have divided the tests into 3 sets.
  5. TargetNetStandardVersion which is currently NetStandard2.1

The next steps when it comes to testing with Sql server 2019 and windows:

  1. Build the driver: MSBuild -t:BuildAll
  2. Build the driver for Netstandard: MSBuild -t:BuildAll -p:ReferenceType=NetStandard -p:TargetNetStandardVersion=Netstandard2.1
  3. Build Tests for netfx: MSBuild -t:BuildTestsNetfx
  4. Build tests for netcore: MSBuild -t:BuildTestsNetCore
  5. Build tests for netstandard: MSBuild -t:BuildTestsNetCore -p:ReferenceType=NetStandard -p:TargetNetStandardVersion=Netstandard2.1
  6. MSBuild -t:RunTests -p:TF=Net6.0
  7. MSBuild -t:RunTests -p:TF=net462

For Unix:

  1. MSBuild -t:BuildAll -p:TestEnabled=true -p:GenerateDocumentationFile=false -p:configuration=Release
  2. MSBuild -t:BuildTestsNetCore -p:Configuration=Release -p:OSGroup=Unix -p:TargetNetCoreVersion=net6.0
  3. MSBuild -t:RunTests -p:TF=net6.0 -p:configuration=Release

There are different type of test for Package. Let me know if you need them as well.

@Wraith2
Copy link
Contributor Author

Wraith2 commented Nov 11, 2022

The command:
MSBuild -t:BuildTestsNetCore -p:ReferenceType=NetStandard -p:TargetNetStandardVersion=Netstandard2.1 fails. It fails because netstandard does not contain the DbBatch classes (which are part of net6.0 but the net6 runtime does so by referencing the netstandard version of the assembly it picks up the classes in both and can't compile.

That isn't the error that I'm seeing in the CI but it may have a similar cause. Do you have any idea how to resolve the problems? I don't see a way to get the builds containing the correct items and also work with the combinations of references used.

@JRahnama
Copy link
Member

JRahnama commented Nov 17, 2022

@Wraith2 are you able to build locally? I am able to do so.

@JRahnama
Copy link
Member

If you can address the conflict, I will spend tomorrow morning to fix the pipeline issue, if there is any.

@Wraith2
Copy link
Contributor Author

Wraith2 commented Nov 17, 2022

No, I can't build locally anymore. The dependencies aren't right somewhere. I've added what I need to the Versions.props file but I'm getting a conflict with two other versions of the same assembly and I can't see either of them being referenced. Code changes I'll fight with for hours but msbuild is something else entirely. I'd be very grateful if you could see if you can untangle whatever dependency mess is going on here.

@JRahnama
Copy link
Member

No, I can't build locally anymore. The dependencies aren't right somewhere. I've added what I need to the Versions.props file but I'm getting a conflict with two other versions of the same assembly and I can't see either of them being referenced. Code changes I'll fight with for hours but msbuild is something else entirely. I'd be very grateful if you could see if you can untangle whatever dependency mess is going on here.

this is weird. I just bult your branch successfully. On CLI and on VS 2022. msbuild version:

image

can you confirm you have same MSBuild?

@Wraith2
Copy link
Contributor Author

Wraith2 commented Nov 17, 2022

E:\Programming\csharp7\SqlClient>msbuild
MSBuild version 17.4.0+18d5aef85 for .NET Framework

Same

Try it in visual studio. Also notice that none of the CI legs can build it now. Just running basic build steps work but when you get to running tests (not compiling) you'll find it doesn't work because it's using a netstandard 2.1 ref which can't work on net6 because both contain SqlBatch implementations.

@JRahnama
Copy link
Member

JRahnama commented Dec 9, 2022

@Wraith2 I was wondering if you can test your PR with the changes from PR #1867 addressing the regression found in the ref folder of netcore. It is a very small change, but netstandard2.1 was totally ignored for some of the files.

@Wraith2
Copy link
Contributor Author

Wraith2 commented Dec 9, 2022

Rebased and pushed, lets see what the CI thinks.

@DavoudEshtehari DavoudEshtehari added this to the 5.2.0-preview3 milestone May 24, 2023
@DavoudEshtehari DavoudEshtehari added this to In progress in SqlClient v5.2 via automation May 24, 2023
@Wraith2
Copy link
Contributor Author

Wraith2 commented Jun 29, 2023

@David-Engel could I get some eyes on this please? As far as I know the only problem is that the CI is trying to use a ns2.1 ref assembly inappropriately which causes a type to be multiply defined.

@David-Engel
Copy link
Contributor

/azp run CI-SqlClient

@azure-pipelines
Copy link

Pull request contains merge conflicts.

@Wraith2
Copy link
Contributor Author

Wraith2 commented Nov 9, 2023

Given that netconf and the release of net8 and the likely release of the accompanying ef core version are next week it feels like this isn't going to get merged and released in time. Disappointed is too small and simple a word to convey how I feel about this.

@roji
Copy link
Member

roji commented Nov 9, 2023

Just as an FYI, EF Core 8.0 is a long-term support release, and therefore can only take a dependency on a SqlClient LTS release as well - AFAIK as I know SqlClient 5.2 won't be one (since 5.1 was LTS). So EF 8.0 wouldn't be able to take a dependency on SqlClient 5.2 (unless I'm getting the SqlClient LTS/STS wrong here).

Beyond that, EF itself currently doesn't yet make use of the DbBatch - that's very much in the plan, but is a non-trivial refactor (follow dotnet/efcore#18990). As more ADO.NET providers implement the API, it would become more valuable to do this in EF - so I'm definitely looking forward to seeing this PR merged in SqlClient!

@ajcvickers
Copy link
Member

@Wraith2 We definitely appreciate all the work you have done on this.

@JRahnama JRahnama changed the title Feature: SqlBatch api Add | Feature: SqlBatch api Nov 9, 2023
@David-Engel David-Engel dismissed cheenamalhotra’s stale review November 9, 2023 18:47

Requested changes have been addressed.

SqlClient v5.2 automation moved this from Review in progress to Reviewer approved Nov 9, 2023
@David-Engel David-Engel merged commit d30d9d1 into dotnet:main Nov 9, 2023
132 checks passed
SqlClient v5.2 automation moved this from Reviewer approved to Done Nov 9, 2023
@David-Engel
Copy link
Contributor

@Wraith2 We definitely appreciate all the work you have done on this.

Ditto on the appreciation. Merged now. Was just waiting for that second reviewer. Team has been under extra pressure that has pushed several non-critical things out. The good news is that we have a couple of new people onboarding that I hope will improve things after they've ramped up.

@Wraith2 Wraith2 deleted the api-batching-net6 branch November 9, 2023 20:32
@roji
Copy link
Member

roji commented Nov 10, 2023

Thanks @Wraith2! Super happy to see this, looking forward to playing around with it once the release is out!

@mgravell
Copy link
Member

Woohoo on the merge! Any ETA on binaries? I'm literally writing Dapper's batch support right now - would love to be able to smoke test this

@ErikEJ
Copy link
Contributor

ErikEJ commented Nov 12, 2023

@mgravell 5.2 preview4 should be in November...

@JRahnama
Copy link
Member

@mgravell 5.2 preview4 should be in November...

Actually, it is planned for sometime in first week of December if everything goes as planned.

@ErikEJ
Copy link
Contributor

ErikEJ commented Nov 13, 2023

@JRahnama This year hopefully 😅

@Wraith2
Copy link
Contributor Author

Wraith2 commented Nov 13, 2023

When is 5.2 RTM supposed to be happening? How many more previews are they likely to be?

@ErikEJ
Copy link
Contributor

ErikEJ commented Nov 13, 2023

@Wraith2 I saw January 2024 mentioned somewhere

@JRahnama
Copy link
Member

When is 5.2 RTM supposed to be happening? How many more previews are they likely to be?

Preview 4 should be last preview and GA version is somewhere in the new year as @ErikEJ mentioned.

@mgravell
Copy link
Member

@JRahnama @ErikEJ please see #2222

@ErikEJ
Copy link
Contributor

ErikEJ commented Nov 16, 2023

@Wraith2 FYI

@mgravell
Copy link
Member

mgravell commented Nov 16, 2023

FYI, some numbers from Dapper (after adding some local hackery re #2222):

| Method                        | Categories      | Count | IsOpen | Mean       | Error      | StdDev    | Ratio | RatioSD | Gen0     | Gen1     | Allocated | Alloc Ratio |
|------------------------------ |---------------- |------ |------- |-----------:|-----------:|----------:|------:|--------:|---------:|---------:|----------:|------------:|
| DapperAsync                   | Async,SqlClient | 1000  | True   | 120.845 ms | 23.8903 ms | 1.3095 ms |  1.00 |    0.01 |        - |        - | 1609750 B |        1.41 |
| DapperAotAsync_BatchNone      | Async,SqlClient | 1000  | True   | 116.517 ms | 30.0250 ms | 1.6458 ms |  0.96 |    0.01 |        - |        - | 1145102 B |        1.00 |
| DapperAotAsync_BatchAll       | Async,SqlClient | 1000  | True   |  73.106 ms |  5.4160 ms | 0.2969 ms |  0.60 |    0.01 |        - |        - | 1221267 B |        1.07 |
| DapperAotAsync_Batch32        | Async,SqlClient | 1000  | True   |  73.775 ms | 17.7965 ms | 0.9755 ms |  0.61 |    0.02 |        - |        - | 1250546 B |        1.09 |
| DapperAot_ManualAsync         | Async,SqlClient | 1000  | True   |  72.290 ms |  9.7130 ms | 0.5324 ms |  0.60 |    0.01 |        - |        - | 1218281 B |        1.06 |
| DapperAot_ManualPreparedAsync | Async,SqlClient | 1000  | True   |  72.019 ms | 30.2447 ms | 1.6578 ms |  0.60 |    0.02 |        - |        - | 1220233 B |        1.07 |
| ManualAsync                   | Async,SqlClient | 1000  | True   | 120.889 ms | 38.3381 ms | 2.1014 ms |  1.00 |    0.00 |        - |        - | 1144504 B |        1.00 |
| EntityFrameworkAsync          | Async,SqlClient | 1000  | True   |   6.981 ms |  1.8516 ms | 0.1015 ms |  0.06 |    0.00 | 320.3125 | 234.3750 | 5386977 B |        4.71 |
| SqlBulkCopyFastMemberAsync    | Async,SqlClient | 1000  | True   |   2.856 ms |  0.1298 ms | 0.0071 ms |  0.02 |    0.00 |  31.2500 |  31.2500 |  557015 B |        0.49 |
|                               |                 |       |        |            |            |           |       |         |          |          |           |             |
| Dapper                        | Sync,SqlClient  | 1000  | True   | 126.079 ms | 28.5030 ms | 1.5623 ms |  1.01 |    0.01 |        - |        - |  465309 B |    1,817.61 |
| DapperAot_BatchNone           | Sync,SqlClient  | 1000  | True   | 118.006 ms | 30.8140 ms | 1.6890 ms |  0.94 |    0.03 |        - |        - |     709 B |        2.77 |
| DapperAot_BatchAll            | Sync,SqlClient  | 1000  | True   |  70.783 ms | 28.0035 ms | 1.5350 ms |  0.57 |    0.02 |        - |        - | 1191080 B |    4,652.66 |
| DapperAot_Batch32             | Sync,SqlClient  | 1000  | True   |  75.743 ms |  7.9881 ms | 0.4379 ms |  0.61 |    0.01 |        - |        - |  858882 B |    3,355.01 |
| DapperAotManual               | Sync,SqlClient  | 1000  | True   |  74.230 ms | 22.6914 ms | 1.2438 ms |  0.59 |    0.02 |        - |        - | 1191080 B |    4,652.66 |
| DapperAot_PreparedManual      | Sync,SqlClient  | 1000  | True   |  75.121 ms | 17.0236 ms | 0.9331 ms |  0.60 |    0.02 |        - |        - | 1191098 B |    4,652.73 |
| Manual                        | Sync,SqlClient  | 1000  | True   | 125.183 ms | 35.4165 ms | 1.9413 ms |  1.00 |    0.00 |        - |        - |     256 B |        1.00 |
| EntityFramework               | Sync,SqlClient  | 1000  | True   |   6.970 ms |  3.3219 ms | 0.1821 ms |  0.06 |    0.00 | 312.5000 | 187.5000 | 5325728 B |   20,803.62 |
| SqlBulkCopyFastMember         | Sync,SqlClient  | 1000  | True   |   1.863 ms |  0.1745 ms | 0.0096 ms |  0.01 |    0.00 |        - |        - |   13672 B |       53.41 |
| SqlBulkCopyDapper             | Sync,SqlClient  | 1000  | True   |   1.839 ms |  0.4902 ms | 0.0269 ms |  0.01 |    0.00 |        - |        - |    7942 B |       31.02 |

what I'm looking at here is the BatchNone, BatchAll and Batch32 rows:

  • BatchNone inserts 1000 rows by keeping a single DbCommand, updating the parameters, and using ExecuteNonQuery 1000 times
  • BatchAll inserts the same 1000 rows in a single DbBatch with 1000 DbBatchCommand instances
  • Batch32 inserts the same 1000 rows by creating a DbBatch, loading 32, executing that, updating the 32, executing that, etc etc

analysis:

  • speed: nice improvement - ~0.6 vs vanilla Dapper, yay!
  • memory - quite a lot more allocatey; I'll see if I can isolate what those are; note, this is also the case for Npgsql - so: possibly "meh"

great job, @Wraith2 !

@mgravell
Copy link
Member

mgravell commented Nov 16, 2023

top allocs:

image

the parameters are not mine; they're internal (BatchState.Execute is after the commands have all been populated this method is basically DbBatch.ExecuteNonQuery with some extra bits like tracking)

image

ditto the string builders:

image

the strings ... some of these seem to be from uint parsing? maybe that can be optimized pretty easily

image

basically, assume that everything of note is "external call" (i.e. SqlClient) underneath BatchState.Execute ;p

@Wraith2
Copy link
Contributor Author

Wraith2 commented Nov 16, 2023

Parameters are very heavy and are always going to be a big source of allocations for anything in this api. Even if the user doesn't provide any the internal method of sending rpc uses several of them each time. It's something I've looked into many times to see if I can reduce the size of usage but made little difference on.

If you can upload the benchmark projects somewhere once you're dong I'll do a perf focussed pass over them and see what I can reduce.

@cheenamalhotra
Copy link
Member

Just throwing out a seed for thought, parameters as a collection can be thought of as a solution where user can pass an array of parameters together with statement. Something that ODBC driver supports (ref. Array of Parameters), but SqlClient doesn't yet. While you're focusing on perf improvements, this can be looked further into as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
netcore 🆕 Public API Use this label for new API additions to the driver.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet