Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(flags): apply the persons db deadline to the group type lookup (#108772)

Phil Haackea2552bdf7a0
diff --git a/docs/internal/feature-flags/database-interaction-patterns.md b/docs/internal/feature-flags/database-interaction-patterns.md
index e92fe48e7758..f3e86d59f4c8 100644
--- a/docs/internal/feature-flags/database-interaction-patterns.md
+++ b/docs/internal/feature-flags/database-interaction-patterns.md
@@ -78,7 +78,7 @@ The same hook also increments the `db_connection_created_total` counter when `po
### Persons DB deadline
`PERSONS_DB_DEADLINE_MS` (default 2500ms) bounds all persons DB work in one flag evaluation.
-The hash key override check, write, and read, and the person, cohort, and group properties fetch share one deadline, so sequential calls cannot add up past it.
+The hash key override check, write, and read, the group type mapping lookup, and the person, cohort, and group properties fetch share one deadline, so sequential calls cannot add up past it.
The deadline starts when the matcher is built, just before evaluation.
Postgres `statement_timeout` cannot cancel a query on a database that has stopped answering, so once a query is in flight this client-side timer is the only bound.
When the pool has no free connection, the pool acquire timeout (`ACQUIRE_TIMEOUT_SECS`) can fire first, and the call fails with `timeout:pool_timeout` instead.
@@ -90,9 +90,16 @@ When the deadline passes, the call fails with `FlagError::TimeoutError("persons_
- The request returns a 200 with `errorsWhileComputingFlags: true`.
A call that would start after the deadline fails without taking a connection.
+The group type mapping cache runs its coalesced fetch in a separate task.
+A cache hit still succeeds after the deadline, each request stops waiting at its own deadline, and a request that stops waiting does not cancel the fetch for the others.
+The shared fetch has its own 5s cap instead of any request's deadline.
+Without the cap, a fetch stuck on an unreachable database keeps running.
+Every later request for the team then waits on that fetch instead of starting a new one.
+A slow group type lookup uses up the shared deadline, so the properties fetch after it can fail even when person queries are fast.
Each stopped call increments `flags_database_error_total` with `timeout_type="persons_db_deadline"` and the call's `operation`.
The canonical log line records the first stopped call in `persons_db_deadline_exceeded`.
The internal batch evaluation endpoint does not apply the deadline. When a person's evaluation returns an error, Django leaves that person out of the static cohort and still reports the run as a success.
+The batch endpoint shares the group type mapping cache with `/flags`, so its group type lookup still stops at the 5s shared fetch cap.
Set `PERSONS_DB_DEADLINE_MS=0` to disable the deadline.
A query that the deadline drops mid-flight keeps its connection until sqlx's on-release ping finishes.
diff --git a/rust/feature-flags/src/api/batch_flag_evaluation.rs b/rust/feature-flags/src/api/batch_flag_evaluation.rs
index 370f86b578b7..1432d8f60028 100644
--- a/rust/feature-flags/src/api/batch_flag_evaluation.rs
+++ b/rust/feature-flags/src/api/batch_flag_evaluation.rs
@@ -25,7 +25,9 @@
//! - The matcher runs without the persons DB deadline (`PERSONS_DB_DEADLINE_MS`). When a
//! person's evaluation returns an error, Django leaves that person out of the cohort and
//! still reports the run as a success. A slow persons query must therefore finish rather
-//! than time out.
+//! than time out. The group type mapping lookup is the exception. This endpoint shares
+//! `GroupTypeCacheManager` with live `/flags`, so that lookup still fails with
+//! `client_timeout` at the cache's 5s shared fetch cap.
//!
//! The paged scan walks `posthog_person.id` ascending across a live table, so the run sees
//! a moving snapshot rather than a point-in-time one: persons inserted above the current
diff --git a/rust/feature-flags/src/api/errors.rs b/rust/feature-flags/src/api/errors.rs
index ab236d170d67..944943704b89 100644
--- a/rust/feature-flags/src/api/errors.rs
+++ b/rust/feature-flags/src/api/errors.rs
@@ -140,6 +140,7 @@ pub(crate) const CODE_FLAG_DATA_PARSING: &str = "flag_data_parsing_error";
pub(crate) const CODE_PERSON_NOT_FOUND: &str = "person_not_found";
pub(crate) const CODE_DEPENDENCY_FAILED: &str = "dependency_failed";
+const TIMEOUT_CLIENT: &str = "client_timeout";
const TIMEOUT_PERSONS_DB_DEADLINE: &str = "persons_db_deadline";
impl FlagError {
@@ -204,6 +205,10 @@ impl FlagError {
}
}
+ pub fn client_timeout() -> Self {
+ FlagError::TimeoutError(Some(TIMEOUT_CLIENT.to_string()))
+ }
+
pub fn persons_db_deadline() -> Self {
FlagError::TimeoutError(Some(TIMEOUT_PERSONS_DB_DEADLINE.to_string()))
}
@@ -659,9 +664,7 @@ impl From<CustomRedisError> for FlagError {
impl From<CustomDatabaseError> for FlagError {
fn from(e: CustomDatabaseError) -> Self {
match e {
- CustomDatabaseError::Timeout(_) => {
- FlagError::TimeoutError(Some("client_timeout".to_string()))
- }
+ CustomDatabaseError::Timeout(_) => FlagError::client_timeout(),
CustomDatabaseError::Other(sqlx_error) => {
// Check if it's a timeout-related SQL error
if is_timeout_error(&sqlx_error) {
diff --git a/rust/feature-flags/src/config.rs b/rust/feature-flags/src/config.rs
index d88d6f0cc9b5..c43676e68df9 100644
--- a/rust/feature-flags/src/config.rs
+++ b/rust/feature-flags/src/config.rs
@@ -436,7 +436,7 @@ pub struct Config {
pub realtime_cohort_lookup_timeout_ms: u64,
// Deadline shared by all persons DB calls in one /flags evaluation: the hash key override
- // check, write, and read, and the properties fetch.
+ // check, write, and read, the group type mapping lookup, and the properties fetch.
// statement_timeout cannot cancel a query on a database that has stopped answering.
// Only this timer bounds the request then. On expiry, the flags that need persons data
// return an error and the other flags evaluate normally. The default leaves 2s of the
diff --git a/rust/feature-flags/src/flags/flag_group_type_mapping.rs b/rust/feature-flags/src/flags/flag_group_type_mapping.rs
index c0ba63cb28a6..f757465a5319 100644
--- a/rust/feature-flags/src/flags/flag_group_type_mapping.rs
+++ b/rust/feature-flags/src/flags/flag_group_type_mapping.rs
@@ -7,6 +7,7 @@ use common_database::PostgresReader;
use common_types::TeamId;
use moka::future::Cache;
use sqlx::FromRow;
+use tokio::time::Instant;
use tracing::error;
use crate::{
@@ -16,6 +17,7 @@ use crate::{
DB_GROUP_TYPE_ERRORS_COUNTER, DB_GROUP_TYPE_READS_COUNTER, GROUP_TYPE_CACHE_ENTRIES_GAUGE,
GROUP_TYPE_CACHE_HIT_COUNTER, GROUP_TYPE_CACHE_MISS_COUNTER,
},
+ utils::deadline::before_deadline,
};
pub type GroupTypeIndex = i32;
@@ -71,6 +73,7 @@ impl GroupTypeMapping {
pub enum GroupTypeFetchError {
DatabaseUnavailable,
QueryFailed(String),
+ Timeout,
}
impl From<GroupTypeFetchError> for FlagError {
@@ -78,6 +81,7 @@ impl From<GroupTypeFetchError> for FlagError {
match value {
GroupTypeFetchError::DatabaseUnavailable => FlagError::DatabaseUnavailable,
GroupTypeFetchError::QueryFailed(msg) => FlagError::internal(anyhow::anyhow!(msg)),
+ GroupTypeFetchError::Timeout => FlagError::client_timeout(),
}
}
}
@@ -136,6 +140,14 @@ pub struct GroupTypeCacheManager {
impl GroupTypeCacheManager {
const DEFAULT_MAX_ENTRIES: u64 = 50_000;
+ /// Caps the coalesced fetch, which runs in its own task. Without a cap, a query stuck on an
+ /// unreachable database keeps that task running. Every later request for the team then
+ /// waits on the stuck task instead of starting a new fetch. A /flags request stops waiting
+ /// before the cap fires, because the cap is above the 4.5s request timeout. The batch
+ /// endpoint shares this cache. It applies no persons deadline, so a batch caller that is
+ /// still waiting when the cap fires gets `client_timeout`.
+ const SHARED_FETCH_TIMEOUT: Duration = Duration::from_secs(5);
+
pub fn new(reader: PostgresReader, max_entries: Option<u64>, ttl_seconds: Option<u64>) -> Self {
let fetcher = PostgresGroupTypeMappingFetcher::new(reader);
Self::new_with_fetcher(fetcher, max_entries, ttl_seconds)
@@ -157,45 +169,62 @@ impl GroupTypeCacheManager {
}
}
+ async fn capped_fetch(
+ fetcher: Arc<dyn GroupTypeMappingFetcher>,
+ team_id: TeamId,
+ ) -> Result<GroupTypeMapping, GroupTypeFetchError> {
+ let result = tokio::time::timeout(Self::SHARED_FETCH_TIMEOUT, fetcher.fetch(team_id))
+ .await
+ .unwrap_or(Err(GroupTypeFetchError::Timeout));
+ match &result {
+ Ok(_) => common_metrics::inc(DB_GROUP_TYPE_READS_COUNTER, &[], 1),
+ Err(e) => {
+ common_metrics::inc(DB_GROUP_TYPE_ERRORS_COUNTER, &[], 1);
+ error!(team_id = team_id, error = ?e, "Failed to fetch group type mappings");
+ }
+ }
+ result
+ }
+
/// Retrieves group type mappings for a given team.
///
/// Uses moka's `try_get_with` for per-key coalescing:
/// - If cached: returns immediately (cache hit)
/// - If not cached: only one caller fetches from DB, others wait for the result
/// - Different teams fetch in parallel (no cross-team blocking)
- pub async fn get_mappings(&self, team_id: TeamId) -> Result<GroupTypeMapping, FlagError> {
- let was_cached = self.cache.contains_key(&team_id);
- let fetcher = self.fetcher.clone();
+ ///
+ /// `deadline` bounds this caller's wait, not a cache hit or the shared fetch. A caller gets
+ /// the shared fetch's result, or its own deadline error if its deadline passes first.
+ pub async fn get_mappings(
+ &self,
+ team_id: TeamId,
+ deadline: Option<Instant>,
+ ) -> Result<GroupTypeMapping, FlagError> {
+ if let Some(mapping) = self.cache.get(&team_id).await {
+ common_metrics::inc(GROUP_TYPE_CACHE_HIT_COUNTER, &[], 1);
+ self.report_cache_metrics();
+ return Ok(mapping);
+ }
+ // NB: Under coalescing, concurrent cold-key callers all count as misses.
+ // This only happens on cold start / TTL expiry and is acceptable.
+ common_metrics::inc(GROUP_TYPE_CACHE_MISS_COUNTER, &[], 1);
- let result = self
- .cache
- .try_get_with(team_id, async move {
- match fetcher.fetch(team_id).await {
- Ok(mapping) => {
- common_metrics::inc(DB_GROUP_TYPE_READS_COUNTER, &[], 1);
- Ok(mapping)
- }
- Err(e) => {
- common_metrics::inc(DB_GROUP_TYPE_ERRORS_COUNTER, &[], 1);
- error!(
- team_id = team_id,
- error = ?e,
- "Failed to fetch group type mappings"
- );
- Err(e)
- }
- }
+ let cache = self.cache.clone();
+ let fetcher = self.fetcher.clone();
+ // The coalesced fetch runs in its own task, so a caller that stops waiting does not
+ // cancel the fetch that other callers wait on. moka panics after a waiter sees 200
+ // cancelled fetches.
+ let shared_fetch = async move {
+ tokio::spawn(async move {
+ cache
+ .try_get_with(team_id, Self::capped_fetch(fetcher, team_id))
+ .await
})
.await
- .map_err(|arc_err| FlagError::from((*arc_err).clone()));
-
- // NB: Under coalescing, concurrent cold-key callers all see was_cached=false,
- // inflating misses. This only happens on cold start / TTL expiry and is acceptable.
- if was_cached {
- common_metrics::inc(GROUP_TYPE_CACHE_HIT_COUNTER, &[], 1);
- } else {
- common_metrics::inc(GROUP_TYPE_CACHE_MISS_COUNTER, &[], 1);
- }
+ .map_err(FlagError::internal)?
+ .map_err(|arc_err| FlagError::from((*arc_err).clone()))
+ };
+ let result = before_deadline(deadline, shared_fetch, FlagError::persons_db_deadline).await;
self.report_cache_metrics();
@@ -305,6 +334,15 @@ mod tests {
}
}
+ fn spawn_get_mappings(
+ cache: &GroupTypeCacheManager,
+ team_id: TeamId,
+ deadline: Option<Instant>,
+ ) -> tokio::task::JoinHandle<Result<GroupTypeMapping, FlagError>> {
+ let cache = cache.clone();
+ tokio::spawn(async move { cache.get_mappings(team_id, deadline).await })
+ }
+
fn test_mapping() -> HashMap<String, GroupTypeIndex> {
[("project".to_string(), 0), ("organization".to_string(), 1)]
.into_iter()
@@ -320,12 +358,12 @@ mod tests {
let cache = GroupTypeCacheManager::new_with_fetcher(fetcher, None, None);
// First request - cache miss
- let result1 = cache.get_mappings(TEAM_ID).await;
+ let result1 = cache.get_mappings(TEAM_ID, None).await;
assert!(result1.is_ok());
assert_eq!(fetch_count.load(Ordering::SeqCst), 1);
// Second request - cache hit
- let result2 = cache.get_mappings(TEAM_ID).await;
+ let result2 = cache.get_mappings(TEAM_ID, None).await;
assert!(result2.is_ok());
assert_eq!(fetch_count.load(Ordering::SeqCst), 1);
@@ -336,6 +374,15 @@ mod tests {
m1.group_types_to_indexes().len(),
m2.group_types_to_indexes().len()
);
+
+ // A request that spent its persons deadline on earlier queries still gets a cache hit
+ let expired_deadline = Some(Instant::now());
+ let result3 = cache.get_mappings(TEAM_ID, expired_deadline).await;
+ assert_eq!(
+ result3.unwrap().group_types_to_indexes(),
+ m1.group_types_to_indexes()
+ );
+ assert_eq!(fetch_count.load(Ordering::SeqCst), 1);
}
#[tokio::test]
@@ -346,7 +393,7 @@ mod tests {
let fetcher = MockGroupTypeFetcher::new(test_mapping(), fetch_count.clone());
let cache = GroupTypeCacheManager::new_with_fetcher(fetcher, None, Some(1));
- let result = cache.get_mappings(TEAM_ID).await;
+ let result = cache.get_mappings(TEAM_ID, None).await;
assert!(result.is_ok());
assert_eq!(fetch_count.load(Ordering::SeqCst), 1);
@@ -358,7 +405,7 @@ mod tests {
assert!(cached.is_none(), "Cache entry should have expired");
// Next request should fetch again
- let result2 = cache.get_mappings(TEAM_ID).await;
+ let result2 = cache.get_mappings(TEAM_ID, None).await;
assert!(result2.is_ok());
assert_eq!(fetch_count.load(Ordering::SeqCst), 2);
}
@@ -384,7 +431,7 @@ mod tests {
let handles: Vec<_> = (0..NUM_CONCURRENT_REQUESTS)
.map(|_| {
let cache = cache.clone();
- tokio::spawn(async move { cache.get_mappings(TEAM_ID).await })
+ tokio::spawn(async move { cache.get_mappings(TEAM_ID, None).await })
})
.collect();
@@ -415,6 +462,75 @@ mod tests {
);
}
+ #[tokio::test(start_paused = true)]
+ async fn test_caller_deadline_ends_only_its_own_wait() {
+ const TEAM_ID: TeamId = 42;
+
+ let fetch_count = Arc::new(AtomicU32::new(0));
+ let fetch_started = Arc::new(tokio::sync::Notify::new());
+ let may_complete = Arc::new(tokio::sync::Notify::new());
+ let fetcher = CoalescingTestFetcher::new(
+ GroupTypeMapping::new(test_mapping()),
+ fetch_count.clone(),
+ Arc::clone(&fetch_started),
+ Arc::clone(&may_complete),
+ );
+ let cache = GroupTypeCacheManager::new_with_fetcher(fetcher, None, None);
+ let start = Instant::now();
+ let early_deadline = Some(start + Duration::from_millis(500));
+ let late_deadline = Some(start + Duration::from_secs(3));
+
+ let early_caller = spawn_get_mappings(&cache, TEAM_ID, early_deadline);
+ fetch_started.notified().await;
+ let dropped_caller = spawn_get_mappings(&cache, TEAM_ID, late_deadline);
+
+ let early_result = tokio::time::timeout(Duration::from_secs(60), early_caller)
+ .await
+ .expect("a caller must stop waiting at its own deadline")
+ .unwrap();
+ assert!(early_result.unwrap_err().is_persons_db_deadline());
+
+ // A dropped request drops its caller future, and the shared fetch must outlive it.
+ dropped_caller.abort();
+ let late_caller = spawn_get_mappings(&cache, TEAM_ID, late_deadline);
+ tokio::time::sleep(Duration::from_secs(1)).await;
+ may_complete.notify_one();
+
+ assert!(late_caller.await.unwrap().is_ok());
+ assert_eq!(fetch_count.load(Ordering::SeqCst), 1);
+ }
+
+ #[tokio::test(start_paused = true)]
+ async fn test_shared_fetch_cap_ends_a_fetch_that_never_completes() {
+ const TEAM_ID: TeamId = 42;
+
+ let fetch_count = Arc::new(AtomicU32::new(0));
+ let fetch_started = Arc::new(tokio::sync::Notify::new());
+ let fetcher = CoalescingTestFetcher::new(
+ GroupTypeMapping::new(test_mapping()),
+ fetch_count.clone(),
+ Arc::clone(&fetch_started),
+ Arc::new(tokio::sync::Notify::new()),
+ );
+ let cache = GroupTypeCacheManager::new_with_fetcher(fetcher, None, None);
+
+ let first_caller = spawn_get_mappings(&cache, TEAM_ID, None);
+ fetch_started.notified().await;
+ let err = tokio::time::timeout(Duration::from_secs(60), first_caller)
+ .await
+ .expect("the shared fetch cap must end a fetch that never completes")
+ .unwrap()
+ .unwrap_err();
+ assert!(matches!(err, FlagError::TimeoutError(Some(ref t)) if t == "client_timeout"));
+
+ let next_caller = spawn_get_mappings(&cache, TEAM_ID, None);
+ tokio::time::timeout(Duration::from_secs(60), fetch_started.notified())
+ .await
+ .expect("a timed-out fetch must not stay cached, so the next caller fetches again");
+ next_caller.abort();
+ assert_eq!(fetch_count.load(Ordering::SeqCst), 2);
+ }
+
#[tokio::test]
async fn test_cross_team_parallelism() {
const NUM_TEAMS: usize = 5;
@@ -429,7 +545,7 @@ mod tests {
.map(|i| {
let cache = cache.clone();
let team_id = (i + 1) as TeamId;
- tokio::spawn(async move { cache.get_mappings(team_id).await })
+ tokio::spawn(async move { cache.get_mappings(team_id, None).await })
})
.collect();
@@ -482,18 +598,18 @@ mod tests {
let cache = GroupTypeCacheManager::new_with_fetcher(fetcher, None, None);
- let result1 = cache.get_mappings(TEAM_ID).await;
+ let result1 = cache.get_mappings(TEAM_ID, None).await;
assert!(result1.is_err());
assert_eq!(fetch_count.load(Ordering::SeqCst), 1);
should_fail.store(false, Ordering::SeqCst);
- let result2 = cache.get_mappings(TEAM_ID).await;
+ let result2 = cache.get_mappings(TEAM_ID, None).await;
assert!(result2.is_ok());
assert_eq!(fetch_count.load(Ordering::SeqCst), 2);
// Third request should hit cache
- let result3 = cache.get_mappings(TEAM_ID).await;
+ let result3 = cache.get_mappings(TEAM_ID, None).await;
assert!(result3.is_ok());
assert_eq!(fetch_count.load(Ordering::SeqCst), 2);
}
@@ -507,14 +623,14 @@ mod tests {
let cache = GroupTypeCacheManager::new_with_fetcher(fetcher, None, None);
// Empty mappings should be cached successfully (not treated as an error)
- let result = cache.get_mappings(TEAM_ID).await;
+ let result = cache.get_mappings(TEAM_ID, None).await;
assert!(result.is_ok());
let mapping = result.unwrap();
assert!(mapping.is_empty());
assert_eq!(fetch_count.load(Ordering::SeqCst), 1);
// Second request should hit cache (empty mapping was cached)
- let result2 = cache.get_mappings(TEAM_ID).await;
+ let result2 = cache.get_mappings(TEAM_ID, None).await;
assert!(result2.is_ok());
assert_eq!(fetch_count.load(Ordering::SeqCst), 1);
}
diff --git a/rust/feature-flags/src/flags/flag_matching.rs b/rust/feature-flags/src/flags/flag_matching.rs
index d20c4308c502..47e644c1f4cd 100644
--- a/rust/feature-flags/src/flags/flag_matching.rs
+++ b/rust/feature-flags/src/flags/flag_matching.rs
@@ -3163,7 +3163,14 @@ impl FeatureFlagMatcher {
let group_type_mapping_timer = common_metrics::timing_guard(FLAG_GROUP_DB_FETCH_TIME, &[]);
let mut errors_while_computing_flags = false;
- match self.group_type_cache.get_mappings(self.team_id).await {
+ // The cache applies the deadline itself, so that this request's deadline cannot cancel
+ // the fetch that other requests for the team wait on.
+ let mappings = self
+ .group_type_cache
+ .get_mappings(self.team_id, self.persons_db_deadline)
+ .await;
+ record_persons_db_deadline_exceeded(db_operations::FETCH_GROUP_TYPE_MAPPING, &mappings);
+ match mappings {
Ok(mapping) => {
if mapping.is_empty() {
// Empty mappings are not an error — the team simply has no group types
diff --git a/rust/feature-flags/src/flags/flag_matching_utils.rs b/rust/feature-flags/src/flags/flag_matching_utils.rs
index 5baa968ce61e..811187407ace 100644
--- a/rust/feature-flags/src/flags/flag_matching_utils.rs
+++ b/rust/feature-flags/src/flags/flag_matching_utils.rs
@@ -760,6 +760,7 @@ pub(crate) mod db_operations {
pub const SET_HASH_KEY_OVERRIDES: &str = "set_hash_key_overrides";
pub const GET_HASH_KEY_OVERRIDES: &str = "get_hash_key_overrides";
pub const FETCH_PROPERTIES: &str = "fetch_properties";
+ pub const FETCH_GROUP_TYPE_MAPPING: &str = "fetch_group_type_mapping";
}
/// Records `flags_hash_key_retries_total` and the `retried` label on `flags_database_error_total`
diff --git a/rust/feature-flags/src/flags/test_flag_matching.rs b/rust/feature-flags/src/flags/test_flag_matching.rs
index 8453fbcb9fc7..8c2430f8d17d 100644
--- a/rust/feature-flags/src/flags/test_flag_matching.rs
+++ b/rust/feature-flags/src/flags/test_flag_matching.rs
@@ -8171,10 +8171,12 @@ mod tests {
// Paused time makes the elapsed assertion exact: the runtime jumps straight to each timer.
#[rstest::rstest]
- #[case::hash_key_read(None, "get_hash_key_overrides")]
- #[case::hash_key_check(Some("anon_distinct_id"), "should_write_hash_key_override")]
+ #[case::hash_key_read(true, None, "get_hash_key_overrides")]
+ #[case::hash_key_check(true, Some("anon_distinct_id"), "should_write_hash_key_override")]
+ #[case::group_type_lookup(false, None, "fetch_group_type_mapping")]
#[tokio::test(start_paused = true)]
async fn test_stalled_persons_db_degrades_within_one_deadline(
+ #[case] with_continuity_flag: bool,
#[case] anon_distinct_id: Option<&str>,
#[case] first_stopped_call: &str,
) {
@@ -8216,7 +8218,16 @@ mod tests {
key: "continuity_flag".mock_into(),
ensure_experience_continuity: Some(true)
);
- let mut flags = flag_list_with_metadata(vec![rollout_flag, person_flag, continuity_flag]);
+ let group_flag = mock!(FeatureFlag,
+ id: 4,
+ key: "group_flag".mock_into(),
+ filters: mock!(FlagFilters, aggregation_group_type_index: Some(0))
+ );
+ let mut flag_list = vec![rollout_flag, person_flag, group_flag];
+ if with_continuity_flag {
+ flag_list.push(continuity_flag);
+ }
+ let mut flags = flag_list_with_metadata(flag_list);
// Preloaded cohorts keep the cohort definitions lookup off the stalled pool.
flags.cohorts = Some(Arc::from(Vec::new()));
@@ -8252,12 +8263,15 @@ mod tests {
"timeout:persons_db_deadline"
);
assert_eq!(
- response.flags["continuity_flag"].reason.code,
- "hash_key_override_error"
+ response
+ .flags
+ .get("continuity_flag")
+ .map(|flag| flag.reason.code.as_str()),
+ with_continuity_flag.then_some("hash_key_override_error")
);
assert!(
elapsed < deadline * 2,
- "the hash key lookup and the properties fetch share one deadline, took {elapsed:?}"
+ "the hash key lookup, the group type lookup, and the properties fetch share one deadline, took {elapsed:?}"
);
assert_eq!(
stalled_db.connection_requests.load(Ordering::SeqCst),