Deadlock occurs for flag value fetching while using in memory or redis cache for flags
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu từ điểm đầu vào GetFeatureState và theo dõi OpenFeature.Api.Instance.GetClient("FsProvider") qua GetBooleanValueAsync, so sánh đường đi có và không có thao tác tra cứu và ghi vào featureCache. Kiểm tra cách đường đi caching trong bộ nhớ hoặc Redis tương tác với việc lấy flag bất đồng bộ. Hoàn tất khi lần lấy flag đầu tiên trả về và giá trị được lưu trong khoảng thời gian dự kiến là 30 phút.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- C#
- Star
- 20
- Fork
- 17
- Merge trung bình
- 21 giờ 47 phút
- Pull request đã merge (30 ngày)
- 8
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Flagsmith/flagsmith-dotnet-client
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Flagsmith/flagsmith-dotnet-client#197 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Dependency DashboardĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Flagsmith/flagsmith-dotnet-client#194 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
Flagsmith/flagsmith-dotnet-client#191 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
Flagsmith/flagsmith-dotnet-client#190 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Local evaluation silently drops identity overrides on large environmentsCó thể đã có người làm @marc-merino đã nhận 38 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Flagsmith/flagsmith-dotnet-client#187 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Flagsmith/flagsmith-dotnet-client
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NimblePros/eShopOnWeb#333 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Natvs/Nt.Automaton#33 ·
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Remove old asp.net core examplesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Add readme for the toolsĐang mởdocumentation
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày