microsoft / durabletask-mssql

Microsoft SQL storage provider for Durable Functions and the Durable Task Framework
MIT License
87 stars 32 forks source link

External client ignores task hub name configuration #127

Closed bhugot closed 1 year ago

bhugot commented 2 years ago

Hello, When using an external client with sql provider. the specified task hub is ignored. The only way to have the specified task hub used is actually to use this

services.Configure<DurableTaskOptions>(options =>
        {
            options .HubName = "CustomTaskHub";
        });

But it's only one taskhub that could be use this way. And we need to be able to ask for many task hub on same sql schema. What we do is

private async Task<IReadOnlyCollection<DurableOrchestrationStatus>> SearchPerTaskHubAsync(string taskHub,
        OrchestrationStatusQueryCondition condition, CancellationToken cancellationToken)
    {
        var client = _durableClientFactory.CreateClient(new DurableClientOptions
        {
            TaskHub = taskHub // <-- this is not used
        });
        var result = new List<DurableOrchestrationStatus>();
        while (true)
        {
            var page = await client.ListInstancesAsync(condition, cancellationToken);
            result.AddRange(page.DurableOrchestrationState);
            if(string.IsNullOrEmpty(page.ContinuationToken))
                return result;
            condition.ContinuationToken = page.ContinuationToken;
        }
    }
bhugot commented 2 years ago

I should have we activated EXECUTE dt.SetGlobalSetting @Name='TaskHubMode', @Value=0

bhugot commented 2 years ago

Ok I think that I have found the root cause of it https://github.com/microsoft/durabletask-mssql/blob/531422c6260bed46495dd91bb4741f1f675a6dc9/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityProviderFactory.cs#L90 it's creating another SqlOrchestrationService instead of using the one created correctly one line before so it should instead do that

SqlOrchestrationService orchestrationService = new SqlOrchestrationService(clientOptions.GetOrchestrationServiceSettings(
                    this.extensionOptions,
                    this.connectionInfoResolver));
                clientProvider = new SqlDurabilityProvider(
                    orchestrationService,
                    clientOptions);
bhugot commented 1 year ago

@cgillum any date for the release or is it possible to have a preview?

cgillum commented 1 year ago

@bhugot the thing that's blocking the release is that I need to put together a suite of schema upgrade/compatibility tests now that we've reached the stable release versions. This will take some time and we don't have a date for it yet. I can get you a preview package if you're okay without it containing any database upgrade compatibility validation.

bhugot commented 1 year ago

Would be great for the preview.

cgillum commented 1 year ago

OK. You can find the preview nuget packages uploaded here:

bhugot commented 1 year ago

Thanks alot