Deadlock occurs for flag value fetching while using in memory or redis cache for flags
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 GetFeatureState 入口点开始,跟踪 OpenFeature.Api.Instance.GetClient("FsProvider") 经过 GetBooleanValueAsync 的调用路径,比较包含和不包含 featureCache 查找与写入的路径。检查内存中或 Redis 缓存路径如何与异步 flag 获取交互。完成标准是第一次 flag 获取返回,并且值按预期存储 30 分钟。
由索引模型根据 Issue 内容生成。
描述
How are you running Flagsmith
- Self Hosted with Docker
- Self Hosted with Kubernetes
- SaaS at flagsmith.com
- Some other way (add details in description below)
Describe the bug
I have added in memory or redis caching for flag values to control flagsmith API hits. But as soon as I add that the flag fetching for the first time becomes a never returning call and its like deadlock occurs.
Here is the code .
Do note that I am using the open feature sdk here for flagsmith provider.
Steps To Reproduce
// At the class level
private static readonly ConcurrentDictionary<string, (bool Value, DateTime Timestamp)> featureCache
= new ConcurrentDictionary<string, (bool Value, DateTime Timestamp)>();`
public static async Task<bool> GetFeatureState(string flagName, bool defaultValue, OpenFeature.Model.EvaluationContext context, string identity)
{
try
{
var CommonConfigValue = ConfigurationManager.AppSettings[flagName];
var flagStatus = false;
if (string.IsNullOrEmpty(CommonConfigValue) &&
AppSettings._OpenFeatureProviderName.ToLower() == ProviderEnum.FlagSmith.ToString().ToLower())
{
var cacheflagName = $"{identity}:{flagName}";
if (featureCache.TryGetValue(cacheflagName, out (bool Value, DateTime Timestamp) cachedEntry))
{
SystemLogger.WriteInformation($"Found cached value for {cacheflagName}");
// Use cached value only if timestamp is within 30 minutes
if ((DateTime.Now - cachedEntry.Timestamp).TotalMinutes < 30)
{
SystemLogger.WriteInformation($"Using cached value for {cacheflagName}");
return cachedEntry.Value;
}
}
// Retrieve the Flagsmith client from the Application state
var flagsmithClient = OpenFeature.Api.Instance.GetClient("FsProvider");
// Check the feature flag asynchronously
flagStatus = await flagsmithClient.GetBooleanValueAsync(flagName, defaultValue, context)
.ConfigureAwait(false);
// Store value with timestamp
featureCache[cacheflagName] = (flagStatus, DateTime.Now);
}
else
{
flagStatus = CommonConfigValue?.Trim().ToLower() == "true";
}
return flagStatus;
}
catch (Exception ex)
{
SystemLogger.WriteError($"Error checking feature state: {ex.Message}");
return false;
}
}
Expected behavior
Flag value must be returned and stored in cache for 30 min time
Screenshots
No response
- 主要语言
- C#
- 星标
- 20
- 派生
- 17
- 平均合并
- 21 小时 47 分钟
- 30 天内合并 PR
- 8
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Flagsmith/flagsmith-dotnet-client 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 55/100
Flagsmith/flagsmith-dotnet-client#197 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
Flagsmith/flagsmith-dotnet-client#194 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 52/100
Flagsmith/flagsmith-dotnet-client#191 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 58/100
Flagsmith/flagsmith-dotnet-client#190 · 1 条评论 ·
维护者通常 1 天内回复
-
Local evaluation silently drops identity overrides on large environments可能已有人在做 @marc-merino 于 38 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
Flagsmith/flagsmith-dotnet-client#187 ·
维护者通常 1 天内回复
查看 Flagsmith/flagsmith-dotnet-client 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
NimblePros/eShopOnWeb#333 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
Natvs/Nt.Automaton#33 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 62/100
-
documentation
难度 2/5 半天 新手友好度 65/100
维护者通常 1 天内回复