Azure / AppConfiguration

Questions, feedback and samples for Azure App Configuration service
MIT License
228 stars 69 forks source link

Not all KeyValueSelectors get refreshed after sentinel key changed #953

Open lissdy opened 3 weeks ago

lissdy commented 3 weeks ago

Followed https://learn.microsoft.com/en-us/azure/azure-app-configuration/enable-dynamic-configuration-aspnet-core We are using poll model for dynamic configuration

As the screenshot shows, we set three sentinel keys service:testService:sentinel, shared:testService:sentinel and shared:config:sentinel, and set RefreshAll as true for all sentinel keys. Three KeyValueSelectors are shared:testService:*, service:testService:* and shared:config:* Suppose any sentinel value change should trigger the service instance refresh all registered configurations.

image

But we noticed when we update configuration values and sentinel values, some KeyValueSelectors get refreshed but some are not. Service still retrieving the old values even 2 days later. We have to restart the service to ensure all configurations are refreshed.

Suppose all selected configuration values should be refreshed in minutes, could you please confirm if the case is normal? How should we ensure selected configuration values get refreshed after configuration change?

SDK version: 6.1.1

amerjusupovic commented 2 weeks ago

Hi @lissdy, by default the refresh interval should be 30 seconds if you haven't set it manually in ConfigureRefresh. I'm not able to reproduce this behavior after copying the quickstart locally with version 6.1.1 of Microsoft.Azure.AppConfiguration.AspNetCore. I selected multiple key-value collections as you did and set a few different sentinel key-values.

Here are some things I'd want to check from your end:

  1. Are you refreshing your application after at least one sentinel key-value and any selected key-values are updated in your store (you may need to refresh a couple times)?
  2. Have you made all calls to AddAzureAppConfiguration and UseAzureAppConfiguration in the order shown in the quickstart?
  3. If you can enable logging at the Debug level, can you check your logs to see which key-values are changing and if the sentinel key-value is logged as a change? The instructions for this can be found in the page you sent.
lissdy commented 5 days ago

Thanks @amerjusupovic for the reply. I have set the refresh interval as 300 seconds.

  1. If "shared:testService:sentinel" value changed, since I set RefreshAll as true, suppose all registered key-value collections shared:testService:, service:testService: and shared:config:* should be refreshed, right?
  2. Yes, followed the quickstart, and here is how I set sentinel key and register key

        private static AzureAppConfigurationOptions ConfigAacOptions(this AzureAppConfigurationOptions options, HashSet<string> sentinelKeys, HashSet<string> registerKeys, double cacheExpirationInSeconds)
        {
            options
                .ConfigureClientOptions(clientOptions =>
                {
                    clientOptions.Retry.MaxRetries = ConfigConstants.MaxRetries;
                })
                .ConfigureRefresh(refresh =>
                {
                    foreach (var i in sentinelKeys)
                    {
                        refresh.Register(key: i, refreshAll: true); // set sentinel key
                    }
    
                    refresh
                        .SetCacheExpiration(TimeSpan.FromSeconds(cacheExpirationInSeconds));
                });
            foreach (var i in registerKeys)
            {
                options.Select(i); // set register key
            }
            return options;
        }
  3. We can't enable the SDK log, but enabled diagnostic setting, found if "shared:testService:sentinel" value changed, the SDK only send request to refresh shared:config:*, other two key-value collections refresh is missed
amerjusupovic commented 3 days ago

You're right, if a key is registered with refreshAll set to true then all selected key-values should be refreshed. Is there any way you could try upgrading to the newest provider version, 7.3.0?

lissdy commented 1 day ago

Upgraded to the newest version 7.3.0, will try to reproduce the issue and let you know the update, thanks