Skip to content

Commit

Permalink
VCST-1752: Fix performance degradation on SQL Server (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-dudarev authored Sep 13, 2024
1 parent e767a8c commit 2ee6bc3
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_expression_bodied_lambdas = true:silent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="VirtoCommerce.Platform.Data.SqlServer" Version="3.825.0" />
<PackageReference Include="VirtoCommerce.Platform.Data.SqlServer" Version="3.851.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\VirtoCommerce.OrdersModule.Core\VirtoCommerce.OrdersModule.Core.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReference Include="VirtoCommerce.CustomerModule.Core" Version="3.803.0" />
<PackageReference Include="VirtoCommerce.NotificationsModule.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.PaymentModule.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.825.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.851.0" />
<PackageReference Include="VirtoCommerce.ShippingModule.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.StoreModule.Core" Version="3.800.0" />
</ItemGroup>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace VirtoCommerce.OrdersModule.Data.MySql;

public class MySqlDataAssemblyMarker
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public OrderDbContext CreateDbContext(string[] args)
connectionString,
ResolveServerVersion(serverVersion, connectionString),
db => db
.MigrationsAssembly(typeof(MySqlDbContextFactory).Assembly.GetName().Name));
.MigrationsAssembly(typeof(MySqlDataAssemblyMarker).Assembly.GetName().Name));

return new OrderDbContext(builder.Options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="VirtoCommerce.Platform.Data.MySql" Version="3.825.0" />
<PackageReference Include="VirtoCommerce.Platform.Data.MySql" Version="3.851.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtoCommerce.OrdersModule.Data\VirtoCommerce.OrdersModule.Data.csproj" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace VirtoCommerce.OrdersModule.Data.PostgreSql;

public class PostgreSqlDataAssemblyMarker
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public OrderDbContext CreateDbContext(string[] args)

builder.UseNpgsql(
connectionString,
db => db.MigrationsAssembly(typeof(PostgreSqlDbContextFactory).Assembly.GetName().Name));
db => db.MigrationsAssembly(typeof(PostgreSqlDataAssemblyMarker).Assembly.GetName().Name));

return new OrderDbContext(builder.Options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="VirtoCommerce.Platform.Data.PostgreSql" Version="3.825.0" />
<PackageReference Include="VirtoCommerce.Platform.Data.PostgreSql" Version="3.851.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtoCommerce.OrdersModule.Data\VirtoCommerce.OrdersModule.Data.csproj" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace VirtoCommerce.OrdersModule.Data.SqlServer;

public class SqlServerDataAssemblyMarker
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public OrderDbContext CreateDbContext(string[] args)

builder.UseSqlServer(
connectionString,
db => db.MigrationsAssembly(typeof(SqlServerDbContextFactory).Assembly.GetName().Name));
db => db.MigrationsAssembly(typeof(SqlServerDataAssemblyMarker).Assembly.GetName().Name));

return new OrderDbContext(builder.Options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="VirtoCommerce.Platform.Data.SqlServer" Version="3.825.0" />
<PackageReference Include="VirtoCommerce.Platform.Data.SqlServer" Version="3.851.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtoCommerce.OrdersModule.Data\VirtoCommerce.OrdersModule.Data.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.InventoryModule.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.Platform.Data" Version="3.825.0" />
<PackageReference Include="VirtoCommerce.Platform.Security" Version="3.825.0" />
<PackageReference Include="VirtoCommerce.Platform.Data" Version="3.851.0" />
<PackageReference Include="VirtoCommerce.Platform.Security" Version="3.851.0" />
<PackageReference Include="VirtoCommerce.SearchModule.Data" Version="3.800.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public async Task<ActionResult<CustomerOrder>> CreateOrderFromCart(string cartId
{
CustomerOrder retVal;

using (await AsyncLock.GetLockByKey(cartId).GetReleaserAsync())
using (await AsyncLock.GetLockByKey(cartId).LockAsync())
{
var cart = await _cartService.GetByIdAsync(cartId);
retVal = await _customerOrderBuilder.PlaceCustomerOrderFromCartAsync(cart);
Expand Down
9 changes: 6 additions & 3 deletions src/VirtoCommerce.OrdersModule.Web/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
using VirtoCommerce.Platform.Core.Security;
using VirtoCommerce.Platform.Core.Settings;
using VirtoCommerce.Platform.Data.Extensions;
using VirtoCommerce.Platform.Data.MySql.Extensions;
using VirtoCommerce.Platform.Data.PostgreSql.Extensions;
using VirtoCommerce.Platform.Data.SqlServer.Extensions;
using VirtoCommerce.SearchModule.Core.Model;
using VirtoCommerce.SearchModule.Core.Services;
using VirtoCommerce.StoreModule.Core.Model;
Expand All @@ -64,13 +67,13 @@ public void Initialize(IServiceCollection serviceCollection)
switch (databaseProvider)
{
case "MySql":
options.UseMySqlDatabase(connectionString);
options.UseMySqlDatabase(connectionString, typeof(MySqlDataAssemblyMarker), Configuration);
break;
case "PostgreSql":
options.UsePostgreSqlDatabase(connectionString);
options.UsePostgreSqlDatabase(connectionString, typeof(PostgreSqlDataAssemblyMarker), Configuration);
break;
default:
options.UseSqlServerDatabase(connectionString);
options.UseSqlServerDatabase(connectionString, typeof(SqlServerDataAssemblyMarker), Configuration);
break;
}
});
Expand Down
4 changes: 3 additions & 1 deletion src/VirtoCommerce.OrdersModule.Web/module.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<id>VirtoCommerce.Orders</id>
<version>3.826.0</version>
<version-tag />
<platformVersion>3.825.0</platformVersion>

<platformVersion>3.851.0</platformVersion>
<dependencies>
<dependency id="VirtoCommerce.Cart" version="3.800.0" />
<dependency id="VirtoCommerce.Catalog" version="3.800.0" />
Expand All @@ -16,6 +17,7 @@
<dependency id="VirtoCommerce.Shipping" version="3.800.0" />
<dependency id="VirtoCommerce.Store" version="3.800.0" />
</dependencies>

<title>Order Management</title>
<description>Document based flexible order management system</description>
<authors>
Expand Down

0 comments on commit 2ee6bc3

Please sign in to comment.