dotnet / orleans

Cloud Native application framework for .NET
https://docs.microsoft.com/dotnet/orleans
MIT License
10.09k stars 2.03k forks source link

AdoNet Clustering: Missing CleanupDefunctSiloEntriesKey query #8676

Open m3nax opened 1 year ago

m3nax commented 1 year ago

Problem:

When i run the project an exception was thrown

System.ArgumentException: 'Not all required queries found. Missing are: CleanupDefunctSiloEntriesKey

The CleanupDefunctSiloEntriesKey query is missing from the SQL script SQLServer-Clustering.sql, checked main and v7.2.2 branches

Used configuration:

file project.csproj

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Orleans.Clustering.AdoNet" Version="7.2.2" />
    <PackageReference Include="Microsoft.Orleans.Persistence.AdoNet" Version="7.2.2" />
    <PackageReference Include="Microsoft.Orleans.Server" Version="7.2.2">
      <TreatAsUsed>true</TreatAsUsed>
    </PackageReference>
    <PackageReference Include="System.Data.SqlClient" Version="4.8.5">
      <TreatAsUsed>true</TreatAsUsed>
    </PackageReference>
  </ItemGroup>

</Project>

file: program.cs

const string connectionString = "***";

var builder = WebApplication.CreateBuilder(args);

builder.Host.UseOrleans(siloBuilder =>
{
    siloBuilder
        .Configure<ClusterOptions>(options =>
        {
            options.ClusterId = "Cluster42";
            options.ServiceId = "MyAwesomeService";
        })
        .UseAdoNetClustering(options =>
        {
            options.ConnectionString = connectionString;
            options.Invariant = "System.Data.SqlClient";
        })
        .ConfigureEndpoints(siloPort: 11111, gatewayPort: 30000);

    siloBuilder.AddAdoNetGrainStorage("batt", options =>
    {
        options.Invariant = "System.Data.SqlClient";
        options.ConnectionString = connectionString;
    });
});

var app = builder.Build();

app.Run();

Guide used:

Sql script used for Database creation:

Similar issue:

snovak7 commented 1 year ago

Migrations folder has it https://github.com/dotnet/orleans/blob/main/src/AdoNet/Orleans.Clustering.AdoNet/Migrations/SQLServer-Clustering-3.7.0.sql

m3nax commented 1 year ago

Thanks, can I open a pull request to add the missing query to the clustering SQL script? Anyone who starts using this project from version 7.2.x with clustering gets an error like me during startup.

snovak7 commented 1 year ago

I don't know what's the idea here, ideally there would be migration that would automatically deploy tables, I do this separately with init container in Kubernetes, other would be as a startup task? @ReubenBond any ideas or goals for this?