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(personhog): resolve identity only in the identity service (#99568)

Nick Bestfd844df0f0ca
diff --git a/rust/personhog-identity/src/storage/mod.rs b/rust/personhog-identity/src/storage/mod.rs
index e7fef7b5d34b..fb0d0bb2b63a 100644
--- a/rust/personhog-identity/src/storage/mod.rs
+++ b/rust/personhog-identity/src/storage/mod.rs
@@ -18,6 +18,7 @@ pub const DB_QUERY_DURATION: &str = "personhog_identity_db_query_duration_ms";
pub trait IdentityStorage: Send + Sync {
/// Batch-resolve (team_id, distinct_id) keys to persons on the primary.
/// Returns a map keyed by (team_id, distinct_id); unresolved keys are absent.
+ /// Persons carry identity only (no properties): the leader owns those.
async fn resolve_distinct_ids(
&self,
keys: &[(i64, String)],
diff --git a/rust/personhog-identity/src/storage/postgres/mod.rs b/rust/personhog-identity/src/storage/postgres/mod.rs
index 37ddd126050b..4e61dd01185c 100644
--- a/rust/personhog-identity/src/storage/postgres/mod.rs
+++ b/rust/personhog-identity/src/storage/postgres/mod.rs
@@ -57,18 +57,22 @@ pub(crate) async fn begin_timed(pool: &PgPool) -> sqlx::Result<Transaction<'_, P
}
/// Decode a person from a row whose SELECT list uses the canonical aliases
-/// (`team_id::bigint AS team_id`, `properties::text AS properties`, the
-/// `is_user_id` boolean CASE, …). Shared by every submodule that selects
-/// person rows — the table name is interpolated at runtime, so the queries
-/// cannot use the compile-time sqlx macros and their generated row types.
+/// (`team_id::bigint AS team_id`, the `is_user_id` boolean CASE, …). Shared
+/// by every submodule that selects person rows — the table name is
+/// interpolated at runtime, so the queries cannot use the compile-time sqlx
+/// macros and their generated row types.
+///
+/// Properties are never read. The identity service resolves identity only;
+/// the partition leader owns person properties, and a primary-sourced copy
+/// would lag it by writer apply lag.
pub(super) fn person_from_row(row: &PgRow) -> Result<Person, sqlx::Error> {
Ok(Person {
id: row.try_get("id")?,
uuid: row.try_get("uuid")?,
team_id: row.try_get("team_id")?,
- properties: row.try_get("properties")?,
- properties_last_updated_at: row.try_get("properties_last_updated_at")?,
- properties_last_operation: row.try_get("properties_last_operation")?,
+ properties: None,
+ properties_last_updated_at: None,
+ properties_last_operation: None,
created_at: row.try_get("created_at")?,
version: row.try_get("version")?,
is_identified: row.try_get("is_identified")?,
@@ -82,9 +86,6 @@ pub(super) fn person_from_row(row: &PgRow) -> Result<Person, sqlx::Error> {
pub(super) fn person_columns(p: &str) -> String {
format!(
"{p}.id, {p}.uuid, {p}.team_id::bigint AS team_id, \
- {p}.properties::text AS properties, \
- {p}.properties_last_updated_at::text AS properties_last_updated_at, \
- {p}.properties_last_operation::text AS properties_last_operation, \
{p}.created_at, {p}.version, {p}.is_identified, \
CASE WHEN {p}.is_user_id IS NULL THEN NULL ELSE ({p}.is_user_id != 0) END AS is_user_id, \
{p}.last_seen_at"
diff --git a/rust/personhog-identity/tests/storage_tests.rs b/rust/personhog-identity/tests/storage_tests.rs
index b008320ccc06..7d1364b4d0b4 100644
--- a/rust/personhog-identity/tests/storage_tests.rs
+++ b/rust/personhog-identity/tests/storage_tests.rs
@@ -152,7 +152,10 @@ async fn creates_stub_with_deterministic_uuid_and_version_zero() {
assert!(created);
assert_eq!(person.uuid, person_uuid(ctx.team_id, "user-1"));
assert_eq!(person.version, Some(0));
- assert_eq!(person.properties.as_deref(), Some("{}"));
+ assert!(
+ person.properties.is_none(),
+ "identity never reads properties; the leader owns them"
+ );
assert!(!person.is_identified);
assert_eq!(
person.created_at,
@@ -553,7 +556,6 @@ async fn deleted_person_is_revived_above_the_tombstone_on_recreate() {
assert!(created, "a revival is a creation to the caller");
assert_eq!(person.id, person_id, "revival keeps the row, not a new one");
assert_eq!(person.version, Some(8), "revived above the tombstone");
- assert_eq!(person.properties.as_deref(), Some("{}"));
assert_eq!(
ctx.distinct_id_state("revive-me").await,
Some((person_id, false, Some(4))),