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

Feature/31 readcommitedlock #39

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# NEventStore.Persistence.Sql

## 9.1.1

- Target Framework supported: netstandard2.0, net462
- Updated System.Data.SqlClient 4.8.5
- Added Azure SQL support to MsSqlDialect [#31](https://github.com/NEventStore/NEventStore.Persistence.SQL/issues/31)
- Fix: NEventStore constraint failed with MySql 8.x (works with 5.7) [#487](https://github.com/NEventStore/NEventStore/issues/487)

### Breaking Change

- The fix for [#487](https://github.com/NEventStore/NEventStore/issues/487) changed how the `Commits` table is created for MySql 8.x:
to update an existing database in order to run on 8.x you need to manually update the `Commits` table schema and change the constraint of the `CommitId` column
from: `CommitId binary(16) NOT NULL CHECK (CommitId != 0)` to: `CommitId binary(16) NOT NULL CHECK (CommitId <> 0x00)`.
- MsSqlDialects now have an `useAzureSql` parameter, if set to `true` the statement `WITH (READCOMMITTEDLOCK)` will be added to any `FROM Commits` query.
Copy link

@fschmied fschmied Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could even be made a default. It does no harm outside of Azure SQL. In fact, it will also make NEventStore more robust with local SQL Server, too, when someone enabled the READ COMMITTED SNAPSHOT option on the database.


## 9.0.1

- Added documentation files to NuGet packages (improved intellisense support) [#36](https://github.com/NEventStore/NEventStore.Persistence.SQL/issues/36)
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ SQL Persistence Engine for NEventStore

NEventStore.Persistence.Sql currently supports:

- .net framework 4.6.1
- .net framework 4.6.2
- .net standard 2.0
- .net 5.0
- .net 6.0
- MsSql
- SqlLite
- MySql
Expand Down Expand Up @@ -57,6 +55,18 @@ To build the project locally on a Windows Machine:
- Optional: update `.\src\.nuget\NEventStore.Persistence.Sql.nuspec` file if needed (before creating relase packages).
- Open a Powershell console in Administrative mode and run the build script `build.ps1` in the root of the repository.

## How to Run Unit Tests (locally)

- Install Database engines or use Docker to run them in a container (you can use the scripts in `./docker` folder).
- Define the following environment variables:

```
NEventStore.MsSql="Server=localhost,50001;Database=NEventStore;User Id=sa;Password=Password1;"
NEventStore.MySql="Server=localhost;Port=50003;Database=NEventStore;Uid=sa;Pwd=Password1;AutoEnlist=false;"
NEventStore.PostgreSql="Server=localhost;Port=50004;Database=NEventStore;Uid=sa;Pwd=Password1;Enlist=false;"
NEventStore.Oracle="Data Source=localhost:1521/XE;User Id=system;Password=Password1;Persist Security Info=True;"
```

## How to contribute

### Git-Flow
Expand Down
2 changes: 1 addition & 1 deletion dependencies/NEventStore
Submodule NEventStore updated 31 files
+12 −0 .config/dotnet-tools.json
+10 −0 Changelog.md
+2 −53 GitVersion.yml
+1 −1 appveyor.yml
+3 −4 build.ps1
+13 −4 readme.markdown
+1 −1 src/NEventStore.Benchmark/Benchmarks/PersistenceBenchmarks.cs
+7 −7 src/NEventStore.Benchmark/NEventStore.Benchmark.csproj
+1 −1 src/NEventStore.Benchmark/Support/EventStoreHelpers.cs
+1 −1 src/NEventStore.Example/MainProgram.cs
+9 −9 src/NEventStore.Example/NEventStore.Example.csproj
+4 −4 src/NEventStore.Persistence.AcceptanceTests/NEventStore.Persistence.AcceptanceTests.Core.csproj
+2 −2 src/NEventStore.Persistence.AcceptanceTests/PersistenceTests.cs
+1 −1 src/NEventStore.PollingClient/NEventStore.PollingClient.csproj
+1 −1 src/NEventStore.PollingClientExample/MainProgram.cs
+9 −9 src/NEventStore.PollingClientExample/NEventStore.PollingClientExample.csproj
+6 −6 src/NEventStore.Serialization.Binary.Tests/NEventStore.Serialization.Binary.Core.Tests.csproj
+6 −6 src/NEventStore.Serialization.Bson.Tests/NEventStore.Serialization.Bson.Core.Tests.csproj
+2 −2 src/NEventStore.Serialization.Bson/NEventStore.Serialization.Bson.Core.csproj
+6 −6 src/NEventStore.Serialization.Gzip.Tests/NEventStore.Serialization.GZip.Core.Tests.csproj
+6 −6 src/NEventStore.Serialization.Json.Tests/NEventStore.Serialization.Json.Core.Tests.csproj
+2 −2 src/NEventStore.Serialization.Json/NEventStore.Serialization.Json.Core.csproj
+6 −6 src/NEventStore.Serialization.Rijndael.Tests/NEventStore.Serialization.Rijndael.Core.Tests.csproj
+10 −10 src/NEventStore.Tests/NEventStore.Core.Tests.csproj
+1 −1 src/NEventStore/Diagnostics/PerformanceCounterPersistenceEngine.cs
+1 −1 src/NEventStore/Diagnostics/PerformanceCounters.cs
+1 −1 src/NEventStore/Messages.Designer.cs
+2 −2 src/NEventStore/NEventStore.Core.csproj
+3 −3 src/NEventStore/PersistenceWireup.cs
+1 −1 src/NEventStore/Resources.Designer.cs
+1 −1 src/NEventStore/Serialization/Messages.Designer.cs
2 changes: 1 addition & 1 deletion docker/docker-compose.ci.linux.db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
mysql:
container_name: nesci-mysql-1
platform: linux
image: mysql:5.7
image: mysql:8.0 #5.7
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.ci.windows.db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
mysql:
container_name: nesci-mysql-1
platform: windows
image: mysql:5.7
image: mysql:8.0 #5.7
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1;net461</TargetFrameworks>
<TargetFrameworks>net7.0;net462</TargetFrameworks>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyName>NEventStore.Persistence.MsSql.Tests</AssemblyName>
Expand All @@ -14,16 +14,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Transactions" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
using NEventStore.Persistence.Sql.Tests;

namespace NEventStore.Persistence.AcceptanceTests
{
namespace NEventStore.Persistence.AcceptanceTests {
using NEventStore.Persistence.Sql;
using NEventStore.Persistence.Sql.SqlDialects;
using NEventStore.Serialization;
using System.Data.SqlClient;
using System.Transactions;

public partial class PersistenceEngineFixture
{
public partial class PersistenceEngineFixture {
public ISqlDialect SqlDialect { get; set; } = new MsSqlDialect();

/// <summary>
/// this mimic the current NEventStore default values which is run outside any transaction (creates a scope that
/// suppresses any transaction)
/// </summary>
public TransactionScopeOption? ScopeOption { get; set; } = null; // the old default: TransactionScopeOption.Suppress;
public TransactionScopeOption? ScopeOption { get; set; } // the old default: TransactionScopeOption.Suppress;

public PersistenceEngineFixture()
{
#if NET461
#if NET462
_createPersistence = pageSize =>
new SqlPersistenceFactory(new EnviromentConnectionFactory("MsSql", "System.Data.SqlClient"),
new BinarySerializer(),
new MsSqlDialect(),
SqlDialect,
pageSize: pageSize,
scopeOption: ScopeOption
).Build();
#else
_createPersistence = pageSize =>
new SqlPersistenceFactory(new EnviromentConnectionFactory("MsSql", SqlClientFactory.Instance),
new BinarySerializer(),
new MsSqlDialect(),
SqlDialect,
pageSize: pageSize,
scopeOption: ScopeOption
).Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Linq;
using System.Transactions;
using FluentAssertions;
#if NET461
#if NET462
using NEventStore.Diagnostics;
#endif
using NEventStore.Persistence.AcceptanceTests.BDD;
Expand Down Expand Up @@ -123,7 +123,7 @@ public class IsolationLevelPersistenceEngineFixture
public IsolationLevelPersistenceEngineFixture()
{
_recorder = new IsolationLevelRecorder();
#if NET461
#if NET462
_connectionFactory = new EnviromentConnectionFactory("MsSql", "System.Data.SqlClient");
#else
_connectionFactory = new EnviromentConnectionFactory("MsSql", System.Data.SqlClient.SqlClientFactory.Instance);
Expand All @@ -141,7 +141,7 @@ public void Initialize()
_persistence.Drop();
_persistence.Dispose();
}
#if NET461
#if NET462
_persistence = new PerformanceCounterPersistenceEngine(_createPersistence(), "tests");
#else
_persistence = _createPersistence();
Expand Down
2 changes: 1 addition & 1 deletion src/NEventStore.Persistence.MsSql.Tests/WireupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected override void Context()
{
_eventStore = Wireup
.Init()
#if NET461
#if NET462
.UsingSqlPersistence(new EnviromentConnectionFactory("MsSql", "System.Data.SqlClient"))
#else
.UsingSqlPersistence(new EnviromentConnectionFactory("MsSql", System.Data.SqlClient.SqlClientFactory.Instance))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1;net461</TargetFrameworks>
<TargetFrameworks>net7.0;net462</TargetFrameworks>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyName>NEventStore.Persistence.MySql.Tests</AssemblyName>
Expand All @@ -14,17 +14,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MySql.Data" Version="8.0.27" />
<PackageReference Include="MySql.Data" Version="8.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Data" />
<Reference Include="System.Transactions" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial class PersistenceEngineFixture
{
public PersistenceEngineFixture()
{
#if NET461
#if NET462
_createPersistence = pageSize =>
new SqlPersistenceFactory(
new EnviromentConnectionFactory("MySql", "MySql.Data.MySqlClient"),
Expand Down
2 changes: 1 addition & 1 deletion src/NEventStore.Persistence.MySql.Tests/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient"/>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.27.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.1.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</DbProviderFactories>
</system.data>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1;net461</TargetFrameworks>
<TargetFrameworks>net7.0;net462</TargetFrameworks>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyName>NEventStore.Persistence.PostgreSql.Tests</AssemblyName>
Expand All @@ -13,15 +13,15 @@
<DefineConstants Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">NUNIT</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Transactions" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Npgsql" Version="6.0.0" />
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
<PackageReference Include="Npgsql" Version="7.0.4" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public PersistenceEngineFixture()
// It will be done when creating the PostgreNpgsql6Dialect dialect
// AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);

#if NET461
#if NET462
_createPersistence = pageSize =>
new SqlPersistenceFactory(
new EnviromentConnectionFactory("PostgreSql", "Npgsql"),
Expand Down
1 change: 1 addition & 0 deletions src/NEventStore.Persistence.Sql.Core.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
..\appveyor.yml = ..\appveyor.yml
..\build.ps1 = ..\build.ps1
..\Changelog.md = ..\Changelog.md
.nuget\NEventStore.Persistence.Sql.nuspec = .nuget\NEventStore.Persistence.Sql.nuspec
..\README.md = ..\README.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class EnviromentConnectionFactory : IConnectionFactory
private readonly string _envVarKey;
private readonly DbProviderFactory _dbProviderFactory;

#if NET461
#if NET462
public EnviromentConnectionFactory(string envDatabaseName, string providerInvariantName)
{
_envVarKey = string.Format("NEventStore.{0}", envDatabaseName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net5.0;netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>net7.0;net462</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyName>NEventStore.Persistence.Sql.Tests</AssemblyName>
<RootNamespace>NEventStore.Persistence.Sql.Tests</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ namespace NEventStore.Persistence.AcceptanceTests
using Xunit.Should;
#endif

// The following tests actually works well only for MsSqlServer
// we'll need some refactoring to have initialization work
// for different of kinds of databases.

public enum TransactionScopeConcern
{
NoTransaction = 0,
Expand Down Expand Up @@ -319,11 +323,11 @@ public class Unsupported_Multiple_Completing_TransactionScopes_When_EnlistInAmbi
public Unsupported_Multiple_Completing_TransactionScopes_When_EnlistInAmbientTransaction_is_and_IsolationLevel_is(
TransactionScopeConcern enlistInAmbientTransaction,
IsolationLevel transationIsolationLevel
) : base(enlistInAmbientTransaction, transationIsolationLevel, true)
) : base(enlistInAmbientTransaction, transationIsolationLevel, completeTransaction: true)
{ }

[Fact]
public void should_throw_an_Exception_only_if_no_transaction_or_enlist_in_ambient_transaction_and_IsolationLevel_is_Serializable()
public void Should_throw_an_Exception_only_if_no_transaction_or_enlist_in_ambient_transaction_and_IsolationLevel_is_Serializable()
{
_thrown.Should().BeOfType<AggregateException>();
_thrown.InnerException.Should().BeOfType<StorageException>();
Expand Down Expand Up @@ -557,7 +561,7 @@ IsolationLevel transationIsolationLevel
) : base(enlistInAmbientTransaction, transationIsolationLevel, completeTransaction: true)
{ }

#if NET461
#if NET462
// some of these tests fails with a local instance of sql sever
[Fact]
public void should_throw_an_StorageUnavailableException()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// netstandard does not have support for DbFactoryProviders, we need a totally different way to initialize the driver
#if NET461
#if NET462
namespace NEventStore.Persistence.Sql
{
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net5.0;netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RootNamespace>NEventStore.Persistence.Sql</RootNamespace>
<AssemblyName>NEventStore.Persistence.Sql</AssemblyName>
Expand All @@ -27,10 +27,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Configuration" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
Expand Down
Loading