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.

feat(personhog): add DeleteTombstonedPersons RPC (#97994)

Eli Reisman271aa7e69dc8
diff --git a/.agents/skills/adding-personhog-rpc/SKILL.md b/.agents/skills/adding-personhog-rpc/SKILL.md
index b4a382d7e816..ac9c252fbb54 100644
--- a/.agents/skills/adding-personhog-rpc/SKILL.md
+++ b/.agents/skills/adding-personhog-rpc/SKILL.md
@@ -130,14 +130,12 @@ The compiler guides you — once the proto is defined, `cargo build` errors tell
### 3c. Router wiring (personhog-router)
-1. **Add the method** to `rust/personhog-router/src/router/mod.rs`
- - Use the `route_request` function (imported from `routing.rs`) with the correct `DataCategory` and `OperationType`
- - Call the replica (or leader) backend
- - Use the `call_backend!` macro for instrumentation
-2. **Add the service impl** to `rust/personhog-router/src/service/mod.rs`
- - Invoke the `route_request!` macro (defined at the top of this file) to delegate to the router
-3. **Add to the backend trait** in `rust/personhog-router/src/backend/mod.rs` and implement in `replica.rs`
-4. **Add router tests** in `rust/personhog-router/tests/`
+The router forwards request bytes without decoding them, so a new RPC needs no handler there.
+
+1. **Add the method name** to `KNOWN_METHODS` in `rust/personhog-router/src/proxy.rs`, keeping the list sorted
+ - Methods that must reach the leader are matched by name in `proxy.rs`; everything else forwards to a replica
+ - `known_methods_is_sorted` and `known_methods_matches_service_proto` in the same file fail until the list matches `service.proto`
+2. **Add the method** to every `PersonHogService` mock that implements the generated trait, including the ones outside personhog (`rust/personhog-router/tests/common/mod.rs`, `rust/property-defs-rs/tests/`); tonic traits have no default methods
Use `rstest` parameterized tests where multiple variations of the same behavior are being tested.
diff --git a/nodejs/src/common/generated/personhog/personhog/service/v1/service_pb.ts b/nodejs/src/common/generated/personhog/personhog/service/v1/service_pb.ts
index abfb0711a8db..abe79fbf24f1 100644
--- a/nodejs/src/common/generated/personhog/personhog/service/v1/service_pb.ts
+++ b/nodejs/src/common/generated/personhog/personhog/service/v1/service_pb.ts
@@ -65,6 +65,8 @@ import type {
DeletePersonsBatchForTeamResponseSchema,
DeletePersonsRequestSchema,
DeletePersonsResponseSchema,
+ DeleteTombstonedPersonsRequestSchema,
+ DeleteTombstonedPersonsResponseSchema,
FencePersonRequestSchema,
FencePersonResponseSchema,
FencePersonsRequestSchema,
@@ -107,7 +109,7 @@ import { file_personhog_types_v1_person } from '../../types/v1/person_pb'
export const file_personhog_service_v1_service: GenFile =
/*@__PURE__*/
fileDesc(
- 'CiJwZXJzb25ob2cvc2VydmljZS92MS9zZXJ2aWNlLnByb3RvEhRwZXJzb25ob2cuc2VydmljZS52MTLXKgoQUGVyc29uSG9nU2VydmljZRJYCglHZXRQZXJzb24SJC5wZXJzb25ob2cudHlwZXMudjEuR2V0UGVyc29uUmVxdWVzdBolLnBlcnNvbmhvZy50eXBlcy52MS5HZXRQZXJzb25SZXNwb25zZRJYCgpHZXRQZXJzb25zEiUucGVyc29uaG9nLnR5cGVzLnYxLkdldFBlcnNvbnNSZXF1ZXN0GiMucGVyc29uaG9nLnR5cGVzLnYxLlBlcnNvbnNSZXNwb25zZRJkCg9HZXRQZXJzb25CeVV1aWQSKi5wZXJzb25ob2cudHlwZXMudjEuR2V0UGVyc29uQnlVdWlkUmVxdWVzdBolLnBlcnNvbmhvZy50eXBlcy52MS5HZXRQZXJzb25SZXNwb25zZRJmChFHZXRQZXJzb25zQnlVdWlkcxIsLnBlcnNvbmhvZy50eXBlcy52MS5HZXRQZXJzb25zQnlVdWlkc1JlcXVlc3QaIy5wZXJzb25ob2cudHlwZXMudjEuUGVyc29uc1Jlc3BvbnNlEnAKFUdldFBlcnNvbkJ5RGlzdGluY3RJZBIwLnBlcnNvbmhvZy50eXBlcy52MS5HZXRQZXJzb25CeURpc3RpbmN0SWRSZXF1ZXN0GiUucGVyc29uaG9nLnR5cGVzLnYxLkdldFBlcnNvblJlc3BvbnNlEpE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oVU2V0UGVyc29uVmVyc2lvbkZsb29yEjAucGVyc29uaG9nLnR5cGVzLnYxLlNldFBlcnNvblZlcnNpb25GbG9vclJlcXVlc3QaMS5wZXJzb25ob2cudHlwZXMudjEuU2V0UGVyc29uVmVyc2lvbkZsb29yUmVzcG9uc2ViBnByb3RvMw',
[
file_personhog_types_v1_person,
file_personhog_types_v1_group,
@@ -469,6 +471,9 @@ export const PersonHogService: GenService<{
}
/**
* Person deletes
+ * DeletePersons removes the persons in any state. A caller working from an advisory
+ * list of tombstoned persons must use DeleteTombstonedPersons instead, which re-checks
+ * the tombstone under the row lock.
* WARNING: This is a write operation on person data. It should route to the leader
* once personhog-leader supports deletes. Currently routed through the replica
* (which uses the primary Postgres pool) as a temporary measure.
@@ -491,6 +496,18 @@ export const PersonHogService: GenService<{
input: typeof DeletePersonsBatchForTeamRequestSchema
output: typeof DeletePersonsBatchForTeamResponseSchema
}
+ /**
+ * Deletes only persons that are still tombstoned when the delete runs, a bounded
+ * number of rows per call; pending uuids are sent again by the caller.
+ * WARNING: Same routing caveat as DeletePersons above.
+ *
+ * @generated from rpc personhog.service.v1.PersonHogService.DeleteTombstonedPersons
+ */
+ deleteTombstonedPersons: {
+ methodKind: 'unary'
+ input: typeof DeleteTombstonedPersonsRequestSchema
+ output: typeof DeleteTombstonedPersonsResponseSchema
+ }
/**
* Person split
* WARNING: Same routing caveat as DeletePersons above — write operation on person data
diff --git a/nodejs/src/common/generated/personhog/personhog/types/v1/person_pb.ts b/nodejs/src/common/generated/personhog/personhog/types/v1/person_pb.ts
index accc392d47ca..7e87f118f15f 100644
--- a/nodejs/src/common/generated/personhog/personhog/types/v1/person_pb.ts
+++ b/nodejs/src/common/generated/personhog/personhog/types/v1/person_pb.ts
@@ -13,7 +13,7 @@ import { file_personhog_types_v1_common } from './common_pb'
export const file_personhog_types_v1_person: GenFile =
/*@__PURE__*/
fileDesc(
- 'Ch9wZXJzb25ob2cvdHlwZXMvdjEvcGVyc29uLnByb3RvEhJw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KY3JlYXRlZF9hdBgEIAEoA0IRCg9fc2VhbGVkX3ZlcnNpb24iFwoVUmVsZWFzZUZlbmNlc1Jlc3BvbnNlIlMKFFNlYWxlZFNvdXJjZVNuYXBzaG90EioKBnBlcnNvbhgBIAEoCzIaLnBlcnNvbmhvZy50eXBlcy52MS5QZXJzb24SDwoHb3JkaW5hbBgCIAEoBSK9AQoZRm9sZFBlcnNvbkRvY3VtZW50UmVxdWVzdBIPCgd0ZWFtX2lkGAEgASgDEhEKCXBlcnNvbl9pZBgCIAEoAxJCChBzZWFsZWRfc25hcHNob3RzGAMgAygLMigucGVyc29uaG9nLnR5cGVzLnYxLlNlYWxlZFNvdXJjZVNuYXBzaG90EhEKCWV2ZW50X3NldBgEIAEoDBIWCg5ldmVudF9zZXRfb25jZRgFIAEoDBINCgVvcF9pZBgGIAEoCSJIChpGb2xkUGVyc29uRG9jdW1lbnRSZXNwb25zZRIqCgZwZXJzb24YASABKAsyGi5wZXJzb25ob2cudHlwZXMudjEuUGVyc29uKm8KD0xpZmVjeWNsZU9wVHlwZRIhCh1MSUZFQ1lDTEVfT1BfVFlQRV9VTlNQRUNJRklFRBAAEhwKGExJRkVDWUNMRV9PUF9UWVBFX0RFTEVURRABEhsKF0xJRkVDWUNMRV9PUF9UWVBFX01FUkdFEAIqbQoOUmVsZWFzZU91dGNvbWUSHwobUkVMRUFTRV9PVVRDT01FX1VOU1BFQ0lGSUVEEAASHQoZUkVMRUFTRV9PVVRDT01FX0NPTU1JVFRFRBABEhsKF1JFTEVBU0VfT1VUQ09NRV9BQk9SVEVEEAJiBnByb3RvMw',
[file_personhog_types_v1_common]
)
@@ -803,6 +803,99 @@ export const DeletePersonsBatchForTeamResponseSchema: GenMessage<DeletePersonsBa
/*@__PURE__*/
messageDesc(file_personhog_types_v1_person, 25)
+/**
+ * DeleteTombstonedPersonsRequest deletes persons only while they are still
+ * tombstoned, checking under the same row locks as the delete, so a racing
+ * revival is either skipped or lands afterwards on a fresh row. One call does a
+ * bounded amount of work: persons whose dependent rows (distinct ids, hash key
+ * overrides, cohort memberships) fit the row budget are deleted whole; the first
+ * person that does not fit gives up as many rows as the leftover allows and is
+ * returned as pending, as is everything after the budget. Send pending uuids again
+ * until none come back. Idempotent.
+ *
+ * @generated from message personhog.types.v1.DeleteTombstonedPersonsRequest
+ */
+export type DeleteTombstonedPersonsRequest = Message<'personhog.types.v1.DeleteTombstonedPersonsRequest'> & {
+ /**
+ * @generated from field: int64 team_id = 1;
+ */
+ teamId: bigint
+
+ /**
+ * Person UUIDs to delete. Max 1000 per request.
+ *
+ * @generated from field: repeated string person_uuids = 2;
+ */
+ personUuids: string[]
+
+ /**
+ * Dependent rows this call may delete. 0 means the server default; the server
+ * clamps the value to its own maximum (replica setting TOMBSTONED_DELETE_MAX_ROWS).
+ *
+ * @generated from field: int64 max_rows = 3;
+ */
+ maxRows: bigint
+}
+
+/**
+ * Describes the message personhog.types.v1.DeleteTombstonedPersonsRequest.
+ * Use `create(DeleteTombstonedPersonsRequestSchema)` to create a new message.
+ */
+export const DeleteTombstonedPersonsRequestSchema: GenMessage<DeleteTombstonedPersonsRequest> =
+ /*@__PURE__*/
+ messageDesc(file_personhog_types_v1_person, 26)
+
+/**
+ * @generated from message personhog.types.v1.DeleteTombstonedPersonsResponse
+ */
+export type DeleteTombstonedPersonsResponse = Message<'personhog.types.v1.DeleteTombstonedPersonsResponse'> & {
+ /**
+ * Persons hard-deleted together with their dependent rows.
+ *
+ * @generated from field: int64 deleted_count = 1;
+ */
+ deletedCount: bigint
+
+ /**
+ * Persons found with is_deleted = false: revived after the caller queued them.
+ * Nothing was deleted for them.
+ *
+ * @generated from field: int64 skipped_live_count = 2;
+ */
+ skippedLiveCount: bigint
+
+ /**
+ * Persons still tombstoned but referenced by a live distinct id. Nothing was
+ * deleted for them; the caller must not treat them as cleaned.
+ *
+ * @generated from field: repeated string blocked_person_uuids = 3;
+ */
+ blockedPersonUuids: string[]
+
+ /**
+ * Persons not finished within max_rows: still tombstoned, some rows possibly
+ * gone. Send them again.
+ *
+ * @generated from field: repeated string pending_person_uuids = 4;
+ */
+ pendingPersonUuids: string[]
+
+ /**
+ * Dependent rows deleted by this call.
+ *
+ * @generated from field: int64 rows_deleted = 5;
+ */
+ rowsDeleted: bigint
+}
+
+/**
+ * Describes the message personhog.types.v1.DeleteTombstonedPersonsResponse.
+ * Use `create(DeleteTombstonedPersonsResponseSchema)` to create a new message.
+ */
+export const DeleteTombstonedPersonsResponseSchema: GenMessage<DeleteTombstonedPersonsResponse> =
+ /*@__PURE__*/
+ messageDesc(file_personhog_types_v1_person, 27)
+
/**
* SplitPersonRequest splits specific distinct_ids off of a person onto new persons.
* Each distinct_id gets a new person with a deterministic UUID (UUIDv5 from team_id:distinct_id).
@@ -839,7 +932,7 @@ export type SplitPersonRequest = Message<'personhog.types.v1.SplitPersonRequest'
*/
export const SplitPersonRequestSchema: GenMessage<SplitPersonRequest> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 26)
+ messageDesc(file_personhog_types_v1_person, 28)
/**
* SplitResult describes a single distinct_id that was split onto a new person.
@@ -881,7 +974,7 @@ export type SplitResult = Message<'personhog.types.v1.SplitResult'> & {
* Describes the message personhog.types.v1.SplitResult.
* Use `create(SplitResultSchema)` to create a new message.
*/
-export const SplitResultSchema: GenMessage<SplitResult> = /*@__PURE__*/ messageDesc(file_personhog_types_v1_person, 27)
+export const SplitResultSchema: GenMessage<SplitResult> = /*@__PURE__*/ messageDesc(file_personhog_types_v1_person, 29)
/**
* @generated from message personhog.types.v1.SplitPersonResponse
@@ -901,7 +994,7 @@ export type SplitPersonResponse = Message<'personhog.types.v1.SplitPersonRespons
*/
export const SplitPersonResponseSchema: GenMessage<SplitPersonResponse> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 28)
+ messageDesc(file_personhog_types_v1_person, 30)
/**
* SetPersonDistinctIdVersionFloorRequest bumps a person_distinct_id row's version.
@@ -938,7 +1031,7 @@ export type SetPersonDistinctIdVersionFloorRequest =
*/
export const SetPersonDistinctIdVersionFloorRequestSchema: GenMessage<SetPersonDistinctIdVersionFloorRequest> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 29)
+ messageDesc(file_personhog_types_v1_person, 31)
/**
* @generated from message personhog.types.v1.SetPersonDistinctIdVersionFloorResponse
@@ -961,7 +1054,7 @@ export type SetPersonDistinctIdVersionFloorResponse =
*/
export const SetPersonDistinctIdVersionFloorResponseSchema: GenMessage<SetPersonDistinctIdVersionFloorResponse> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 30)
+ messageDesc(file_personhog_types_v1_person, 32)
/**
* SetPersonVersionFloorRequest bumps a person's version. Used by the undelete repair
@@ -996,7 +1089,7 @@ export type SetPersonVersionFloorRequest = Message<'personhog.types.v1.SetPerson
*/
export const SetPersonVersionFloorRequestSchema: GenMessage<SetPersonVersionFloorRequest> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 31)
+ messageDesc(file_personhog_types_v1_person, 33)
/**
* @generated from message personhog.types.v1.SetPersonVersionFloorResponse
@@ -1016,7 +1109,7 @@ export type SetPersonVersionFloorResponse = Message<'personhog.types.v1.SetPerso
*/
export const SetPersonVersionFloorResponseSchema: GenMessage<SetPersonVersionFloorResponse> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 32)
+ messageDesc(file_personhog_types_v1_person, 34)
/**
* FencePersonRequest freezes a person for a lifecycle operation (see
@@ -1053,7 +1146,7 @@ export type FencePersonRequest = Message<'personhog.types.v1.FencePersonRequest'
*/
export const FencePersonRequestSchema: GenMessage<FencePersonRequest> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 33)
+ messageDesc(file_personhog_types_v1_person, 35)
/**
* @generated from message personhog.types.v1.FencePersonResponse
@@ -1082,7 +1175,7 @@ export type FencePersonResponse = Message<'personhog.types.v1.FencePersonRespons
*/
export const FencePersonResponseSchema: GenMessage<FencePersonResponse> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 34)
+ messageDesc(file_personhog_types_v1_person, 36)
/**
* FencePersonsRequest freezes many persons of one op in one call (see
@@ -1119,7 +1212,7 @@ export type FencePersonsRequest = Message<'personhog.types.v1.FencePersonsReques
*/
export const FencePersonsRequestSchema: GenMessage<FencePersonsRequest> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 35)
+ messageDesc(file_personhog_types_v1_person, 37)
/**
* Every requested person id lands in exactly one of the two lists; a
@@ -1153,7 +1246,7 @@ export type FencePersonsResponse = Message<'personhog.types.v1.FencePersonsRespo
*/
export const FencePersonsResponseSchema: GenMessage<FencePersonsResponse> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 36)
+ messageDesc(file_personhog_types_v1_person, 38)
/**
* @generated from message personhog.types.v1.FencedPersonSeal
@@ -1186,7 +1279,7 @@ export type FencedPersonSeal = Message<'personhog.types.v1.FencedPersonSeal'> &
*/
export const FencedPersonSealSchema: GenMessage<FencedPersonSeal> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 37)
+ messageDesc(file_personhog_types_v1_person, 39)
/**
* ReleaseFenceRequest closes a fence (see PersonHogLeader.ReleaseFence).
@@ -1254,7 +1347,7 @@ export type ReleaseFenceRequest = Message<'personhog.types.v1.ReleaseFenceReques
*/
export const ReleaseFenceRequestSchema: GenMessage<ReleaseFenceRequest> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 38)
+ messageDesc(file_personhog_types_v1_person, 40)
/**
* @generated from message personhog.types.v1.ReleaseFenceResponse
@@ -1267,7 +1360,7 @@ export type ReleaseFenceResponse = Message<'personhog.types.v1.ReleaseFenceRespo
*/
export const ReleaseFenceResponseSchema: GenMessage<ReleaseFenceResponse> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 39)
+ messageDesc(file_personhog_types_v1_person, 41)
/**
* ReleaseFencesRequest closes many fences of one op in one call (see
@@ -1304,7 +1397,7 @@ export type ReleaseFencesRequest = Message<'personhog.types.v1.ReleaseFencesRequ
*/
export const ReleaseFencesRequestSchema: GenMessage<ReleaseFencesRequest> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 40)
+ messageDesc(file_personhog_types_v1_person, 42)
/**
* @generated from message personhog.types.v1.ReleaseFenceItem
@@ -1341,7 +1434,7 @@ export type ReleaseFenceItem = Message<'personhog.types.v1.ReleaseFenceItem'> &
*/
export const ReleaseFenceItemSchema: GenMessage<ReleaseFenceItem> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 41)
+ messageDesc(file_personhog_types_v1_person, 43)
/**
* @generated from message personhog.types.v1.ReleaseFencesResponse
@@ -1354,7 +1447,7 @@ export type ReleaseFencesResponse = Message<'personhog.types.v1.ReleaseFencesRes
*/
export const ReleaseFencesResponseSchema: GenMessage<ReleaseFencesResponse> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 42)
+ messageDesc(file_personhog_types_v1_person, 44)
/**
* A sealed source snapshot paired with its precedence ordinal — the
@@ -1382,7 +1475,7 @@ export type SealedSourceSnapshot = Message<'personhog.types.v1.SealedSourceSnaps
*/
export const SealedSourceSnapshotSchema: GenMessage<SealedSourceSnapshot> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 43)
+ messageDesc(file_personhog_types_v1_person, 45)
/**
* FoldPersonDocumentRequest folds sealed source snapshots into the merge
@@ -1458,7 +1551,7 @@ export type FoldPersonDocumentRequest = Message<'personhog.types.v1.FoldPersonDo
*/
export const FoldPersonDocumentRequestSchema: GenMessage<FoldPersonDocumentRequest> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 44)
+ messageDesc(file_personhog_types_v1_person, 46)
/**
* @generated from message personhog.types.v1.FoldPersonDocumentResponse
@@ -1486,7 +1579,7 @@ export type FoldPersonDocumentResponse = Message<'personhog.types.v1.FoldPersonD
*/
export const FoldPersonDocumentResponseSchema: GenMessage<FoldPersonDocumentResponse> =
/*@__PURE__*/
- messageDesc(file_personhog_types_v1_person, 45)
+ messageDesc(file_personhog_types_v1_person, 47)
/**
* The kind of lifecycle operation — mirrors lifecycle_op.op_type. The
diff --git a/nodejs/src/common/personhog/client.test.ts b/nodejs/src/common/personhog/client.test.ts
index 0ac92b499d64..77fdc7d6fd02 100644
--- a/nodejs/src/common/personhog/client.test.ts
+++ b/nodejs/src/common/personhog/client.test.ts
@@ -133,6 +133,13 @@ const SERVICE_DEFAULTS: ServiceImpl<typeof PersonHogService> = {
updatePersonProperties: () => ({}),
deletePersons: () => ({ deletedCount: 0n }),
deletePersonsBatchForTeam: () => ({ deletedCount: 0n }),
+ deleteTombstonedPersons: () => ({
+ deletedCount: 0n,
+ skippedLiveCount: 0n,
+ blockedPersonUuids: [],
+ pendingPersonUuids: [],
+ rowsDeleted: 0n,
+ }),
splitPerson: () => ({ splits: [] }),
setPersonDistinctIdVersionFloor: () => ({}),
setPersonVersionFloor: () => ({ updated: false }),
diff --git a/nodejs/src/common/personhog/persons.test.ts b/nodejs/src/common/personhog/persons.test.ts
index 5a9111dbdd73..c978fc16e4e4 100644
--- a/nodejs/src/common/personhog/persons.test.ts
+++ b/nodejs/src/common/personhog/persons.test.ts
@@ -71,6 +71,13 @@ const SERVICE_DEFAULTS: ServiceImpl<typeof PersonHogService> = {
updatePersonProperties: () => ({}),
deletePersons: () => ({ deletedCount: 0n }),
deletePersonsBatchForTeam: () => ({ deletedCount: 0n }),
+ deleteTombstonedPersons: () => ({
+ deletedCount: 0n,
+ skippedLiveCount: 0n,
+ blockedPersonUuids: [],
+ pendingPersonUuids: [],
+ rowsDeleted: 0n,
+ }),
splitPerson: () => ({ splits: [] }),
setPersonDistinctIdVersionFloor: () => ({}),
setPersonVersionFloor: () => ({ updated: false }),
diff --git a/posthog/personhog_client/README.md b/posthog/personhog_client/README.md
index 24158d4caa40..4d3228754037 100644
--- a/posthog/personhog_client/README.md
+++ b/posthog/personhog_client/README.md
@@ -69,7 +69,7 @@ The `PersonHogClient` in `client.py` exposes typed methods for every RPC:
`get_distinct_ids_for_person`, `get_distinct_ids_for_persons`
**Person deletes:**
-`delete_persons`, `delete_persons_batch_for_team`
+`delete_persons`, `delete_persons_batch_for_team`, `delete_tombstoned_persons` (deletes only while still tombstoned, a bounded number of dependent rows per call; persons it did not finish come back as pending and are sent again; used by the persons cleanup drain)
**Person split:**
`split_person` — splits distinct_ids off a person onto new persons (max 250 per request); the sole write path for person splits, with no ORM fallback
diff --git a/posthog/personhog_client/client.py b/posthog/personhog_client/client.py
index f1439153a040..af8fa194b0ed 100644
--- a/posthog/personhog_client/client.py
+++ b/posthog/personhog_client/client.py
@@ -42,6 +42,8 @@ from posthog.personhog_client.proto import (
DeletePersonsBatchForTeamResponse,
DeletePersonsRequest,
DeletePersonsResponse,
+ DeleteTombstonedPersonsRequest,
+ DeleteTombstonedPersonsResponse,
GetDistinctIdsForPersonRequest,
GetDistinctIdsForPersonResponse,
GetDistinctIdsForPersonsRequest,
@@ -216,6 +218,11 @@ class PersonHogClient:
) -> DeletePersonsBatchForTeamResponse:
return self._stub.DeletePersonsBatchForTeam(request, timeout=timeout or self._timeout)
+ def delete_tombstoned_persons(
+ self, request: DeleteTombstonedPersonsRequest, timeout: float | None = None
+ ) -> DeleteTombstonedPersonsResponse:
+ return self._stub.DeleteTombstonedPersons(request, timeout=timeout or self._timeout)
+
# -- Person split --
def split_person(self, request: SplitPersonRequest, timeout: float | None = None) -> SplitPersonResponse:
diff --git a/posthog/personhog_client/fake_client.py b/posthog/personhog_client/fake_client.py
index 1df32f952c71..93bede16c5db 100644
--- a/posthog/personhog_client/fake_client.py
+++ b/posthog/personhog_client/fake_client.py
@@ -50,6 +50,10 @@ def _order_identified_first(
return sorted(dids, key=lambda d: is_anonymous_id(d.distinct_id))
+# The replica's row budget when a request leaves max_rows at 0.
+DELETE_TOMBSTONED_DEFAULT_ROWS = 1000
+
+
class FakePersonHogClient:
"""In-memory fake that implements the same interface as PersonHogClient.
@@ -68,6 +72,11 @@ class FakePersonHogClient:
self._persons_by_distinct_id: dict[tuple[int, str], person_pb2.Person] = {}
# keyed by (team_id, person_id) -> list of DistinctIdWithVersion
self._distinct_ids: dict[tuple[int, int], list[person_pb2.DistinctIdWithVersion]] = {}
+ # keyed by (team_id, distinct_id): mappings tombstoned alongside their person
+ self._tombstoned_distinct_ids: set[tuple[int, str]] = set()
+ # Mirrors the replica's TOMBSTONED_DELETE_MAX_ROWS clamp. The fake tracks distinct ids
+ # only, so the row budget counts them alone.
+ self.tombstoned_delete_max_rows = 5000
# keyed by project_id -> list of GroupTypeMapping
self._group_type_mappings_by_project: dict[int, list[group_pb2.GroupTypeMapping]] = {}
@@ -101,7 +110,11 @@ class FakePersonHogClient:
distinct_ids: list[str] | None = None,
distinct_id_versions: dict[str, int] | None = None,
last_seen_at: int = 0,
+ is_deleted: bool = False,
+ tombstoned_distinct_ids: list[str] | None = None,
) -> person_pb2.Person:
+ # Unlike the replica, the fake returns tombstoned persons on reads, so tests can inspect
+ # what a delete left in place.
person = person_pb2.Person(
id=person_id,
uuid=uuid,
@@ -111,6 +124,7 @@ class FakePersonHogClient:
version=version,
is_identified=is_identified,
last_seen_at=last_seen_at,
+ is_deleted=is_deleted,
)
if is_user_id is not None:
person.is_user_id = is_user_id
@@ -122,6 +136,8 @@ class FakePersonHogClient:
self._distinct_ids.setdefault((team_id, person_id), []).append(
person_pb2.DistinctIdWithVersion(distinct_id=did, version=(distinct_id_versions or {}).get(did, 0))
)
+ for did in tombstoned_distinct_ids or []:
+ self._tombstoned_distinct_ids.add((team_id, did))
return person
def add_group_type_mapping(
@@ -572,23 +588,79 @@ class FakePersonHogClient:
# ── Person deletes ────────────────────────────────────────────────
+ def _remove_person(self, team_id: int, person: person_pb2.Person) -> None:
+ self._persons_by_uuid.pop((team_id, person.uuid), None)
+ self._persons_by_id.pop((team_id, person.id), None)
+ for did in self._distinct_ids.pop((team_id, person.id), []):
+ self._persons_by_distinct_id.pop((team_id, did.distinct_id), None)
+ self._tombstoned_distinct_ids.discard((team_id, did.distinct_id))
+ self._cohort_memberships.pop(person.id, None)
+ for key in [key for key in self._cohort_members if key[1] == person.id]:
+ del self._cohort_members[key]
+
def delete_persons(
self, request: person_pb2.DeletePersonsRequest, timeout: float | None = None
) -> person_pb2.DeletePersonsResponse:
self.calls.append(_Call("delete_persons", request))
deleted_count = 0
for uuid in request.person_uuids:
- person = self._persons_by_uuid.pop((request.team_id, uuid), None)
+ person = self._persons_by_uuid.get((request.team_id, uuid))
if person is None:
continue
deleted_count += 1
- self._persons_by_id.pop((request.team_id, person.id), None)
- # Remove distinct_id mappings
- dids = self._distinct_ids.pop((request.team_id, person.id), [])
- for did in dids:
- self._persons_by_distinct_id.pop((request.team_id, did.distinct_id), None)
+ self._remove_person(request.team_id, person)
return person_pb2.DeletePersonsResponse(deleted_count=deleted_count)
+ def delete_tombstoned_persons(
+ self, request: person_pb2.DeleteTombstonedPersonsRequest, timeout: float | None = None
+ ) -> person_pb2.DeleteTombstonedPersonsResponse:
+ # Mirrors the server, in person id order: a tombstoned person whose distinct ids fit the
+ # leftover budget goes whole unless one is live (blocked); the first that does not fit
+ # gives up as many as the leftover allows and stays pending; the rest stay pending untouched.
+ response = person_pb2.DeleteTombstonedPersonsResponse()
+ budget = max(1, min(request.max_rows or DELETE_TOMBSTONED_DEFAULT_ROWS, self.tombstoned_delete_max_rows))
+ candidates: list[tuple[str, person_pb2.Person]] = []
+ for uuid in dict.fromkeys(request.person_uuids):
+ person = self._persons_by_uuid.get((request.team_id, uuid))
+ if person is None:
+ continue
+ if not person.is_deleted:
+ response.skipped_live_count += 1
+ continue
+ candidates.append((uuid, person))
+ candidates.sort(key=lambda candidate: candidate[1].id)
+
+ trim: tuple[str, person_pb2.Person] | None = None
+ for uuid, person in candidates:
+ dids = self._distinct_ids.get((request.team_id, person.id), [])
+ if len(dids) > budget:
+ trim = trim or (uuid, person)
+ response.pending_person_uuids.append(uuid)
+ continue
+ budget -= len(dids)
+ if any((request.team_id, did.distinct_id) not in self._tombstoned_distinct_ids for did in dids):
+ response.blocked_person_uuids.append(uuid)
+ continue
+ self._remove_person(request.team_id, person)
+ response.deleted_count += 1
+ response.rows_deleted += len(dids)
+
+ if trim is not None:
+ uuid, person = trim
+ dids = self._distinct_ids.get((request.team_id, person.id), [])
+ step = dids[:budget]
+ if any((request.team_id, did.distinct_id) not in self._tombstoned_distinct_ids for did in step):
+ response.pending_person_uuids.remove(uuid)
+ response.blocked_person_uuids.append(uuid)
+ else:
+ for did in step:
+ dids.remove(did)
+ self._persons_by_distinct_id.pop((request.team_id, did.distinct_id), None)
+ self._tombstoned_distinct_ids.discard((request.team_id, did.distinct_id))
+ response.rows_deleted += len(step)
+ self.calls.append(_Call("delete_tombstoned_persons", request, response))
+ return response
+
def delete_persons_batch_for_team(
self, request: person_pb2.DeletePersonsBatchForTeamRequest, timeout: float | None = None
) -> person_pb2.DeletePersonsBatchForTeamResponse:
@@ -600,12 +672,8 @@ class FakePersonHogClient:
to_delete.append((team_id, uuid, person))
if len(to_delete) >= request.batch_size:
break
- for team_id, uuid, person in to_delete:
- self._persons_by_uuid.pop((team_id, uuid), None)
- self._persons_by_id.pop((team_id, person.id), None)
- dids = self._distinct_ids.pop((team_id, person.id), [])
- for did in dids:
- self._persons_by_distinct_id.pop((team_id, did.distinct_id), None)
+ for team_id, _uuid, person in to_delete:
+ self._remove_person(team_id, person)
deleted_count += 1
response = person_pb2.DeletePersonsBatchForTeamResponse(deleted_count=deleted_count)
self.calls.append(_Call("delete_persons_batch_for_team", request, response))
diff --git a/posthog/personhog_client/proto/__init__.py b/posthog/personhog_client/proto/__init__.py
index 58a571f9e8fc..a772265b0cb0 100644
--- a/posthog/personhog_client/proto/__init__.py
+++ b/posthog/personhog_client/proto/__init__.py
@@ -70,6 +70,8 @@ from posthog.personhog_client.proto.generated.personhog.types.v1.person_pb2 impo
DeletePersonsBatchForTeamResponse,
DeletePersonsRequest,
DeletePersonsResponse,
+ DeleteTombstonedPersonsRequest,
+ DeleteTombstonedPersonsResponse,
GetDistinctIdsForPersonRequest,
GetDistinctIdsForPersonResponse,
GetDistinctIdsForPersonsRequest,
diff --git a/posthog/personhog_client/proto/generated/personhog/service/v1/service_pb2.py b/posthog/personhog_client/proto/generated/personhog/service/v1/service_pb2.py
index c00c50a7ca20..116d1b041cb8 100644
--- a/posthog/personhog_client/proto/generated/personhog/service/v1/service_pb2.py
+++ b/posthog/personhog_client/proto/generated/personhog/service/v1/service_pb2.py
@@ -20,7 +20,7 @@ from ....personhog.types.v1 import (
)
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
- b"\n\"personhog/service/v1/service.proto\x12\x14personhog.service.v1\x1a\x1fpersonhog/types/v1/person.proto\x1a\x1epersonhog/types/v1/group.proto\x1a\x1fpersonhog/types/v1/cohort.proto\x1a%personhog/types/v1/feature_flag.proto2\xd7*\n\x10PersonHogService\x12X\n\tGetPerson\x12$.personhog.types.v1.GetPersonRequest\x1a%.personhog.types.v1.GetPersonResponse\x12X\n\nGetPersons\x12%.personhog.types.v1.GetPersonsRequest\x1a#.personhog.types.v1.PersonsResponse\x12d\n\x0fGetPersonByUuid\x12*.personhog.types.v1.GetPersonByUuidRequest\x1a%.personhog.types.v1.GetPersonResponse\x12f\n\x11GetPersonsByUuids\x12,.personhog.types.v1.GetPersonsByUuidsRequest\x1a#.personhog.types.v1.PersonsResponse\x12p\n\x15GetPersonByDistinctId\x120.personhog.types.v1.GetPersonByDistinctIdRequest\x1a%.personhog.types.v1.GetPersonResponse\x12\x91\x01\n\x1dGetPersonsByDistinctIdsInTeam\x128.personhog.types.v1.GetPersonsByDistinctIdsInTeamRequest\x1a6.personhog.types.v1.PersonsByDistinctIdsInTeamResponse\x12\x7f\n\x17GetPersonsByDistinctIds\x122.personhog.types.v1.GetPersonsByDistinctIdsRequest\x1a0.personhog.types.v1.PersonsByDistinctIdsResponse\x12\x82\x01\n\x17GetDistinctIdsForPerson\x122.personhog.types.v1.GetDistinctIdsForPersonRequest\x1a3.personhog.types.v1.GetDistinctIdsForPersonResponse\x12\x85\x01\n\x18GetDistinctIdsForPersons\x123.personhog.types.v1.GetDistinctIdsForPersonsRequest\x1a4.personhog.types.v1.GetDistinctIdsForPersonsResponse\x12\x88\x01\n\x19GetHashKeyOverrideContext\x124.personhog.types.v1.GetHashKeyOverrideContextRequest\x1a5.personhog.types.v1.GetHashKeyOverrideContextResponse\x12\x7f\n\x16UpsertHashKeyOverrides\x121.personhog.types.v1.UpsertHashKeyOverridesRequest\x1a2.personhog.types.v1.UpsertHashKeyOverridesResponse\x12\x94\x01\n\x1dDeleteHashKeyOverridesByTeams\x128.personhog.types.v1.DeleteHashKeyOverridesByTeamsRequest\x1a9.personhog.types.v1.DeleteHashKeyOverridesByTeamsResponse\x12w\n\x15CheckCohortMembership\x120.personhog.types.v1.CheckCohortMembershipRequest\x1a,.personhog.types.v1.CohortMembershipResponse\x12s\n\x12CountCohortMembers\x12-.personhog.types.v1.CountCohortMembersRequest\x1a..personhog.types.v1.CountCohortMembersResponse\x12s\n\x12DeleteCohortMember\x12-.personhog.types.v1.DeleteCohortMemberRequest\x1a..personhog.types.v1.DeleteCohortMemberResponse\x12\x82\x01\n\x17DeleteCohortMembersBulk\x122.personhog.types.v1.DeleteCohortMembersBulkRequest\x1a3.personhog.types.v1.DeleteCohortMembersBulkResponse\x12v\n\x13InsertCohortMembers\x12..personhog.types.v1.InsertCohortMembersRequest\x1a/.personhog.types.v1.InsertCohortMembersResponse\x12v\n\x13ListCohortMemberIds\x12..personhog.types.v1.ListCohortMemberIdsRequest\x1a/.personhog.types.v1.ListCohortMemberIdsResponse\x12U\n\x08GetGroup\x12#.personhog.types.v1.GetGroupRequest\x1a$.personhog.types.v1.GetGroupResponse\x12U\n\tGetGroups\x12$.personhog.types.v1.GetGroupsRequest\x1a\".personhog.types.v1.GroupsResponse\x12g\n\x0eGetGroupsBatch\x12).personhog.types.v1.GetGroupsBatchRequest\x1a*.personhog.types.v1.GetGroupsBatchResponse\x12[\n\nListGroups\x12%.personhog.types.v1.ListGroupsRequest\x1a&.personhog.types.v1.ListGroupsResponse\x12\x86\x01\n\x1cGetGroupTypeMappingsByTeamId\x127.personhog.types.v1.GetGroupTypeMappingsByTeamIdRequest\x1a-.personhog.types.v1.GroupTypeMappingsResponse\x12\x8d\x01\n\x1dGetGroupTypeMappingsByTeamIds\x128.personhog.types.v1.GetGroupTypeMappingsByTeamIdsRequest\x1a2.personhog.types.v1.GroupTypeMappingsBatchResponse\x12\x8c\x01\n\x1fGetGroupTypeMappingsByProjectId\x12:.personhog.types.v1.GetGroupTypeMappingsByProjectIdRequest\x1a-.personhog.types.v1.GroupTypeMappingsResponse\x12\x93\x01\n GetGroupTypeMappingsByProjectIds\x12;.personhog.types.v1.GetGroupTypeMappingsByProjectIdsRequest\x1a2.personhog.types.v1.GroupTypeMappingsBatchResponse\x12\x9d\x01\n GetGroupTypeMappingByDashboardId\x12;.personhog.types.v1.GetGroupTypeMappingByDashboardIdRequest\x1a<.personhog.types.v1.GetGroupTypeMappingByDashboardIdResponse\x12\x7f\n\x16CountGroupTypeMappings\x121.personhog.types.v1.CountGroupTypeMappingsRequest\x1a2.personhog.types.v1.CountGroupTypeMappingsResponse\x12^\n\x0bCreateGroup\x12&.personhog.types.v1.CreateGroupRequest\x1a'.personhog.types.v1.CreateGroupResponse\x12^\n\x0bUpdateGroup\x12&.personhog.types.v1.UpdateGroupRequest\x1a'.personhog.types.v1.UpdateGroupResponse\x12\x85\x01\n\x18DeleteGroupsBatchForTeam\x123.personhog.types.v1.DeleteGroupsBatchForTeamRequest\x1a4.personhog.types.v1.DeleteGroupsBatchForTeamResponse\x12\x7f\n\x16UpdateGroupTypeMapping\x121.personhog.types.v1.UpdateGroupTypeMappingRequest\x1a2.personhog.types.v1.UpdateGroupTypeMappingResponse\x12\x7f\n\x16DeleteGroupTypeMapping\x121.personhog.types.v1.DeleteGroupTypeMappingRequest\x1a2.personhog.types.v1.DeleteGroupTypeMappingResponse\x12\xa6\x01\n#DeleteGroupTypeMappingsBatchForTeam\x12>.personhog.types.v1.DeleteGroupTypeMappingsBatchForTeamRequest\x1a?.personhog.types.v1.DeleteGroupTypeMappingsBatchForTeamResponse\x12\x7f\n\x16UpdatePersonProperties\x121.personhog.types.v1.UpdatePersonPropertiesRequest\x1a2.personhog.types.v1.UpdatePersonPropertiesResponse\x12^\n\x0bFencePerson\x12&.personhog.types.v1.FencePersonRequest\x1a'.personhog.types.v1.FencePersonResponse\x12a\n\x0cFencePersons\x12'.personhog.types.v1.FencePersonsRequest\x1a(.personhog.types.v1.FencePersonsResponse\x12a\n\x0cReleaseFence\x12'.personhog.types.v1.ReleaseFenceRequest\x1a(.personhog.types.v1.ReleaseFenceResponse\x12d\n\rReleaseFences\x12(.personhog.types.v1.ReleaseFencesRequest\x1a).personhog.types.v1.ReleaseFencesResponse\x12s\n\x12FoldPersonDocument\x12-.personhog.types.v1.FoldPersonDocumentRequest\x1a..personhog.types.v1.FoldPersonDocumentResponse\x12d\n\rDeletePersons\x12(.personhog.types.v1.DeletePersonsRequest\x1a).personhog.types.v1.DeletePersonsResponse\x12\x88\x01\n\x19DeletePersonsBatchForTeam\x124.personhog.types.v1.DeletePersonsBatchForTeamRequest\x1a5.personhog.types.v1.DeletePersonsBatchForTeamResponse\x12^\n\x0bSplitPerson\x12&.personhog.types.v1.SplitPersonRequest\x1a'.personhog.types.v1.SplitPersonResponse\x12\x9a\x01\n\x1fSetPersonDistinctIdVersionFloor\x12:.personhog.types.v1.SetPersonDistinctIdVersionFloorRequest\x1a;.personhog.types.v1.SetPersonDistinctIdVersionFloorResponse\x12|\n\x15SetPersonVersionFloor\x120.personhog.types.v1.SetPersonVersionFloorRequest\x1a1.personhog.types.v1.SetPersonVersionFloorResponseb\x06proto3"
+ b"\n\"personhog/service/v1/service.proto\x12\x14personhog.service.v1\x1a\x1fpersonhog/types/v1/person.proto\x1a\x1epersonhog/types/v1/group.proto\x1a\x1fpersonhog/types/v1/cohort.proto\x1a%personhog/types/v1/feature_flag.proto2\xdc+\n\x10PersonHogService\x12X\n\tGetPerson\x12$.personhog.types.v1.GetPersonRequest\x1a%.personhog.types.v1.GetPersonResponse\x12X\n\nGetPersons\x12%.personhog.types.v1.GetPersonsRequest\x1a#.personhog.types.v1.PersonsResponse\x12d\n\x0fGetPersonByUuid\x12*.personhog.types.v1.GetPersonByUuidRequest\x1a%.personhog.types.v1.GetPersonResponse\x12f\n\x11GetPersonsByUuids\x12,.personhog.types.v1.GetPersonsByUuidsRequest\x1a#.personhog.types.v1.PersonsResponse\x12p\n\x15GetPersonByDistinctId\x120.personhog.types.v1.GetPersonByDistinctIdRequest\x1a%.personhog.types.v1.GetPersonResponse\x12\x91\x01\n\x1dGetPersonsByDistinctIdsInTeam\x128.personhog.types.v1.GetPersonsByDistinctIdsInTeamRequest\x1a6.personhog.types.v1.PersonsByDistinctIdsInTeamResponse\x12\x7f\n\x17GetPersonsByDistinctIds\x122.personhog.types.v1.GetPersonsByDistinctIdsRequest\x1a0.personhog.types.v1.PersonsByDistinctIdsResponse\x12\x82\x01\n\x17GetDistinctIdsForPerson\x122.personhog.types.v1.GetDistinctIdsForPersonRequest\x1a3.personhog.types.v1.GetDistinctIdsForPersonResponse\x12\x85\x01\n\x18GetDistinctIdsForPersons\x123.personhog.types.v1.GetDistinctIdsForPersonsRequest\x1a4.personhog.types.v1.GetDistinctIdsForPersonsResponse\x12\x88\x01\n\x19GetHashKeyOverrideContext\x124.personhog.types.v1.GetHashKeyOverrideContextRequest\x1a5.personhog.types.v1.GetHashKeyOverrideContextResponse\x12\x7f\n\x16UpsertHashKeyOverrides\x121.personhog.types.v1.UpsertHashKeyOverridesRequest\x1a2.personhog.types.v1.UpsertHashKeyOverridesResponse\x12\x94\x01\n\x1dDeleteHashKeyOverridesByTeams\x128.personhog.types.v1.DeleteHashKeyOverridesByTeamsRequest\x1a9.personhog.types.v1.DeleteHashKeyOverridesByTeamsResponse\x12w\n\x15CheckCohortMembership\x120.personhog.types.v1.CheckCohortMembershipRequest\x1a,.personhog.types.v1.CohortMembershipResponse\x12s\n\x12CountCohortMembers\x12-.personhog.types.v1.CountCohortMembersRequest\x1a..personhog.types.v1.CountCohortMembersResponse\x12s\n\x12DeleteCohortMember\x12-.personhog.types.v1.DeleteCohortMemberRequest\x1a..personhog.types.v1.DeleteCohortMemberResponse\x12\x82\x01\n\x17DeleteCohortMembersBulk\x122.personhog.types.v1.DeleteCohortMembersBulkRequest\x1a3.personhog.types.v1.DeleteCohortMembersBulkResponse\x12v\n\x13InsertCohortMembers\x12..personhog.types.v1.InsertCohortMembersRequest\x1a/.personhog.types.v1.InsertCohortMembersResponse\x12v\n\x13ListCohortMemberIds\x12..personhog.types.v1.ListCohortMemberIdsRequest\x1a/.personhog.types.v1.ListCohortMemberIdsResponse\x12U\n\x08GetGroup\x12#.personhog.types.v1.GetGroupRequest\x1a$.personhog.types.v1.GetGroupResponse\x12U\n\tGetGroups\x12$.personhog.types.v1.GetGroupsRequest\x1a\".personhog.types.v1.GroupsResponse\x12g\n\x0eGetGroupsBatch\x12).personhog.types.v1.GetGroupsBatchRequest\x1a*.personhog.types.v1.GetGroupsBatchResponse\x12[\n\nListGroups\x12%.personhog.types.v1.ListGroupsRequest\x1a&.personhog.types.v1.ListGroupsResponse\x12\x86\x01\n\x1cGetGroupTypeMappingsByTeamId\x127.personhog.types.v1.GetGroupTypeMappingsByTeamIdRequest\x1a-.personhog.types.v1.GroupTypeMappingsResponse\x12\x8d\x01\n\x1dGetGroupTypeMappingsByTeamIds\x128.personhog.types.v1.GetGroupTypeMappingsByTeamIdsRequest\x1a2.personhog.types.v1.GroupTypeMappingsBatchResponse\x12\x8c\x01\n\x1fGetGroupTypeMappingsByProjectId\x12:.personhog.types.v1.GetGroupTypeMappingsByProjectIdRequest\x1a-.personhog.types.v1.GroupTypeMappingsResponse\x12\x93\x01\n GetGroupTypeMappingsByProjectIds\x12;.personhog.types.v1.GetGroupTypeMappingsByProjectIdsRequest\x1a2.personhog.types.v1.GroupTypeMappingsBatchResponse\x12\x9d\x01\n GetGroupTypeMappingByDashboardId\x12;.personhog.types.v1.GetGroupTypeMappingByDashboardIdRequest\x1a<.personhog.types.v1.GetGroupTypeMappingByDashboardIdResponse\x12\x7f\n\x16CountGroupTypeMappings\x121.personhog.types.v1.CountGroupTypeMappingsRequest\x1a2.personhog.types.v1.CountGroupTypeMappingsResponse\x12^\n\x0bCreateGroup\x12&.personhog.types.v1.CreateGroupRequest\x1a'.personhog.types.v1.CreateGroupResponse\x12^\n\x0bUpdateGroup\x12&.personhog.types.v1.UpdateGroupRequest\x1a'.personhog.types.v1.UpdateGroupResponse\x12\x85\x01\n\x18DeleteGroupsBatchForTeam\x123.personhog.types.v1.DeleteGroupsBatchForTeamRequest\x1a4.personhog.types.v1.DeleteGroupsBatchForTeamResponse\x12\x7f\n\x16UpdateGroupTypeMapping\x121.personhog.types.v1.UpdateGroupTypeMappingRequest\x1a2.personhog.types.v1.UpdateGroupTypeMappingResponse\x12\x7f\n\x16DeleteGroupTypeMapping\x121.personhog.types.v1.DeleteGroupTypeMappingRequest\x1a2.personhog.types.v1.DeleteGroupTypeMappingResponse\x12\xa6\x01\n#DeleteGroupTypeMappingsBatchForTeam\x12>.personhog.types.v1.DeleteGroupTypeMappingsBatchForTeamRequest\x1a?.personhog.types.v1.DeleteGroupTypeMappingsBatchForTeamResponse\x12\x7f\n\x16UpdatePersonProperties\x121.personhog.types.v1.UpdatePersonPropertiesRequest\x1a2.personhog.types.v1.UpdatePersonPropertiesResponse\x12^\n\x0bFencePerson\x12&.personhog.types.v1.FencePersonRequest\x1a'.personhog.types.v1.FencePersonResponse\x12a\n\x0cFencePersons\x12'.personhog.types.v1.FencePersonsRequest\x1a(.personhog.types.v1.FencePersonsResponse\x12a\n\x0cReleaseFence\x12'.personhog.types.v1.ReleaseFenceRequest\x1a(.personhog.types.v1.ReleaseFenceResponse\x12d\n\rReleaseFences\x12(.personhog.types.v1.ReleaseFencesRequest\x1a).personhog.types.v1.ReleaseFencesResponse\x12s\n\x12FoldPersonDocument\x12-.personhog.types.v1.FoldPersonDocumentRequest\x1a..personhog.types.v1.FoldPersonDocumentResponse\x12d\n\rDeletePersons\x12(.personhog.types.v1.DeletePersonsRequest\x1a).personhog.types.v1.DeletePersonsResponse\x12\x88\x01\n\x19DeletePersonsBatchForTeam\x124.personhog.types.v1.DeletePersonsBatchForTeamRequest\x1a5.personhog.types.v1.DeletePersonsBatchForTeamResponse\x12\x82\x01\n\x17DeleteTombstonedPersons\x122.personhog.types.v1.DeleteTombstonedPersonsRequest\x1a3.personhog.types.v1.DeleteTombstonedPersonsResponse\x12^\n\x0bSplitPerson\x12&.personhog.types.v1.SplitPersonRequest\x1a'.personhog.types.v1.SplitPersonResponse\x12\x9a\x01\n\x1fSetPersonDistinctIdVersionFloor\x12:.personhog.types.v1.SetPersonDistinctIdVersionFloorRequest\x1a;.personhog.types.v1.SetPersonDistinctIdVersionFloorResponse\x12|\n\x15SetPersonVersionFloor\x120.personhog.types.v1.SetPersonVersionFloorRequest\x1a1.personhog.types.v1.SetPersonVersionFloorResponseb\x06proto3"
)
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
@@ -28,4 +28,4 @@ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "personhog.service.v1.servic
if not _descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options = None
_globals["_PERSONHOGSERVICE"]._serialized_start = 198
- _globals["_PERSONHOGSERVICE"]._serialized_end = 5661
+ _globals["_PERSONHOGSERVICE"]._serialized_end = 5794
diff --git a/posthog/personhog_client/proto/generated/personhog/service/v1/service_pb2_grpc.py b/posthog/personhog_client/proto/generated/personhog/service/v1/service_pb2_grpc.py
index 75dc605c82e9..07350dad7447 100644
--- a/posthog/personhog_client/proto/generated/personhog/service/v1/service_pb2_grpc.py
+++ b/posthog/personhog_client/proto/generated/personhog/service/v1/service_pb2_grpc.py
@@ -291,6 +291,12 @@ class PersonHogServiceStub:
response_deserializer=personhog_dot_types_dot_v1_dot_person__pb2.DeletePersonsBatchForTeamResponse.FromString,
_registered_method=True,
)
+ self.DeleteTombstonedPersons = channel.unary_unary(
+ "/personhog.service.v1.PersonHogService/DeleteTombstonedPersons",
+ request_serializer=personhog_dot_types_dot_v1_dot_person__pb2.DeleteTombstonedPersonsRequest.SerializeToString,
+ response_deserializer=personhog_dot_types_dot_v1_dot_person__pb2.DeleteTombstonedPersonsResponse.FromString,
+ _registered_method=True,
+ )
self.SplitPerson = channel.unary_unary(
"/personhog.service.v1.PersonHogService/SplitPerson",
request_serializer=personhog_dot_types_dot_v1_dot_person__pb2.SplitPersonRequest.SerializeToString,
@@ -561,6 +567,9 @@ class PersonHogServiceServicer:
def DeletePersons(self, request, context):
"""Person deletes
+ DeletePersons removes the persons in any state. A caller working from an advisory
+ list of tombstoned persons must use DeleteTombstonedPersons instead, which re-checks
+ the tombstone under the row lock.
WARNING: This is a write operation on person data. It should route to the leader
once personhog-leader supports deletes. Currently routed through the replica
(which uses the primary Postgres pool) as a temporary measure.
@@ -576,6 +585,15 @@ class PersonHogServiceServicer:
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")
+ def DeleteTombstonedPersons(self, request, context):
+ """Deletes only persons that are still tombstoned when the delete runs, a bounded
+ number of rows per call; pending uuids are sent again by the caller.
+ WARNING: Same routing caveat as DeletePersons above.
+ """
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
+ context.set_details("Method not implemented!")
+ raise NotImplementedError("Method not implemented!")
+
def SplitPerson(self, request, context):
"""Person split
WARNING: Same routing caveat as DeletePersons above — write operation on person data
@@ -810,6 +828,11 @@ def add_PersonHogServiceServicer_to_server(servicer, server):
request_deserializer=personhog_dot_types_dot_v1_dot_person__pb2.DeletePersonsBatchForTeamRequest.FromString,
response_serializer=personhog_dot_types_dot_v1_dot_person__pb2.DeletePersonsBatchForTeamResponse.SerializeToString,
),
+ "DeleteTombstonedPersons": grpc.unary_unary_rpc_method_handler(
+ servicer.DeleteTombstonedPersons,
+ request_deserializer=personhog_dot_types_dot_v1_dot_person__pb2.DeleteTombstonedPersonsRequest.FromString,
+ response_serializer=personhog_dot_types_dot_v1_dot_person__pb2.DeleteTombstonedPersonsResponse.SerializeToString,
+ ),
"SplitPerson": grpc.unary_unary_rpc_method_handler(
servicer.SplitPerson,
request_deserializer=personhog_dot_types_dot_v1_dot_person__pb2.SplitPersonRequest.FromString,
@@ -2096,6 +2119,36 @@ class PersonHogService:
_registered_method=True,
)
+ @staticmethod
+ def DeleteTombstonedPersons(
+ request,
+ target,
+ options=(),
+ channel_credentials=None,
+ call_credentials=None,
+ insecure=False,
+ compression=None,
+ wait_for_ready=None,
+ timeout=None,
+ metadata=None,
+ ):
+ return grpc.experimental.unary_unary(
+ request,
+ target,
+ "/personhog.service.v1.PersonHogService/DeleteTombstonedPersons",
+ personhog_dot_types_dot_v1_dot_person__pb2.DeleteTombstonedPersonsRequest.SerializeToString,
+ personhog_dot_types_dot_v1_dot_person__pb2.DeleteTombstonedPersonsResponse.FromString,
+ options,
+ channel_credentials,
+ insecure,
+ call_credentials,
+ compression,
+ wait_for_ready,
+ timeout,
+ metadata,
+ _registered_method=True,
+ )
+
@staticmethod
def SplitPerson(
request,
diff --git a/posthog/personhog_client/proto/generated/personhog/types/v1/person_pb2.py b/posthog/personhog_client/proto/generated/personhog/types/v1/person_pb2.py
index 44c12adf7e26..9ad1908636a8 100644
--- a/posthog/personhog_client/proto/generated/personhog/types/v1/person_pb2.py
+++ b/posthog/personhog_client/proto/generated/personhog/types/v1/person_pb2.py
@@ -15,17 +15,17 @@ _sym_db = _symbol_database.Default()
from ....personhog.types.v1 import common_pb2 as personhog_dot_types_dot_v1_dot_common__pb2
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
- b'\n\x1fpersonhog/types/v1/person.proto\x12\x12personhog.types.v1\x1a\x1fpersonhog/types/v1/common.proto"\xb2\x02\n\x06Person\x12\n\n\x02id\x18\x01 \x01(\x03\x12\x0c\n\x04uuid\x18\x02 \x01(\t\x12\x0f\n\x07team_id\x18\x03 \x01(\x03\x12\x12\n\nproperties\x18\x04 \x01(\x0c\x12"\n\x1aproperties_last_updated_at\x18\x05 \x01(\x0c\x12!\n\x19properties_last_operation\x18\x06 \x01(\x0c\x12\x12\n\ncreated_at\x18\x07 \x01(\x03\x12\x0f\n\x07version\x18\x08 \x01(\x03\x12\x15\n\ris_identified\x18\t \x01(\x08\x12\x17\n\nis_user_id\x18\n \x01(\x08H\x00\x88\x01\x01\x12\x19\n\x0clast_seen_at\x18\x0b \x01(\x03H\x01\x88\x01\x01\x12\x12\n\nis_deleted\x18\x0c \x01(\x08B\r\n\x0b_is_user_idB\x0f\n\r_last_seen_at"N\n\x15DistinctIdWithVersion\x12\x13\n\x0bdistinct_id\x18\x01 \x01(\t\x12\x14\n\x07version\x18\x02 \x01(\x03H\x00\x88\x01\x01B\n\n\x08_version"h\n\x15PersonWithDistinctIds\x12\x13\n\x0bdistinct_id\x18\x01 \x01(\t\x12/\n\x06person\x18\x02 \x01(\x0b2\x1a.personhog.types.v1.PersonH\x00\x88\x01\x01B\t\n\x07_person"g\n\x11PersonDistinctIds\x12\x11\n\tperson_id\x18\x01 \x01(\x03\x12?\n\x0cdistinct_ids\x18\x02 \x03(\x0b2).personhog.types.v1.DistinctIdWithVersion"\x87\x01\n\x18PersonWithTeamDistinctId\x12/\n\x03key\x18\x01 \x01(\x0b2".personhog.types.v1.TeamDistinctId\x12/\n\x06person\x18\x02 \x01(\x0b2\x1a.personhog.types.v1.PersonH\x00\x88\x01\x01B\t\n\x07_person"m\n\x10GetPersonRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"O\n\x11GetPersonResponse\x12/\n\x06person\x18\x01 \x01(\x0b2\x1a.personhog.types.v1.PersonH\x00\x88\x01\x01B\t\n\x07_person"o\n\x11GetPersonsRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x12\n\nperson_ids\x18\x02 \x03(\x03\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"S\n\x0fPersonsResponse\x12+\n\x07persons\x18\x01 \x03(\x0b2\x1a.personhog.types.v1.Person\x12\x13\n\x0bmissing_ids\x18\x02 \x03(\x03"n\n\x16GetPersonByUuidRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x0c\n\x04uuid\x18\x02 \x01(\t\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"q\n\x18GetPersonsByUuidsRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\r\n\x05uuids\x18\x02 \x03(\t\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"{\n\x1cGetPersonByDistinctIdRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x13\n\x0bdistinct_id\x18\x02 \x01(\t\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"\x84\x01\n$GetPersonsByDistinctIdsInTeamRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x14\n\x0cdistinct_ids\x18\x02 \x03(\t\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"`\n"PersonsByDistinctIdsInTeamResponse\x12:\n\x07results\x18\x01 \x03(\x0b2).personhog.types.v1.PersonWithDistinctIds"\x96\x01\n\x1eGetPersonsByDistinctIdsRequest\x12=\n\x11team_distinct_ids\x18\x01 \x03(\x0b2".personhog.types.v1.TeamDistinctId\x125\n\x0cread_options\x18\x02 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"]\n\x1cPersonsByDistinctIdsResponse\x12=\n\x07results\x18\x01 \x03(\x0b2,.personhog.types.v1.PersonWithTeamDistinctId"\x99\x01\n\x1eGetDistinctIdsForPersonRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions\x12\x12\n\x05limit\x18\x04 \x01(\x03H\x00\x88\x01\x01B\x08\n\x06_limit"b\n\x1fGetDistinctIdsForPersonResponse\x12?\n\x0cdistinct_ids\x18\x01 \x03(\x0b2).personhog.types.v1.DistinctIdWithVersion"\xb1\x01\n\x1fGetDistinctIdsForPersonsRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x12\n\nperson_ids\x18\x02 \x03(\x03\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions\x12\x1d\n\x10limit_per_person\x18\x04 \x01(\x03H\x00\x88\x01\x01B\x13\n\x11_limit_per_person"f\n GetDistinctIdsForPersonsResponse\x12B\n\x13person_distinct_ids\x18\x01 \x03(\x0b2%.personhog.types.v1.PersonDistinctIds"\x96\x02\n\x1dUpdatePersonPropertiesRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x12\x12\n\nevent_name\x18\x03 \x01(\t\x12\x16\n\x0eset_properties\x18\x04 \x01(\x0c\x12\x1b\n\x13set_once_properties\x18\x05 \x01(\x0c\x12\x18\n\x10unset_properties\x18\x06 \x03(\t\x12\x1a\n\ris_identified\x18\x07 \x01(\x08H\x00\x88\x01\x01\x12\x19\n\x0clast_seen_at\x18\x08 \x01(\x03H\x01\x88\x01\x01\x12\x14\n\x0cforce_update\x18\t \x01(\x08B\x10\n\x0e_is_identifiedB\x0f\n\r_last_seen_at"m\n\x1eUpdatePersonPropertiesResponse\x12/\n\x06person\x18\x01 \x01(\x0b2\x1a.personhog.types.v1.PersonH\x00\x88\x01\x01\x12\x0f\n\x07updated\x18\x02 \x01(\x08B\t\n\x07_person"=\n\x14DeletePersonsRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x14\n\x0cperson_uuids\x18\x02 \x03(\t".\n\x15DeletePersonsResponse\x12\x15\n\rdeleted_count\x18\x01 \x01(\x03"G\n DeletePersonsBatchForTeamRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x12\n\nbatch_size\x18\x02 \x01(\x03":\n!DeletePersonsBatchForTeamResponse\x12\x15\n\rdeleted_count\x18\x01 \x01(\x03"W\n\x12SplitPersonRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x12\x1d\n\x15distinct_ids_to_split\x18\x03 \x03(\t"\x8e\x01\n\x0bSplitResult\x12\x13\n\x0bdistinct_id\x18\x01 \x01(\t\x12\x17\n\x0fnew_person_uuid\x18\x02 \x01(\t\x12\x1a\n\x12new_person_version\x18\x03 \x01(\x03\x12\x13\n\x0bpdi_version\x18\x04 \x01(\x03\x12 \n\x18new_person_created_at_ms\x18\x05 \x01(\x03"F\n\x13SplitPersonResponse\x12/\n\x06splits\x18\x01 \x03(\x0b2\x1f.personhog.types.v1.SplitResult"c\n&SetPersonDistinctIdVersionFloorRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x13\n\x0bdistinct_id\x18\x02 \x01(\t\x12\x13\n\x0bmin_version\x18\x03 \x01(\x03"e\n\'SetPersonDistinctIdVersionFloorResponse\x12/\n\x06person\x18\x01 \x01(\x0b2\x1a.personhog.types.v1.PersonH\x00\x88\x01\x01B\t\n\x07_person"W\n\x1cSetPersonVersionFloorRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x12\x13\n\x0bmin_version\x18\x03 \x01(\x03"0\n\x1dSetPersonVersionFloorResponse\x12\x0f\n\x07updated\x18\x01 \x01(\x08"}\n\x12FencePersonRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x12\r\n\x05op_id\x18\x03 \x01(\t\x124\n\x07op_type\x18\x04 \x01(\x0e2#.personhog.types.v1.LifecycleOpType"A\n\x13FencePersonResponse\x12*\n\x06sealed\x18\x01 \x01(\x0b2\x1a.personhog.types.v1.Person"\x7f\n\x13FencePersonsRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\r\n\x05op_id\x18\x02 \x01(\t\x124\n\x07op_type\x18\x03 \x01(\x0e2#.personhog.types.v1.LifecycleOpType\x12\x12\n\nperson_ids\x18\x04 \x03(\x03"_\n\x14FencePersonsResponse\x124\n\x06sealed\x18\x01 \x03(\x0b2$.personhog.types.v1.FencedPersonSeal\x12\x11\n\tnot_found\x18\x02 \x03(\x03"J\n\x10FencedPersonSeal\x12\x11\n\tperson_id\x18\x01 \x01(\x03\x12\x0f\n\x07version\x18\x02 \x01(\x03\x12\x12\n\ncreated_at\x18\x03 \x01(\x03"\xd6\x01\n\x13ReleaseFenceRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x12\x13\n\x0bperson_uuid\x18\x03 \x01(\t\x12\r\n\x05op_id\x18\x04 \x01(\t\x123\n\x07outcome\x18\x05 \x01(\x0e2".personhog.types.v1.ReleaseOutcome\x12\x1b\n\x0esealed_version\x18\x06 \x01(\x03H\x00\x88\x01\x01\x12\x12\n\ncreated_at\x18\x07 \x01(\x03B\x11\n\x0f_sealed_version"\x16\n\x14ReleaseFenceResponse"\xa2\x01\n\x14ReleaseFencesRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\r\n\x05op_id\x18\x02 \x01(\t\x123\n\x07outcome\x18\x03 \x01(\x0e2".personhog.types.v1.ReleaseOutcome\x125\n\x07persons\x18\x04 \x03(\x0b2$.personhog.types.v1.ReleaseFenceItem"~\n\x10ReleaseFenceItem\x12\x11\n\tperson_id\x18\x01 \x01(\x03\x12\x13\n\x0bperson_uuid\x18\x02 \x01(\t\x12\x1b\n\x0esealed_version\x18\x03 \x01(\x03H\x00\x88\x01\x01\x12\x12\n\ncreated_at\x18\x04 \x01(\x03B\x11\n\x0f_sealed_version"\x17\n\x15ReleaseFencesResponse"S\n\x14SealedSourceSnapshot\x12*\n\x06person\x18\x01 \x01(\x0b2\x1a.personhog.types.v1.Person\x12\x0f\n\x07ordinal\x18\x02 \x01(\x05"\xbd\x01\n\x19FoldPersonDocumentRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x12B\n\x10sealed_snapshots\x18\x03 \x03(\x0b2(.personhog.types.v1.SealedSourceSnapshot\x12\x11\n\tevent_set\x18\x04 \x01(\x0c\x12\x16\n\x0eevent_set_once\x18\x05 \x01(\x0c\x12\r\n\x05op_id\x18\x06 \x01(\t"H\n\x1aFoldPersonDocumentResponse\x12*\n\x06person\x18\x01 \x01(\x0b2\x1a.personhog.types.v1.Person*o\n\x0fLifecycleOpType\x12!\n\x1dLIFECYCLE_OP_TYPE_UNSPECIFIED\x10\x00\x12\x1c\n\x18LIFECYCLE_OP_TYPE_DELETE\x10\x01\x12\x1b\n\x17LIFECYCLE_OP_TYPE_MERGE\x10\x02*m\n\x0eReleaseOutcome\x12\x1f\n\x1bRELEASE_OUTCOME_UNSPECIFIED\x10\x00\x12\x1d\n\x19RELEASE_OUTCOME_COMMITTED\x10\x01\x12\x1b\n\x17RELEASE_OUTCOME_ABORTED\x10\x02b\x06proto3'
+ b'\n\x1fpersonhog/types/v1/person.proto\x12\x12personhog.types.v1\x1a\x1fpersonhog/types/v1/common.proto"\xb2\x02\n\x06Person\x12\n\n\x02id\x18\x01 \x01(\x03\x12\x0c\n\x04uuid\x18\x02 \x01(\t\x12\x0f\n\x07team_id\x18\x03 \x01(\x03\x12\x12\n\nproperties\x18\x04 \x01(\x0c\x12"\n\x1aproperties_last_updated_at\x18\x05 \x01(\x0c\x12!\n\x19properties_last_operation\x18\x06 \x01(\x0c\x12\x12\n\ncreated_at\x18\x07 \x01(\x03\x12\x0f\n\x07version\x18\x08 \x01(\x03\x12\x15\n\ris_identified\x18\t \x01(\x08\x12\x17\n\nis_user_id\x18\n \x01(\x08H\x00\x88\x01\x01\x12\x19\n\x0clast_seen_at\x18\x0b \x01(\x03H\x01\x88\x01\x01\x12\x12\n\nis_deleted\x18\x0c \x01(\x08B\r\n\x0b_is_user_idB\x0f\n\r_last_seen_at"N\n\x15DistinctIdWithVersion\x12\x13\n\x0bdistinct_id\x18\x01 \x01(\t\x12\x14\n\x07version\x18\x02 \x01(\x03H\x00\x88\x01\x01B\n\n\x08_version"h\n\x15PersonWithDistinctIds\x12\x13\n\x0bdistinct_id\x18\x01 \x01(\t\x12/\n\x06person\x18\x02 \x01(\x0b2\x1a.personhog.types.v1.PersonH\x00\x88\x01\x01B\t\n\x07_person"g\n\x11PersonDistinctIds\x12\x11\n\tperson_id\x18\x01 \x01(\x03\x12?\n\x0cdistinct_ids\x18\x02 \x03(\x0b2).personhog.types.v1.DistinctIdWithVersion"\x87\x01\n\x18PersonWithTeamDistinctId\x12/\n\x03key\x18\x01 \x01(\x0b2".personhog.types.v1.TeamDistinctId\x12/\n\x06person\x18\x02 \x01(\x0b2\x1a.personhog.types.v1.PersonH\x00\x88\x01\x01B\t\n\x07_person"m\n\x10GetPersonRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"O\n\x11GetPersonResponse\x12/\n\x06person\x18\x01 \x01(\x0b2\x1a.personhog.types.v1.PersonH\x00\x88\x01\x01B\t\n\x07_person"o\n\x11GetPersonsRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x12\n\nperson_ids\x18\x02 \x03(\x03\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"S\n\x0fPersonsResponse\x12+\n\x07persons\x18\x01 \x03(\x0b2\x1a.personhog.types.v1.Person\x12\x13\n\x0bmissing_ids\x18\x02 \x03(\x03"n\n\x16GetPersonByUuidRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x0c\n\x04uuid\x18\x02 \x01(\t\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"q\n\x18GetPersonsByUuidsRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\r\n\x05uuids\x18\x02 \x03(\t\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"{\n\x1cGetPersonByDistinctIdRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x13\n\x0bdistinct_id\x18\x02 \x01(\t\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"\x84\x01\n$GetPersonsByDistinctIdsInTeamRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x14\n\x0cdistinct_ids\x18\x02 \x03(\t\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"`\n"PersonsByDistinctIdsInTeamResponse\x12:\n\x07results\x18\x01 \x03(\x0b2).personhog.types.v1.PersonWithDistinctIds"\x96\x01\n\x1eGetPersonsByDistinctIdsRequest\x12=\n\x11team_distinct_ids\x18\x01 \x03(\x0b2".personhog.types.v1.TeamDistinctId\x125\n\x0cread_options\x18\x02 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions"]\n\x1cPersonsByDistinctIdsResponse\x12=\n\x07results\x18\x01 \x03(\x0b2,.personhog.types.v1.PersonWithTeamDistinctId"\x99\x01\n\x1eGetDistinctIdsForPersonRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions\x12\x12\n\x05limit\x18\x04 \x01(\x03H\x00\x88\x01\x01B\x08\n\x06_limit"b\n\x1fGetDistinctIdsForPersonResponse\x12?\n\x0cdistinct_ids\x18\x01 \x03(\x0b2).personhog.types.v1.DistinctIdWithVersion"\xb1\x01\n\x1fGetDistinctIdsForPersonsRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x12\n\nperson_ids\x18\x02 \x03(\x03\x125\n\x0cread_options\x18\x03 \x01(\x0b2\x1f.personhog.types.v1.ReadOptions\x12\x1d\n\x10limit_per_person\x18\x04 \x01(\x03H\x00\x88\x01\x01B\x13\n\x11_limit_per_person"f\n GetDistinctIdsForPersonsResponse\x12B\n\x13person_distinct_ids\x18\x01 \x03(\x0b2%.personhog.types.v1.PersonDistinctIds"\x96\x02\n\x1dUpdatePersonPropertiesRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x12\x12\n\nevent_name\x18\x03 \x01(\t\x12\x16\n\x0eset_properties\x18\x04 \x01(\x0c\x12\x1b\n\x13set_once_properties\x18\x05 \x01(\x0c\x12\x18\n\x10unset_properties\x18\x06 \x03(\t\x12\x1a\n\ris_identified\x18\x07 \x01(\x08H\x00\x88\x01\x01\x12\x19\n\x0clast_seen_at\x18\x08 \x01(\x03H\x01\x88\x01\x01\x12\x14\n\x0cforce_update\x18\t \x01(\x08B\x10\n\x0e_is_identifiedB\x0f\n\r_last_seen_at"m\n\x1eUpdatePersonPropertiesResponse\x12/\n\x06person\x18\x01 \x01(\x0b2\x1a.personhog.types.v1.PersonH\x00\x88\x01\x01\x12\x0f\n\x07updated\x18\x02 \x01(\x08B\t\n\x07_person"=\n\x14DeletePersonsRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x14\n\x0cperson_uuids\x18\x02 \x03(\t".\n\x15DeletePersonsResponse\x12\x15\n\rdeleted_count\x18\x01 \x01(\x03"G\n DeletePersonsBatchForTeamRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x12\n\nbatch_size\x18\x02 \x01(\x03":\n!DeletePersonsBatchForTeamResponse\x12\x15\n\rdeleted_count\x18\x01 \x01(\x03"Y\n\x1eDeleteTombstonedPersonsRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x14\n\x0cperson_uuids\x18\x02 \x03(\t\x12\x10\n\x08max_rows\x18\x03 \x01(\x03"\xa6\x01\n\x1fDeleteTombstonedPersonsResponse\x12\x15\n\rdeleted_count\x18\x01 \x01(\x03\x12\x1a\n\x12skipped_live_count\x18\x02 \x01(\x03\x12\x1c\n\x14blocked_person_uuids\x18\x03 \x03(\t\x12\x1c\n\x14pending_person_uuids\x18\x04 \x03(\t\x12\x14\n\x0crows_deleted\x18\x05 \x01(\x03"W\n\x12SplitPersonRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x12\x1d\n\x15distinct_ids_to_split\x18\x03 \x03(\t"\x8e\x01\n\x0bSplitResult\x12\x13\n\x0bdistinct_id\x18\x01 \x01(\t\x12\x17\n\x0fnew_person_uuid\x18\x02 \x01(\t\x12\x1a\n\x12new_person_version\x18\x03 \x01(\x03\x12\x13\n\x0bpdi_version\x18\x04 \x01(\x03\x12 \n\x18new_person_created_at_ms\x18\x05 \x01(\x03"F\n\x13SplitPersonResponse\x12/\n\x06splits\x18\x01 \x03(\x0b2\x1f.personhog.types.v1.SplitResult"c\n&SetPersonDistinctIdVersionFloorRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x13\n\x0bdistinct_id\x18\x02 \x01(\t\x12\x13\n\x0bmin_version\x18\x03 \x01(\x03"e\n\'SetPersonDistinctIdVersionFloorResponse\x12/\n\x06person\x18\x01 \x01(\x0b2\x1a.personhog.types.v1.PersonH\x00\x88\x01\x01B\t\n\x07_person"W\n\x1cSetPersonVersionFloorRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x12\x13\n\x0bmin_version\x18\x03 \x01(\x03"0\n\x1dSetPersonVersionFloorResponse\x12\x0f\n\x07updated\x18\x01 \x01(\x08"}\n\x12FencePersonRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x12\r\n\x05op_id\x18\x03 \x01(\t\x124\n\x07op_type\x18\x04 \x01(\x0e2#.personhog.types.v1.LifecycleOpType"A\n\x13FencePersonResponse\x12*\n\x06sealed\x18\x01 \x01(\x0b2\x1a.personhog.types.v1.Person"\x7f\n\x13FencePersonsRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\r\n\x05op_id\x18\x02 \x01(\t\x124\n\x07op_type\x18\x03 \x01(\x0e2#.personhog.types.v1.LifecycleOpType\x12\x12\n\nperson_ids\x18\x04 \x03(\x03"_\n\x14FencePersonsResponse\x124\n\x06sealed\x18\x01 \x03(\x0b2$.personhog.types.v1.FencedPersonSeal\x12\x11\n\tnot_found\x18\x02 \x03(\x03"J\n\x10FencedPersonSeal\x12\x11\n\tperson_id\x18\x01 \x01(\x03\x12\x0f\n\x07version\x18\x02 \x01(\x03\x12\x12\n\ncreated_at\x18\x03 \x01(\x03"\xd6\x01\n\x13ReleaseFenceRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x12\x13\n\x0bperson_uuid\x18\x03 \x01(\t\x12\r\n\x05op_id\x18\x04 \x01(\t\x123\n\x07outcome\x18\x05 \x01(\x0e2".personhog.types.v1.ReleaseOutcome\x12\x1b\n\x0esealed_version\x18\x06 \x01(\x03H\x00\x88\x01\x01\x12\x12\n\ncreated_at\x18\x07 \x01(\x03B\x11\n\x0f_sealed_version"\x16\n\x14ReleaseFenceResponse"\xa2\x01\n\x14ReleaseFencesRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\r\n\x05op_id\x18\x02 \x01(\t\x123\n\x07outcome\x18\x03 \x01(\x0e2".personhog.types.v1.ReleaseOutcome\x125\n\x07persons\x18\x04 \x03(\x0b2$.personhog.types.v1.ReleaseFenceItem"~\n\x10ReleaseFenceItem\x12\x11\n\tperson_id\x18\x01 \x01(\x03\x12\x13\n\x0bperson_uuid\x18\x02 \x01(\t\x12\x1b\n\x0esealed_version\x18\x03 \x01(\x03H\x00\x88\x01\x01\x12\x12\n\ncreated_at\x18\x04 \x01(\x03B\x11\n\x0f_sealed_version"\x17\n\x15ReleaseFencesResponse"S\n\x14SealedSourceSnapshot\x12*\n\x06person\x18\x01 \x01(\x0b2\x1a.personhog.types.v1.Person\x12\x0f\n\x07ordinal\x18\x02 \x01(\x05"\xbd\x01\n\x19FoldPersonDocumentRequest\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x11\n\tperson_id\x18\x02 \x01(\x03\x12B\n\x10sealed_snapshots\x18\x03 \x03(\x0b2(.personhog.types.v1.SealedSourceSnapshot\x12\x11\n\tevent_set\x18\x04 \x01(\x0c\x12\x16\n\x0eevent_set_once\x18\x05 \x01(\x0c\x12\r\n\x05op_id\x18\x06 \x01(\t"H\n\x1aFoldPersonDocumentResponse\x12*\n\x06person\x18\x01 \x01(\x0b2\x1a.personhog.types.v1.Person*o\n\x0fLifecycleOpType\x12!\n\x1dLIFECYCLE_OP_TYPE_UNSPECIFIED\x10\x00\x12\x1c\n\x18LIFECYCLE_OP_TYPE_DELETE\x10\x01\x12\x1b\n\x17LIFECYCLE_OP_TYPE_MERGE\x10\x02*m\n\x0eReleaseOutcome\x12\x1f\n\x1bRELEASE_OUTCOME_UNSPECIFIED\x10\x00\x12\x1d\n\x19RELEASE_OUTCOME_COMMITTED\x10\x01\x12\x1b\n\x17RELEASE_OUTCOME_ABORTED\x10\x02b\x06proto3'
)
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "personhog.types.v1.person_pb2", _globals)
if not _descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options = None
- _globals["_LIFECYCLEOPTYPE"]._serialized_start = 5280
- _globals["_LIFECYCLEOPTYPE"]._serialized_end = 5391
- _globals["_RELEASEOUTCOME"]._serialized_start = 5393
- _globals["_RELEASEOUTCOME"]._serialized_end = 5502
+ _globals["_LIFECYCLEOPTYPE"]._serialized_start = 5540
+ _globals["_LIFECYCLEOPTYPE"]._serialized_end = 5651
+ _globals["_RELEASEOUTCOME"]._serialized_start = 5653
+ _globals["_RELEASEOUTCOME"]._serialized_end = 5762
_globals["_PERSON"]._serialized_start = 89
_globals["_PERSON"]._serialized_end = 395
_globals["_DISTINCTIDWITHVERSION"]._serialized_start = 397
@@ -78,43 +78,47 @@ if not _descriptor._USE_C_DESCRIPTORS:
_globals["_DELETEPERSONSBATCHFORTEAMREQUEST"]._serialized_end = 3163
_globals["_DELETEPERSONSBATCHFORTEAMRESPONSE"]._serialized_start = 3165
_globals["_DELETEPERSONSBATCHFORTEAMRESPONSE"]._serialized_end = 3223
- _globals["_SPLITPERSONREQUEST"]._serialized_start = 3225
- _globals["_SPLITPERSONREQUEST"]._serialized_end = 3312
- _globals["_SPLITRESULT"]._serialized_start = 3315
- _globals["_SPLITRESULT"]._serialized_end = 3457
- _globals["_SPLITPERSONRESPONSE"]._serialized_start = 3459
- _globals["_SPLITPERSONRESPONSE"]._serialized_end = 3529
- _globals["_SETPERSONDISTINCTIDVERSIONFLOORREQUEST"]._serialized_start = 3531
- _globals["_SETPERSONDISTINCTIDVERSIONFLOORREQUEST"]._serialized_end = 3630
- _globals["_SETPERSONDISTINCTIDVERSIONFLOORRESPONSE"]._serialized_start = 3632
- _globals["_SETPERSONDISTINCTIDVERSIONFLOORRESPONSE"]._serialized_end = 3733
- _globals["_SETPERSONVERSIONFLOORREQUEST"]._serialized_start = 3735
- _globals["_SETPERSONVERSIONFLOORREQUEST"]._serialized_end = 3822
- _globals["_SETPERSONVERSIONFLOORRESPONSE"]._serialized_start = 3824
- _globals["_SETPERSONVERSIONFLOORRESPONSE"]._serialized_end = 3872
- _globals["_FENCEPERSONREQUEST"]._serialized_start = 3874
- _globals["_FENCEPERSONREQUEST"]._serialized_end = 3999
- _globals["_FENCEPERSONRESPONSE"]._serialized_start = 4001
- _globals["_FENCEPERSONRESPONSE"]._serialized_end = 4066
- _globals["_FENCEPERSONSREQUEST"]._serialized_start = 4068
- _globals["_FENCEPERSONSREQUEST"]._serialized_end = 4195
- _globals["_FENCEPERSONSRESPONSE"]._serialized_start = 4197
- _globals["_FENCEPERSONSRESPONSE"]._serialized_end = 4292
- _globals["_FENCEDPERSONSEAL"]._serialized_start = 4294
- _globals["_FENCEDPERSONSEAL"]._serialized_end = 4368
- _globals["_RELEASEFENCEREQUEST"]._serialized_start = 4371
- _globals["_RELEASEFENCEREQUEST"]._serialized_end = 4585
- _globals["_RELEASEFENCERESPONSE"]._serialized_start = 4587
- _globals["_RELEASEFENCERESPONSE"]._serialized_end = 4609
- _globals["_RELEASEFENCESREQUEST"]._serialized_start = 4612
- _globals["_RELEASEFENCESREQUEST"]._serialized_end = 4774
- _globals["_RELEASEFENCEITEM"]._serialized_start = 4776
- _globals["_RELEASEFENCEITEM"]._serialized_end = 4902
- _globals["_RELEASEFENCESRESPONSE"]._serialized_start = 4904
- _globals["_RELEASEFENCESRESPONSE"]._serialized_end = 4927
- _globals["_SEALEDSOURCESNAPSHOT"]._serialized_start = 4929
- _globals["_SEALEDSOURCESNAPSHOT"]._serialized_end = 5012
- _globals["_FOLDPERSONDOCUMENTREQUEST"]._serialized_start = 5015
- _globals["_FOLDPERSONDOCUMENTREQUEST"]._serialized_end = 5204
- _globals["_FOLDPERSONDOCUMENTRESPONSE"]._serialized_start = 5206
- _globals["_FOLDPERSONDOCUMENTRESPONSE"]._serialized_end = 5278
+ _globals["_DELETETOMBSTONEDPERSONSREQUEST"]._serialized_start = 3225
+ _globals["_DELETETOMBSTONEDPERSONSREQUEST"]._serialized_end = 3314
+ _globals["_DELETETOMBSTONEDPERSONSRESPONSE"]._serialized_start = 3317
+ _globals["_DELETETOMBSTONEDPERSONSRESPONSE"]._serialized_end = 3483
+ _globals["_SPLITPERSONREQUEST"]._serialized_start = 3485
+ _globals["_SPLITPERSONREQUEST"]._serialized_end = 3572
+ _globals["_SPLITRESULT"]._serialized_start = 3575
+ _globals["_SPLITRESULT"]._serialized_end = 3717
+ _globals["_SPLITPERSONRESPONSE"]._serialized_start = 3719
+ _globals["_SPLITPERSONRESPONSE"]._serialized_end = 3789
+ _globals["_SETPERSONDISTINCTIDVERSIONFLOORREQUEST"]._serialized_start = 3791
+ _globals["_SETPERSONDISTINCTIDVERSIONFLOORREQUEST"]._serialized_end = 3890
+ _globals["_SETPERSONDISTINCTIDVERSIONFLOORRESPONSE"]._serialized_start = 3892
+ _globals["_SETPERSONDISTINCTIDVERSIONFLOORRESPONSE"]._serialized_end = 3993
+ _globals["_SETPERSONVERSIONFLOORREQUEST"]._serialized_start = 3995
+ _globals["_SETPERSONVERSIONFLOORREQUEST"]._serialized_end = 4082
+ _globals["_SETPERSONVERSIONFLOORRESPONSE"]._serialized_start = 4084
+ _globals["_SETPERSONVERSIONFLOORRESPONSE"]._serialized_end = 4132
+ _globals["_FENCEPERSONREQUEST"]._serialized_start = 4134
+ _globals["_FENCEPERSONREQUEST"]._serialized_end = 4259
+ _globals["_FENCEPERSONRESPONSE"]._serialized_start = 4261
+ _globals["_FENCEPERSONRESPONSE"]._serialized_end = 4326
+ _globals["_FENCEPERSONSREQUEST"]._serialized_start = 4328
+ _globals["_FENCEPERSONSREQUEST"]._serialized_end = 4455
+ _globals["_FENCEPERSONSRESPONSE"]._serialized_start = 4457
+ _globals["_FENCEPERSONSRESPONSE"]._serialized_end = 4552
+ _globals["_FENCEDPERSONSEAL"]._serialized_start = 4554
+ _globals["_FENCEDPERSONSEAL"]._serialized_end = 4628
+ _globals["_RELEASEFENCEREQUEST"]._serialized_start = 4631
+ _globals["_RELEASEFENCEREQUEST"]._serialized_end = 4845
+ _globals["_RELEASEFENCERESPONSE"]._serialized_start = 4847
+ _globals["_RELEASEFENCERESPONSE"]._serialized_end = 4869
+ _globals["_RELEASEFENCESREQUEST"]._serialized_start = 4872
+ _globals["_RELEASEFENCESREQUEST"]._serialized_end = 5034
+ _globals["_RELEASEFENCEITEM"]._serialized_start = 5036
+ _globals["_RELEASEFENCEITEM"]._serialized_end = 5162
+ _globals["_RELEASEFENCESRESPONSE"]._serialized_start = 5164
+ _globals["_RELEASEFENCESRESPONSE"]._serialized_end = 5187
+ _globals["_SEALEDSOURCESNAPSHOT"]._serialized_start = 5189
+ _globals["_SEALEDSOURCESNAPSHOT"]._serialized_end = 5272
+ _globals["_FOLDPERSONDOCUMENTREQUEST"]._serialized_start = 5275
+ _globals["_FOLDPERSONDOCUMENTREQUEST"]._serialized_end = 5464
+ _globals["_FOLDPERSONDOCUMENTRESPONSE"]._serialized_start = 5466
+ _globals["_FOLDPERSONDOCUMENTRESPONSE"]._serialized_end = 5538
diff --git a/posthog/personhog_client/proto/generated/personhog/types/v1/person_pb2.pyi b/posthog/personhog_client/proto/generated/personhog/types/v1/person_pb2.pyi
index c4614ee0c3e4..81a305e80f5e 100644
--- a/posthog/personhog_client/proto/generated/personhog/types/v1/person_pb2.pyi
+++ b/posthog/personhog_client/proto/generated/personhog/types/v1/person_pb2.pyi
@@ -423,6 +423,44 @@ class DeletePersonsBatchForTeamResponse(_message.Message):
def __init__(self, deleted_count: _Optional[int] = ...) -> None: ...
+class DeleteTombstonedPersonsRequest(_message.Message):
+ __slots__ = ("team_id", "person_uuids", "max_rows")
+ TEAM_ID_FIELD_NUMBER: _ClassVar[int]
+ PERSON_UUIDS_FIELD_NUMBER: _ClassVar[int]
+ MAX_ROWS_FIELD_NUMBER: _ClassVar[int]
+ team_id: int
+ person_uuids: _containers.RepeatedScalarFieldContainer[str]
+ max_rows: int
+
+ def __init__(
+ self,
+ team_id: _Optional[int] = ...,
+ person_uuids: _Optional[_Iterable[str]] = ...,
+ max_rows: _Optional[int] = ...,
+ ) -> None: ...
+
+class DeleteTombstonedPersonsResponse(_message.Message):
+ __slots__ = ("deleted_count", "skipped_live_count", "blocked_person_uuids", "pending_person_uuids", "rows_deleted")
+ DELETED_COUNT_FIELD_NUMBER: _ClassVar[int]
+ SKIPPED_LIVE_COUNT_FIELD_NUMBER: _ClassVar[int]
+ BLOCKED_PERSON_UUIDS_FIELD_NUMBER: _ClassVar[int]
+ PENDING_PERSON_UUIDS_FIELD_NUMBER: _ClassVar[int]
+ ROWS_DELETED_FIELD_NUMBER: _ClassVar[int]
+ deleted_count: int
+ skipped_live_count: int
+ blocked_person_uuids: _containers.RepeatedScalarFieldContainer[str]
+ pending_person_uuids: _containers.RepeatedScalarFieldContainer[str]
+ rows_deleted: int
+
+ def __init__(
+ self,
+ deleted_count: _Optional[int] = ...,
+ skipped_live_count: _Optional[int] = ...,
+ blocked_person_uuids: _Optional[_Iterable[str]] = ...,
+ pending_person_uuids: _Optional[_Iterable[str]] = ...,
+ rows_deleted: _Optional[int] = ...,
+ ) -> None: ...
+
class SplitPersonRequest(_message.Message):
__slots__ = ("team_id", "person_id", "distinct_ids_to_split")
TEAM_ID_FIELD_NUMBER: _ClassVar[int]
diff --git a/posthog/personhog_client/test_fake_client.py b/posthog/personhog_client/test_fake_client.py
index a84f9a50f7dd..d8b6779984dc 100644
--- a/posthog/personhog_client/test_fake_client.py
+++ b/posthog/personhog_client/test_fake_client.py
@@ -469,3 +469,152 @@ class TestFakePersonhogClientContextManager:
client = get_personhog_client()
assert client is fake
+
+
+class TestFakePersonHogClientDeleteTombstonedPersons:
+ TEAM_ID = 7
+
+ def setup_method(self):
+ self.client = FakePersonHogClient()
+ self.client.add_person(
+ team_id=self.TEAM_ID,
+ person_id=1,
+ uuid="tombstoned",
+ distinct_ids=["t-1", "t-2"],
+ is_deleted=True,
+ tombstoned_distinct_ids=["t-1", "t-2"],
+ )
+ self.client.add_person(team_id=self.TEAM_ID, person_id=2, uuid="live", distinct_ids=["l-1"])
+ self.client.add_person(
+ team_id=self.TEAM_ID,
+ person_id=3,
+ uuid="blocked",
+ distinct_ids=["b-1", "b-2"],
+ is_deleted=True,
+ tombstoned_distinct_ids=["b-1"],
+ )
+ self.client.add_person(
+ team_id=self.TEAM_ID,
+ person_id=4,
+ uuid="big",
+ distinct_ids=[f"o-{i}" for i in range(5)],
+ is_deleted=True,
+ tombstoned_distinct_ids=[f"o-{i}" for i in range(5)],
+ )
+
+ def _delete(self, *uuids: str, max_rows: int = 0) -> person_pb2.DeleteTombstonedPersonsResponse:
+ return self.client.delete_tombstoned_persons(
+ person_pb2.DeleteTombstonedPersonsRequest(team_id=self.TEAM_ID, person_uuids=list(uuids), max_rows=max_rows)
+ )
+
+ def _present(self, uuid: str) -> bool:
+ return self.client.get_person_by_uuid(
+ person_pb2.GetPersonByUuidRequest(team_id=self.TEAM_ID, uuid=uuid)
+ ).HasField("person")
+
+ @pytest.mark.parametrize(
+ "uuid,expected,expect_present",
+ [
+ ("tombstoned", person_pb2.DeleteTombstonedPersonsResponse(deleted_count=1, rows_deleted=2), False),
+ ("live", person_pb2.DeleteTombstonedPersonsResponse(skipped_live_count=1), True),
+ ("blocked", person_pb2.DeleteTombstonedPersonsResponse(blocked_person_uuids=["blocked"]), True),
+ ("big", person_pb2.DeleteTombstonedPersonsResponse(deleted_count=1, rows_deleted=5), False),
+ ("unknown", person_pb2.DeleteTombstonedPersonsResponse(), False),
+ ],
+ )
+ def test_each_outcome(self, uuid, expected, expect_present):
+ # The same uuid twice must not double any count or list.
+ assert self._delete(uuid, uuid) == expected
+ assert self._present(uuid) == expect_present
+
+ def test_a_person_over_the_budget_is_trimmed_across_calls_then_deleted(self):
+ pending = person_pb2.DeleteTombstonedPersonsResponse(pending_person_uuids=["big"], rows_deleted=2)
+
+ assert self._delete("big", max_rows=2) == pending
+ assert self._delete("big", max_rows=2) == pending
+ assert self._delete("big", max_rows=2) == person_pb2.DeleteTombstonedPersonsResponse(
+ deleted_count=1, rows_deleted=1
+ )
+ assert not self._present("big")
+ assert not self.client.get_person_by_distinct_id(
+ person_pb2.GetPersonByDistinctIdRequest(team_id=self.TEAM_ID, distinct_id="o-0")
+ ).HasField("person")
+
+ def test_small_persons_in_the_same_request_never_wait_behind_a_big_one(self):
+ # tombstoned (2 rows) and blocked (2 rows) are admitted first, in id order, leaving 2
+ # rows of the budget for the big person's trim step.
+ resp = self._delete("big", "tombstoned", "live", "blocked", max_rows=6)
+
+ assert resp == person_pb2.DeleteTombstonedPersonsResponse(
+ deleted_count=1,
+ skipped_live_count=1,
+ blocked_person_uuids=["blocked"],
+ pending_person_uuids=["big"],
+ rows_deleted=4,
+ )
+ assert not self._present("tombstoned")
+ assert self._present("big") and self._present("blocked")
+
+ def test_a_big_person_with_a_live_distinct_id_is_blocked_with_nothing_deleted(self):
+ self.client.add_person(
+ team_id=self.TEAM_ID,
+ person_id=5,
+ uuid="big-live",
+ distinct_ids=[f"x-{i}" for i in range(5)],
+ is_deleted=True,
+ tombstoned_distinct_ids=[f"x-{i}" for i in range(1, 5)],
+ )
+
+ resp = self._delete("big-live", max_rows=2)
+
+ assert resp == person_pb2.DeleteTombstonedPersonsResponse(blocked_person_uuids=["big-live"])
+ for distinct_id in ("x-0", "x-4"):
+ assert self.client.get_person_by_distinct_id(
+ person_pb2.GetPersonByDistinctIdRequest(team_id=self.TEAM_ID, distinct_id=distinct_id)
+ ).HasField("person")
+
+ def test_max_rows_defaults_and_clamps_like_the_server(self):
+ self.client.tombstoned_delete_max_rows = 3
+
+ assert self._delete("big", max_rows=0) == person_pb2.DeleteTombstonedPersonsResponse(
+ pending_person_uuids=["big"], rows_deleted=3
+ )
+ assert self._delete("big", max_rows=1) == person_pb2.DeleteTombstonedPersonsResponse(
+ pending_person_uuids=["big"], rows_deleted=1
+ )
+ assert self._delete("big", max_rows=100) == person_pb2.DeleteTombstonedPersonsResponse(
+ deleted_count=1, rows_deleted=1
+ )
+
+ def test_deleting_removes_distinct_id_mappings_and_cohort_rows_and_is_idempotent(self):
+ self.client.add_cohort_membership(person_id=1, cohort_id=9)
+
+ assert self._delete("tombstoned").deleted_count == 1
+
+ by_did = self.client.get_person_by_distinct_id(
+ person_pb2.GetPersonByDistinctIdRequest(team_id=self.TEAM_ID, distinct_id="t-1")
+ )
+ assert not by_did.HasField("person")
+ membership = self.client.check_cohort_membership(
+ cohort_pb2.CheckCohortMembershipRequest(person_id=1, cohort_ids=[9])
+ )
+ assert list(membership.memberships) == []
+ assert self.client.count_cohort_members(cohort_pb2.CountCohortMembersRequest(cohort_ids=[9])).count == 0
+ assert self._delete("tombstoned") == person_pb2.DeleteTombstonedPersonsResponse()
+
+ def test_wrong_team_touches_nothing(self):
+ resp = self.client.delete_tombstoned_persons(
+ person_pb2.DeleteTombstonedPersonsRequest(team_id=self.TEAM_ID + 1, person_uuids=["tombstoned"])
+ )
+
+ assert resp == person_pb2.DeleteTombstonedPersonsResponse()
+ assert self._present("tombstoned")
+
+ def test_delete_persons_still_removes_tombstoned_and_live_alike(self):
+ resp = self.client.delete_persons(
+ person_pb2.DeletePersonsRequest(team_id=self.TEAM_ID, person_uuids=["tombstoned", "live", "blocked"])
+ )
+
+ assert resp.deleted_count == 3
+ for uuid in ("tombstoned", "live", "blocked"):
+ assert not self._present(uuid)
diff --git a/proto/AGENTS.md b/proto/AGENTS.md
index ad02537c409d..e7e4666e3fba 100644
--- a/proto/AGENTS.md
+++ b/proto/AGENTS.md
@@ -31,7 +31,7 @@ Then update:
No codegen step needed (tonic regenerates on `cargo build`), but you must:
- Implement the RPC in `rust/personhog-replica/` (storage layer + service handler)
-- Wire it through `rust/personhog-router/` (backend, router, and service layers)
+- Add the method name to `KNOWN_METHODS` in `rust/personhog-router/src/proxy.rs` (the router forwards raw bytes; leader-routed methods are matched by name there)
- Add tests (see Rust test conventions in `rust/personhog-replica/AGENTS.md`)
## Ingestion worker protos
diff --git a/proto/personhog/replica/v1/replica.proto b/proto/personhog/replica/v1/replica.proto
index d8ccdaf5d9f0..515959e2fa32 100644
--- a/proto/personhog/replica/v1/replica.proto
+++ b/proto/personhog/replica/v1/replica.proto
@@ -64,6 +64,7 @@ service PersonHogReplica {
// Person deletes (temporary: should move to leader once it supports deletes)
rpc DeletePersons(personhog.types.v1.DeletePersonsRequest) returns (personhog.types.v1.DeletePersonsResponse);
rpc DeletePersonsBatchForTeam(personhog.types.v1.DeletePersonsBatchForTeamRequest) returns (personhog.types.v1.DeletePersonsBatchForTeamResponse);
+ rpc DeleteTombstonedPersons(personhog.types.v1.DeleteTombstonedPersonsRequest) returns (personhog.types.v1.DeleteTombstonedPersonsResponse);
// Person split (temporary: same routing caveat as deletes above)
rpc SplitPerson(personhog.types.v1.SplitPersonRequest) returns (personhog.types.v1.SplitPersonResponse);
diff --git a/proto/personhog/service/v1/service.proto b/proto/personhog/service/v1/service.proto
index b925d1edf864..02cddc8f53ec 100644
--- a/proto/personhog/service/v1/service.proto
+++ b/proto/personhog/service/v1/service.proto
@@ -74,6 +74,9 @@ service PersonHogService {
rpc FoldPersonDocument(personhog.types.v1.FoldPersonDocumentRequest) returns (personhog.types.v1.FoldPersonDocumentResponse);
// Person deletes
+ // DeletePersons removes the persons in any state. A caller working from an advisory
+ // list of tombstoned persons must use DeleteTombstonedPersons instead, which re-checks
+ // the tombstone under the row lock.
// WARNING: This is a write operation on person data. It should route to the leader
// once personhog-leader supports deletes. Currently routed through the replica
// (which uses the primary Postgres pool) as a temporary measure.
@@ -81,6 +84,10 @@ service PersonHogService {
rpc DeletePersons(personhog.types.v1.DeletePersonsRequest) returns (personhog.types.v1.DeletePersonsResponse);
// WARNING: Same routing caveat as DeletePersons above.
rpc DeletePersonsBatchForTeam(personhog.types.v1.DeletePersonsBatchForTeamRequest) returns (personhog.types.v1.DeletePersonsBatchForTeamResponse);
+ // Deletes only persons that are still tombstoned when the delete runs, a bounded
+ // number of rows per call; pending uuids are sent again by the caller.
+ // WARNING: Same routing caveat as DeletePersons above.
+ rpc DeleteTombstonedPersons(personhog.types.v1.DeleteTombstonedPersonsRequest) returns (personhog.types.v1.DeleteTombstonedPersonsResponse);
// Person split
// WARNING: Same routing caveat as DeletePersons above — write operation on person data
diff --git a/proto/personhog/types/v1/person.proto b/proto/personhog/types/v1/person.proto
index 052e9b3ee6d5..eb35e73cae8d 100644
--- a/proto/personhog/types/v1/person.proto
+++ b/proto/personhog/types/v1/person.proto
@@ -211,6 +211,39 @@ message DeletePersonsBatchForTeamResponse {
int64 deleted_count = 1;
}
+// DeleteTombstonedPersonsRequest deletes persons only while they are still
+// tombstoned, checking under the same row locks as the delete, so a racing
+// revival is either skipped or lands afterwards on a fresh row. One call does a
+// bounded amount of work: persons whose dependent rows (distinct ids, hash key
+// overrides, cohort memberships) fit the row budget are deleted whole; the first
+// person that does not fit gives up as many rows as the leftover allows and is
+// returned as pending, as is everything after the budget. Send pending uuids again
+// until none come back. Idempotent.
+message DeleteTombstonedPersonsRequest {
+ int64 team_id = 1;
+ // Person UUIDs to delete. Max 1000 per request.
+ repeated string person_uuids = 2;
+ // Dependent rows this call may delete. 0 means the server default; the server
+ // clamps the value to its own maximum (replica setting TOMBSTONED_DELETE_MAX_ROWS).
+ int64 max_rows = 3;
+}
+
+message DeleteTombstonedPersonsResponse {
+ // Persons hard-deleted together with their dependent rows.
+ int64 deleted_count = 1;
+ // Persons found with is_deleted = false: revived after the caller queued them.
+ // Nothing was deleted for them.
+ int64 skipped_live_count = 2;
+ // Persons still tombstoned but referenced by a live distinct id. Nothing was
+ // deleted for them; the caller must not treat them as cleaned.
+ repeated string blocked_person_uuids = 3;
+ // Persons not finished within max_rows: still tombstoned, some rows possibly
+ // gone. Send them again.
+ repeated string pending_person_uuids = 4;
+ // Dependent rows deleted by this call.
+ int64 rows_deleted = 5;
+}
+
// SplitPersonRequest splits specific distinct_ids off of a person onto new persons.
// Each distinct_id gets a new person with a deterministic UUID (UUIDv5 from team_id:distinct_id).
// The operation is atomic per request: all splits succeed or none do.
diff --git a/rust/personhog-replica/.sqlx/query-09e316dd3a94d3bc6c307d2735f960b2bcfcb7bb89dbd5c66419e1a0dcc54503.json b/rust/personhog-replica/.sqlx/query-09e316dd3a94d3bc6c307d2735f960b2bcfcb7bb89dbd5c66419e1a0dcc54503.json
new file mode 100644
index 000000000000..275405249bb1
--- /dev/null
+++ b/rust/personhog-replica/.sqlx/query-09e316dd3a94d3bc6c307d2735f960b2bcfcb7bb89dbd5c66419e1a0dcc54503.json
@@ -0,0 +1,14 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "DELETE FROM posthog_cohortpeople WHERE id = ANY($1)",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Int8Array"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "09e316dd3a94d3bc6c307d2735f960b2bcfcb7bb89dbd5c66419e1a0dcc54503"
+}
diff --git a/rust/personhog-replica/.sqlx/query-1d53950566985021fcd5cc5583a4ced1f4566720d2a431f146a37b8c52d5779a.json b/rust/personhog-replica/.sqlx/query-1d53950566985021fcd5cc5583a4ced1f4566720d2a431f146a37b8c52d5779a.json
new file mode 100644
index 000000000000..aebd7d02bbf2
--- /dev/null
+++ b/rust/personhog-replica/.sqlx/query-1d53950566985021fcd5cc5583a4ced1f4566720d2a431f146a37b8c52d5779a.json
@@ -0,0 +1,15 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "DELETE FROM posthog_persondistinctid WHERE team_id = $1 AND id = ANY($2)",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Int4",
+ "Int8Array"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "1d53950566985021fcd5cc5583a4ced1f4566720d2a431f146a37b8c52d5779a"
+}
diff --git a/rust/personhog-replica/.sqlx/query-2ab6a8ac144329498bd667e14dc58969f93d025cd0e8551886ee56367c3bc0b1.json b/rust/personhog-replica/.sqlx/query-2ab6a8ac144329498bd667e14dc58969f93d025cd0e8551886ee56367c3bc0b1.json
new file mode 100644
index 000000000000..52a02fef2bb4
--- /dev/null
+++ b/rust/personhog-replica/.sqlx/query-2ab6a8ac144329498bd667e14dc58969f93d025cd0e8551886ee56367c3bc0b1.json
@@ -0,0 +1,42 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT p.id AS \"id!\",\n (SELECT count(*) FROM (SELECT 1 FROM posthog_persondistinctid\n WHERE team_id = $1 AND person_id = p.id LIMIT $3) t) AS \"distinct_ids!\",\n (SELECT count(*) FROM (SELECT 1 FROM posthog_featureflaghashkeyoverride\n WHERE team_id = $1 AND person_id = p.id LIMIT $3) t) AS \"hash_key_overrides!\",\n (SELECT count(*) FROM (SELECT 1 FROM posthog_cohortpeople\n WHERE person_id = p.id LIMIT $3) t) AS \"cohort_memberships!\"\n FROM unnest($2::bigint[]) AS p(id)\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id!",
+ "type_info": "Int8"
+ },
+ {
+ "ordinal": 1,
+ "name": "distinct_ids!",
+ "type_info": "Int8"
+ },
+ {
+ "ordinal": 2,
+ "name": "hash_key_overrides!",
+ "type_info": "Int8"
+ },
+ {
+ "ordinal": 3,
+ "name": "cohort_memberships!",
+ "type_info": "Int8"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Int4",
+ "Int8Array",
+ "Int8"
+ ]
+ },
+ "nullable": [
+ null,
+ null,
+ null,
+ null
+ ]
+ },
+ "hash": "2ab6a8ac144329498bd667e14dc58969f93d025cd0e8551886ee56367c3bc0b1"
+}
diff --git a/rust/personhog-replica/.sqlx/query-5bbcabb838ac3962a7f9f39f8086e37172d9d42f85f35040e65a58f1b7735982.json b/rust/personhog-replica/.sqlx/query-5bbcabb838ac3962a7f9f39f8086e37172d9d42f85f35040e65a58f1b7735982.json
new file mode 100644
index 000000000000..88e058de3fb1
--- /dev/null
+++ b/rust/personhog-replica/.sqlx/query-5bbcabb838ac3962a7f9f39f8086e37172d9d42f85f35040e65a58f1b7735982.json
@@ -0,0 +1,15 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "DELETE FROM posthog_featureflaghashkeyoverride WHERE team_id = $1 AND person_id = ANY($2)",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Int4",
+ "Int8Array"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "5bbcabb838ac3962a7f9f39f8086e37172d9d42f85f35040e65a58f1b7735982"
+}
diff --git a/rust/personhog-replica/.sqlx/query-6927414fcbb8f07e710b61435441f6d7b9db22734707f972fb32074fa2fad4f1.json b/rust/personhog-replica/.sqlx/query-6927414fcbb8f07e710b61435441f6d7b9db22734707f972fb32074fa2fad4f1.json
new file mode 100644
index 000000000000..80d0e1b8892c
--- /dev/null
+++ b/rust/personhog-replica/.sqlx/query-6927414fcbb8f07e710b61435441f6d7b9db22734707f972fb32074fa2fad4f1.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT id::bigint AS \"id!\"\n FROM posthog_person\n WHERE team_id = $1 AND id = ANY($2) AND is_deleted\n ORDER BY id\n FOR UPDATE\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id!",
+ "type_info": "Int8"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Int4",
+ "Int8Array"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "6927414fcbb8f07e710b61435441f6d7b9db22734707f972fb32074fa2fad4f1"
+}
diff --git a/rust/personhog-replica/.sqlx/query-709c822202ccdcb5ff14e54fb82960465ae47ce237bb0de6ae1d9e289a800c14.json b/rust/personhog-replica/.sqlx/query-709c822202ccdcb5ff14e54fb82960465ae47ce237bb0de6ae1d9e289a800c14.json
new file mode 100644
index 000000000000..f91b2f2b8521
--- /dev/null
+++ b/rust/personhog-replica/.sqlx/query-709c822202ccdcb5ff14e54fb82960465ae47ce237bb0de6ae1d9e289a800c14.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT count(*) AS \"count!\"\n FROM posthog_person\n WHERE team_id = $1 AND uuid = ANY($2) AND is_deleted = false\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "count!",
+ "type_info": "Int8"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Int4",
+ "UuidArray"
+ ]
+ },
+ "nullable": [
+ null
+ ]
+ },
+ "hash": "709c822202ccdcb5ff14e54fb82960465ae47ce237bb0de6ae1d9e289a800c14"
+}
diff --git a/rust/personhog-replica/.sqlx/query-75d73fcab2d574df253bcd7cf478cc660b63640d7c1483cabe636f07eaf0b388.json b/rust/personhog-replica/.sqlx/query-75d73fcab2d574df253bcd7cf478cc660b63640d7c1483cabe636f07eaf0b388.json
new file mode 100644
index 000000000000..1e9deffa070a
--- /dev/null
+++ b/rust/personhog-replica/.sqlx/query-75d73fcab2d574df253bcd7cf478cc660b63640d7c1483cabe636f07eaf0b388.json
@@ -0,0 +1,15 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "DELETE FROM posthog_featureflaghashkeyoverride WHERE team_id = $1 AND id = ANY($2::bigint[])",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Int4",
+ "Int8Array"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "75d73fcab2d574df253bcd7cf478cc660b63640d7c1483cabe636f07eaf0b388"
+}
diff --git a/rust/personhog-replica/.sqlx/query-8d37b457f707e52fea5027efb00e5d8902ab548c81e38f8279ded75e0e89da8f.json b/rust/personhog-replica/.sqlx/query-8d37b457f707e52fea5027efb00e5d8902ab548c81e38f8279ded75e0e89da8f.json
new file mode 100644
index 000000000000..9789605f4b86
--- /dev/null
+++ b/rust/personhog-replica/.sqlx/query-8d37b457f707e52fea5027efb00e5d8902ab548c81e38f8279ded75e0e89da8f.json
@@ -0,0 +1,30 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT id::bigint AS \"id!\", is_deleted AS \"is_deleted!\"\n FROM posthog_persondistinctid\n WHERE team_id = $1 AND person_id = $2\n LIMIT $3\n FOR UPDATE\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id!",
+ "type_info": "Int8"
+ },
+ {
+ "ordinal": 1,
+ "name": "is_deleted!",
+ "type_info": "Bool"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Int4",
+ "Int8",
+ "Int8"
+ ]
+ },
+ "nullable": [
+ false,
+ false
+ ]
+ },
+ "hash": "8d37b457f707e52fea5027efb00e5d8902ab548c81e38f8279ded75e0e89da8f"
+}
diff --git a/rust/personhog-replica/.sqlx/query-c5ceeed49c4f6b887d2d7e96aaaa3ec7ce15bce008ee100aad382d97416907d4.json b/rust/personhog-replica/.sqlx/query-c5ceeed49c4f6b887d2d7e96aaaa3ec7ce15bce008ee100aad382d97416907d4.json
new file mode 100644
index 000000000000..da390ebc5364
--- /dev/null
+++ b/rust/personhog-replica/.sqlx/query-c5ceeed49c4f6b887d2d7e96aaaa3ec7ce15bce008ee100aad382d97416907d4.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT id::bigint AS \"id!\"\n FROM posthog_cohortpeople\n WHERE person_id = $1\n LIMIT $2\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id!",
+ "type_info": "Int8"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Int8",
+ "Int8"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "c5ceeed49c4f6b887d2d7e96aaaa3ec7ce15bce008ee100aad382d97416907d4"
+}
diff --git a/rust/personhog-replica/.sqlx/query-d0422727d46f82a91929bd6e1bde67a4d1b95e0373b45ab7b935b175c3b9af25.json b/rust/personhog-replica/.sqlx/query-d0422727d46f82a91929bd6e1bde67a4d1b95e0373b45ab7b935b175c3b9af25.json
new file mode 100644
index 000000000000..0a74a66678a2
--- /dev/null
+++ b/rust/personhog-replica/.sqlx/query-d0422727d46f82a91929bd6e1bde67a4d1b95e0373b45ab7b935b175c3b9af25.json
@@ -0,0 +1,29 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT id::bigint AS \"id!\", uuid AS \"uuid!\"\n FROM posthog_person\n WHERE team_id = $1 AND uuid = ANY($2) AND is_deleted\n ORDER BY id\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id!",
+ "type_info": "Int8"
+ },
+ {
+ "ordinal": 1,
+ "name": "uuid!",
+ "type_info": "Uuid"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Int4",
+ "UuidArray"
+ ]
+ },
+ "nullable": [
+ false,
+ false
+ ]
+ },
+ "hash": "d0422727d46f82a91929bd6e1bde67a4d1b95e0373b45ab7b935b175c3b9af25"
+}
diff --git a/rust/personhog-replica/.sqlx/query-f373cf983473004a5f1535fa1c56d748e85555973b3abd6d13e5adc6fd69601a.json b/rust/personhog-replica/.sqlx/query-f373cf983473004a5f1535fa1c56d748e85555973b3abd6d13e5adc6fd69601a.json
new file mode 100644
index 000000000000..e974693d34ed
--- /dev/null
+++ b/rust/personhog-replica/.sqlx/query-f373cf983473004a5f1535fa1c56d748e85555973b3abd6d13e5adc6fd69601a.json
@@ -0,0 +1,29 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT person_id AS \"person_id!\", is_deleted AS \"is_deleted!\"\n FROM posthog_persondistinctid\n WHERE team_id = $1 AND person_id = ANY($2)\n ORDER BY id\n FOR UPDATE\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "person_id!",
+ "type_info": "Int8"
+ },
+ {
+ "ordinal": 1,
+ "name": "is_deleted!",
+ "type_info": "Bool"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Int4",
+ "Int8Array"
+ ]
+ },
+ "nullable": [
+ false,
+ false
+ ]
+ },
+ "hash": "f373cf983473004a5f1535fa1c56d748e85555973b3abd6d13e5adc6fd69601a"
+}
diff --git a/rust/personhog-replica/.sqlx/query-fcc1c6fe82aa2208a7b6f38cb45b3e2a4912343ffaad7ea53aa6bf385de1ab3f.json b/rust/personhog-replica/.sqlx/query-fcc1c6fe82aa2208a7b6f38cb45b3e2a4912343ffaad7ea53aa6bf385de1ab3f.json
new file mode 100644
index 000000000000..a08c52feb9f4
--- /dev/null
+++ b/rust/personhog-replica/.sqlx/query-fcc1c6fe82aa2208a7b6f38cb45b3e2a4912343ffaad7ea53aa6bf385de1ab3f.json
@@ -0,0 +1,24 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT id::bigint AS \"id!\"\n FROM posthog_featureflaghashkeyoverride\n WHERE team_id = $1 AND person_id = $2\n LIMIT $3\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id!",
+ "type_info": "Int8"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Int4",
+ "Int8",
+ "Int8"
+ ]
+ },
+ "nullable": [
+ null
+ ]
+ },
+ "hash": "fcc1c6fe82aa2208a7b6f38cb45b3e2a4912343ffaad7ea53aa6bf385de1ab3f"
+}
diff --git a/rust/personhog-replica/src/config.rs b/rust/personhog-replica/src/config.rs
index 441ce65073d8..35b13d2b6264 100644
--- a/rust/personhog-replica/src/config.rs
+++ b/rust/personhog-replica/src/config.rs
@@ -61,6 +61,13 @@ pub struct Config {
#[envconfig(default = "2")]
pub bulk_max_concurrent_chunks: usize,
+ /// Most dependent rows (distinct ids, hash key overrides, cohort
+ /// memberships) one DeleteTombstonedPersons call may delete; the request's
+ /// max_rows is clamped to it. The bulk pool statement timeout is 30 s and the
+ /// measured tail cost on the persons tables is up to 5 ms per row.
+ #[envconfig(default = "5000")]
+ pub tombstoned_delete_max_rows: usize,
+
/// Maximum number of server-side (PgBouncer → Postgres) connections to
/// warm at startup via SELECT 1. Clamped to min_pg_connections. Set to 0
/// to skip server-side warming entirely.
diff --git a/rust/personhog-replica/src/main.rs b/rust/personhog-replica/src/main.rs
index ee9682d1e143..1ec1b85d2830 100644
--- a/rust/personhog-replica/src/main.rs
+++ b/rust/personhog-replica/src/main.rs
@@ -97,6 +97,10 @@ async fn create_storage(config: &Config) -> Arc<PostgresStorage> {
config.bulk_chunk_size >= 1,
"BULK_CHUNK_SIZE must be at least 1"
);
+ assert!(
+ config.tombstoned_delete_max_rows >= 1,
+ "TOMBSTONED_DELETE_MAX_ROWS must be at least 1"
+ );
assert!(
config.bulk_max_concurrent_chunks >= 1,
"BULK_MAX_CONCURRENT_CHUNKS must be at least 1"
@@ -115,6 +119,7 @@ async fn create_storage(config: &Config) -> Arc<PostgresStorage> {
bulk_replica_pool,
config.bulk_chunk_size,
config.bulk_max_concurrent_chunks,
+ config.tombstoned_delete_max_rows,
))
}
other => {
diff --git a/rust/personhog-replica/src/service/mod.rs b/rust/personhog-replica/src/service/mod.rs
index c67de1b162d8..ea44f36157be 100644
--- a/rust/personhog-replica/src/service/mod.rs
+++ b/rust/personhog-replica/src/service/mod.rs
@@ -20,14 +20,14 @@ use personhog_proto::personhog::types::v1::{
DeleteGroupsBatchForTeamRequest, DeleteGroupsBatchForTeamResponse,
DeleteHashKeyOverridesByTeamsRequest, DeleteHashKeyOverridesByTeamsResponse,
DeletePersonsBatchForTeamRequest, DeletePersonsBatchForTeamResponse, DeletePersonsRequest,
- DeletePersonsResponse, DistinctIdWithVersion, GetDistinctIdsForPersonRequest,
- GetDistinctIdsForPersonResponse, GetDistinctIdsForPersonsRequest,
- GetDistinctIdsForPersonsResponse, GetGroupRequest, GetGroupResponse,
- GetGroupTypeMappingByDashboardIdRequest, GetGroupTypeMappingByDashboardIdResponse,
- GetGroupTypeMappingsByProjectIdRequest, GetGroupTypeMappingsByProjectIdsRequest,
- GetGroupTypeMappingsByTeamIdRequest, GetGroupTypeMappingsByTeamIdsRequest,
- GetGroupsBatchRequest, GetGroupsBatchResponse, GetGroupsRequest,
- GetHashKeyOverrideContextRequest, GetHashKeyOverrideContextResponse,
+ DeletePersonsResponse, DeleteTombstonedPersonsRequest, DeleteTombstonedPersonsResponse,
+ DistinctIdWithVersion, GetDistinctIdsForPersonRequest, GetDistinctIdsForPersonResponse,
+ GetDistinctIdsForPersonsRequest, GetDistinctIdsForPersonsResponse, GetGroupRequest,
+ GetGroupResponse, GetGroupTypeMappingByDashboardIdRequest,
+ GetGroupTypeMappingByDashboardIdResponse, GetGroupTypeMappingsByProjectIdRequest,
+ GetGroupTypeMappingsByProjectIdsRequest, GetGroupTypeMappingsByTeamIdRequest,
+ GetGroupTypeMappingsByTeamIdsRequest, GetGroupsBatchRequest, GetGroupsBatchResponse,
+ GetGroupsRequest, GetHashKeyOverrideContextRequest, GetHashKeyOverrideContextResponse,
GetPersonByDistinctIdRequest, GetPersonByUuidRequest, GetPersonRequest, GetPersonResponse,
GetPersonsByDistinctIdsInTeamRequest, GetPersonsByDistinctIdsRequest, GetPersonsByUuidsRequest,
GetPersonsRequest, GroupKey, GroupTypeMapping, GroupTypeMappingCount,
@@ -64,6 +64,9 @@ use field_mask::{
person_needs_properties,
};
+/// Dependent rows one DeleteTombstonedPersons call deletes when the request leaves max_rows at 0.
+const DELETE_TOMBSTONED_DEFAULT_ROWS: i64 = 1000;
+
pub struct PersonHogReplicaService {
storage: Arc<dyn FullStorage>,
}
@@ -432,6 +435,56 @@ impl PersonHogReplica for PersonHogReplicaService {
}))
}
+ async fn delete_tombstoned_persons(
+ &self,
+ request: Request<DeleteTombstonedPersonsRequest>,
+ ) -> Result<Response<DeleteTombstonedPersonsResponse>, Status> {
+ let req = request.into_inner();
+
+ if req.person_uuids.len() > 1000 {
+ return Err(Status::invalid_argument(
+ "Maximum 1000 person UUIDs per request",
+ ));
+ }
+
+ let uuids: Vec<Uuid> = req
+ .person_uuids
+ .iter()
+ .map(|s| Uuid::parse_str(s))
+ .collect::<Result<Vec<_>, _>>()
+ .map_err(|e| Status::invalid_argument(format!("Invalid UUID: {e}")))?;
+ if req.max_rows < 0 {
+ return Err(Status::invalid_argument("max_rows must not be negative"));
+ }
+ let max_rows = if req.max_rows == 0 {
+ DELETE_TOMBSTONED_DEFAULT_ROWS
+ } else {
+ req.max_rows
+ };
+
+ let outcome = self
+ .storage
+ .delete_tombstoned_persons(req.team_id, &uuids, max_rows)
+ .await
+ .map_err(|e| log_and_convert_error(e, "delete_tombstoned_persons"))?;
+
+ Ok(Response::new(DeleteTombstonedPersonsResponse {
+ deleted_count: outcome.deleted,
+ skipped_live_count: outcome.skipped_live,
+ blocked_person_uuids: outcome
+ .blocked_uuids
+ .iter()
+ .map(ToString::to_string)
+ .collect(),
+ pending_person_uuids: outcome
+ .pending_uuids
+ .iter()
+ .map(ToString::to_string)
+ .collect(),
+ rows_deleted: outcome.rows_deleted,
+ }))
+ }
+
// ============================================================
// Feature Flag support
// ============================================================
diff --git a/rust/personhog-replica/src/service/tests/mocks.rs b/rust/personhog-replica/src/service/tests/mocks.rs
index bf7995f18c83..af71e1063cf7 100644
--- a/rust/personhog-replica/src/service/tests/mocks.rs
+++ b/rust/personhog-replica/src/service/tests/mocks.rs
@@ -95,6 +95,15 @@ impl storage::PersonLookup for FailingStorage {
Err(self.error.clone())
}
+ async fn delete_tombstoned_persons(
+ &self,
+ _team_id: i64,
+ _uuids: &[Uuid],
+ _max_rows: i64,
+ ) -> storage::StorageResult<storage::TombstonedDeleteOutcome> {
+ Err(self.error.clone())
+ }
+
async fn delete_persons_batch_for_team(
&self,
_team_id: i64,
@@ -469,6 +478,15 @@ impl storage::PersonLookup for SuccessStorage {
Ok(0)
}
+ async fn delete_tombstoned_persons(
+ &self,
+ _team_id: i64,
+ _uuids: &[Uuid],
+ _max_rows: i64,
+ ) -> storage::StorageResult<storage::TombstonedDeleteOutcome> {
+ Ok(storage::TombstonedDeleteOutcome::default())
+ }
+
async fn delete_persons_batch_for_team(
&self,
_team_id: i64,
@@ -902,6 +920,15 @@ impl storage::PersonLookup for PopulatedStorage {
Ok(0)
}
+ async fn delete_tombstoned_persons(
+ &self,
+ _team_id: i64,
+ _uuids: &[Uuid],
+ _max_rows: i64,
+ ) -> storage::StorageResult<storage::TombstonedDeleteOutcome> {
+ Ok(storage::TombstonedDeleteOutcome::default())
+ }
+
async fn delete_persons_batch_for_team(
&self,
_team_id: i64,
@@ -1311,6 +1338,15 @@ impl storage::PersonLookup for ConsistencyTrackingStorage {
Ok(0)
}
+ async fn delete_tombstoned_persons(
+ &self,
+ _team_id: i64,
+ _uuids: &[Uuid],
+ _max_rows: i64,
+ ) -> storage::StorageResult<storage::TombstonedDeleteOutcome> {
+ Ok(storage::TombstonedDeleteOutcome::default())
+ }
+
async fn delete_persons_batch_for_team(
&self,
_team_id: i64,
diff --git a/rust/personhog-replica/src/service/tests/mod.rs b/rust/personhog-replica/src/service/tests/mod.rs
index 259ba6b329f7..ca4ef0519b11 100644
--- a/rust/personhog-replica/src/service/tests/mod.rs
+++ b/rust/personhog-replica/src/service/tests/mod.rs
@@ -9,9 +9,10 @@ use personhog_proto::personhog::types::v1::{
CountCohortMembersRequest, CreateGroupRequest, DeleteCohortMemberRequest,
DeleteCohortMembersBulkRequest, DeleteGroupTypeMappingRequest,
DeleteGroupTypeMappingsBatchForTeamRequest, DeleteGroupsBatchForTeamRequest,
- DeletePersonsBatchForTeamRequest, DeletePersonsRequest, GetGroupRequest, GetPersonRequest,
- GetPersonsByDistinctIdsInTeamRequest, InsertCohortMembersRequest, ListCohortMemberIdsRequest,
- UpdateGroupRequest, UpdateGroupTypeMappingRequest,
+ DeletePersonsBatchForTeamRequest, DeletePersonsRequest, DeleteTombstonedPersonsRequest,
+ GetGroupRequest, GetPersonRequest, GetPersonsByDistinctIdsInTeamRequest,
+ InsertCohortMembersRequest, ListCohortMemberIdsRequest, UpdateGroupRequest,
+ UpdateGroupTypeMappingRequest,
};
use rstest::rstest;
use tonic::Request;
@@ -191,6 +192,43 @@ async fn test_delete_persons_success(#[case] person_uuids: Vec<String>) {
assert!(result.is_ok());
}
+// ============================================================
+// DeleteTombstonedPersons tests
+// ============================================================
+
+#[rstest]
+#[case::too_many_uuids(
+ (0..1001).map(|i| format!("00000000-0000-0000-0000-{i:012}")).collect(),
+ 0,
+ "1000"
+)]
+#[case::invalid_uuid(vec!["not-a-valid-uuid".to_string()], 0, "Invalid UUID")]
+#[case::negative_max_rows(
+ vec!["00000000-0000-0000-0000-000000000001".to_string()],
+ -1,
+ "max_rows"
+)]
+#[tokio::test]
+async fn test_delete_tombstoned_persons_invalid_input(
+ #[case] person_uuids: Vec<String>,
+ #[case] max_rows: i64,
+ #[case] expected_message: &str,
+) {
+ let service = PersonHogReplicaService::new(Arc::new(mocks::SuccessStorage));
+
+ let status = service
+ .delete_tombstoned_persons(Request::new(DeleteTombstonedPersonsRequest {
+ team_id: 1,
+ person_uuids,
+ max_rows,
+ }))
+ .await
+ .unwrap_err();
+
+ assert_eq!(status.code(), tonic::Code::InvalidArgument);
+ assert!(status.message().contains(expected_message));
+}
+
// ============================================================
// DeletePersonsBatchForTeam tests
// ============================================================
diff --git a/rust/personhog-replica/src/storage/mod.rs b/rust/personhog-replica/src/storage/mod.rs
index d90b62df5308..a53d4ed8225c 100644
--- a/rust/personhog-replica/src/storage/mod.rs
+++ b/rust/personhog-replica/src/storage/mod.rs
@@ -8,6 +8,7 @@ pub use error::{StorageError, StorageResult};
pub use types::{
CohortMembership, DistinctIdMapping, DistinctIdWithVersion, Group, GroupIdentifier, GroupKey,
GroupTypeMapping, HashKeyOverride, HashKeyOverrideContext, Person, SplitResult,
+ TombstonedDeleteOutcome,
};
pub use traits::{CohortStorage, DistinctIdLookup, FeatureFlagStorage, GroupStorage, PersonLookup};
diff --git a/rust/personhog-replica/src/storage/postgres/mod.rs b/rust/personhog-replica/src/storage/postgres/mod.rs
index 9988eef6af28..e6ab51353075 100644
--- a/rust/personhog-replica/src/storage/postgres/mod.rs
+++ b/rust/personhog-replica/src/storage/postgres/mod.rs
@@ -41,6 +41,7 @@ pub struct PostgresStorage {
pub bulk_replica_pool: PgPool,
pub(crate) bulk_chunk_size: usize,
pub(crate) bulk_max_concurrent_chunks: usize,
+ pub(crate) tombstoned_delete_max_rows: usize,
}
impl PostgresStorage {
@@ -52,6 +53,7 @@ impl PostgresStorage {
bulk_replica_pool: PgPool,
bulk_chunk_size: usize,
bulk_max_concurrent_chunks: usize,
+ tombstoned_delete_max_rows: usize,
) -> Self {
Self {
primary_pool,
@@ -60,6 +62,7 @@ impl PostgresStorage {
bulk_replica_pool,
bulk_chunk_size,
bulk_max_concurrent_chunks,
+ tombstoned_delete_max_rows,
}
}
diff --git a/rust/personhog-replica/src/storage/postgres/person.rs b/rust/personhog-replica/src/storage/postgres/person.rs
index 69ce79d31667..aab08f8c9d68 100644
--- a/rust/personhog-replica/src/storage/postgres/person.rs
+++ b/rust/personhog-replica/src/storage/postgres/person.rs
@@ -4,6 +4,7 @@ use async_trait::async_trait;
use chrono::{DateTime, Utc};
use futures::stream::{self, StreamExt, TryStreamExt};
use sqlx::postgres::PgPool;
+use sqlx::{Postgres, Transaction};
use uuid::Uuid;
use personhog_common::grpc::{current_client_name, current_method_name};
@@ -11,7 +12,7 @@ use personhog_common::grpc::{current_client_name, current_method_name};
use super::{PostgresStorage, DB_BULK_CHUNKS, DB_QUERY_DURATION, DB_ROWS_RETURNED};
use crate::storage::error::{StorageError, StorageResult};
use crate::storage::traits::PersonLookup;
-use crate::storage::types::{Person, SplitResult};
+use crate::storage::types::{Person, SplitResult, TombstonedDeleteOutcome};
/// Version offset for split person/PDI rows — mirrors the Django convention.
const SPLIT_VERSION_OFFSET: i64 = 101;
@@ -548,6 +549,238 @@ impl PersonLookup for PostgresStorage {
Ok(results.iter().sum())
}
+ async fn delete_tombstoned_persons(
+ &self,
+ team_id: i64,
+ uuids: &[Uuid],
+ max_rows: i64,
+ ) -> StorageResult<TombstonedDeleteOutcome> {
+ if uuids.is_empty() {
+ return Ok(TombstonedDeleteOutcome::default());
+ }
+
+ let client = current_client_name();
+ let method = current_method_name();
+ let labels = [
+ (
+ "operation".to_string(),
+ "delete_tombstoned_persons".to_string(),
+ ),
+ ("pool".to_string(), "bulk_primary".to_string()),
+ ("client".to_string(), client.to_string()),
+ ("method".to_string(), method.to_string()),
+ ];
+ let _timer = common_metrics::timing_guard(DB_QUERY_DURATION, &labels);
+
+ // One outcome per uuid: a duplicate must not be counted or reported twice.
+ let mut seen = HashSet::with_capacity(uuids.len());
+ let unique: Vec<Uuid> = uuids.iter().copied().filter(|u| seen.insert(*u)).collect();
+
+ // The caller picks the row budget; the server caps it so no call outlives its deadline.
+ let budget = max_rows.clamp(1, self.tombstoned_delete_max_rows as i64);
+
+ let mut tx = self.bulk_primary_pool.begin().await?;
+ // A held row means a revival or merge in flight: fail fast and let the caller retry. Kept
+ // under the router's 5 s backend deadline so the caller sees an error, not a timeout.
+ sqlx::query("SET LOCAL lock_timeout = '2s'")
+ .execute(&mut *tx)
+ .await?;
+
+ // Resolved without locks. The delete re-checks the tombstone under its row lock, so a
+ // person revived in between drops out and reads as neither deleted nor live.
+ let candidates: Vec<(i64, Uuid)> = sqlx::query!(
+ r#"
+ SELECT id::bigint AS "id!", uuid AS "uuid!"
+ FROM posthog_person
+ WHERE team_id = $1 AND uuid = ANY($2) AND is_deleted
+ ORDER BY id
+ "#,
+ team_id as i32,
+ unique.as_slice()
+ )
+ .fetch_all(&mut *tx)
+ .await?
+ .into_iter()
+ .map(|row| (row.id, row.uuid))
+ .collect();
+
+ let skipped_live: i64 = sqlx::query_scalar!(
+ r#"
+ SELECT count(*) AS "count!"
+ FROM posthog_person
+ WHERE team_id = $1 AND uuid = ANY($2) AND is_deleted = false
+ "#,
+ team_id as i32,
+ unique.as_slice()
+ )
+ .fetch_one(&mut *tx)
+ .await?;
+
+ let mut outcome = TombstonedDeleteOutcome {
+ skipped_live,
+ ..TombstonedDeleteOutcome::default()
+ };
+ if candidates.is_empty() {
+ tx.commit().await?;
+ return Ok(outcome);
+ }
+
+ // Each probe reads at most `remaining + 1` index entries per table per person, so its
+ // cost is bounded by the budget however many rows a person owns.
+ let mut admission = Admission::new(budget, self.bulk_chunk_size);
+ for batch in candidates.chunks(PROBE_BATCH_PERSONS) {
+ if !admission.wants_more() {
+ admission.defer(batch.iter().map(|(_, uuid)| *uuid));
+ continue;
+ }
+ let ids: Vec<i64> = batch.iter().map(|(id, _)| *id).collect();
+ let counts =
+ probe_dependent_rows(&mut *tx, team_id, &ids, admission.probe_limit()).await?;
+ for (id, uuid) in batch {
+ admission.offer(*id, *uuid, counts.get(id).copied().unwrap_or_default());
+ }
+ }
+ let Admission {
+ remaining,
+ admitted,
+ trim,
+ mut pending,
+ ..
+ } = admission;
+
+ // Lock only the persons that are still tombstoned, in id order. READ COMMITTED re-checks
+ // is_deleted on the row version that wins the lock, so a person revived a moment ago
+ // drops out here. Live writers touch live persons, never locked here, and the identity
+ // saga locks persons before distinct ids in this same order.
+ let mut lock_ids: Vec<i64> = admitted.iter().map(|(id, _)| *id).collect();
+ lock_ids.extend(trim.map(|(id, _)| id));
+ let locked: HashSet<i64> = sqlx::query_scalar!(
+ r#"
+ SELECT id::bigint AS "id!"
+ FROM posthog_person
+ WHERE team_id = $1 AND id = ANY($2) AND is_deleted
+ ORDER BY id
+ FOR UPDATE
+ "#,
+ team_id as i32,
+ lock_ids.as_slice()
+ )
+ .fetch_all(&mut *tx)
+ .await?
+ .into_iter()
+ .collect();
+
+ let admitted: Vec<(i64, Uuid)> = admitted
+ .into_iter()
+ .filter(|(id, _)| locked.contains(id))
+ .collect();
+ let admitted_ids: Vec<i64> = admitted.iter().map(|(id, _)| *id).collect();
+
+ // Lock the distinct ids too and read their state under the lock. A live mapping means
+ // ingestion can still reach the person, so it must stay.
+ let mut live_owners: HashSet<i64> = HashSet::new();
+ if !admitted_ids.is_empty() {
+ live_owners = sqlx::query!(
+ r#"
+ SELECT person_id AS "person_id!", is_deleted AS "is_deleted!"
+ FROM posthog_persondistinctid
+ WHERE team_id = $1 AND person_id = ANY($2)
+ ORDER BY id
+ FOR UPDATE
+ "#,
+ team_id as i32,
+ admitted_ids.as_slice()
+ )
+ .fetch_all(&mut *tx)
+ .await?
+ .into_iter()
+ .filter(|row| !row.is_deleted)
+ .map(|row| row.person_id)
+ .collect();
+ }
+
+ let (blocked, victims): (Vec<(i64, Uuid)>, Vec<(i64, Uuid)>) = admitted
+ .into_iter()
+ .partition(|(id, _)| live_owners.contains(id));
+ outcome.blocked_uuids = blocked.into_iter().map(|(_, uuid)| uuid).collect();
+ let victim_ids: Vec<i64> = victims.iter().map(|(id, _)| *id).collect();
+
+ // The hash key override FK cascades in production but not in every environment built
+ // from the sqlx migrations, so remove the overrides here instead of relying on the cascade.
+ if !victim_ids.is_empty() {
+ let overrides = sqlx::query!(
+ "DELETE FROM posthog_featureflaghashkeyoverride WHERE team_id = $1 AND person_id = ANY($2)",
+ team_id as i32,
+ victim_ids.as_slice()
+ )
+ .execute(&mut *tx)
+ .await?;
+ outcome.rows_deleted += overrides.rows_affected() as i64;
+ }
+ let rows =
+ delete_persons_by_ids_in_tx(&mut tx, team_id, &victim_ids, &client, true).await?;
+ outcome.deleted = rows.persons;
+ outcome.rows_deleted += rows.dependents();
+
+ // The first person that did not fit gives up as many rows as the leftover allows and
+ // stays pending, unless it turned out to be live again or to own a live distinct id.
+ if let Some((id, uuid)) = trim {
+ let still_pending = if !locked.contains(&id) {
+ false
+ } else {
+ match trim_locked_person(&mut tx, team_id, id, remaining).await? {
+ Some(rows) => {
+ outcome.rows_deleted += rows;
+ true
+ }
+ None => {
+ outcome.blocked_uuids.push(uuid);
+ false
+ }
+ }
+ };
+ if !still_pending {
+ pending.retain(|u| *u != uuid);
+ }
+ }
+ outcome.pending_uuids = pending;
+
+ tx.commit().await?;
+
+ for (operation, value) in [
+ ("delete_tombstoned_persons_deleted", outcome.deleted),
+ (
+ "delete_tombstoned_persons_skipped_live",
+ outcome.skipped_live,
+ ),
+ (
+ "delete_tombstoned_persons_blocked",
+ outcome.blocked_uuids.len() as i64,
+ ),
+ (
+ "delete_tombstoned_persons_pending",
+ outcome.pending_uuids.len() as i64,
+ ),
+ (
+ "delete_tombstoned_persons_rows_deleted",
+ outcome.rows_deleted,
+ ),
+ ] {
+ common_metrics::histogram(
+ DB_ROWS_RETURNED,
+ &[
+ ("operation".to_string(), operation.to_string()),
+ ("pool".to_string(), "bulk_primary".to_string()),
+ ("client".to_string(), client.to_string()),
+ ("method".to_string(), method.to_string()),
+ ],
+ value as f64,
+ );
+ }
+
+ Ok(outcome)
+ }
+
async fn get_persons_by_distinct_ids_cross_team(
&self,
team_distinct_ids: &[(i64, String)],
@@ -989,6 +1222,41 @@ async fn delete_persons_by_ids_chunk(
let _chunk_timer = common_metrics::timing_guard(DB_QUERY_DURATION, &chunk_labels);
let mut tx = pool.begin().await?;
+ let rows =
+ delete_persons_by_ids_in_tx(&mut tx, team_id, person_ids, client, delete_cohortpeople)
+ .await?;
+ tx.commit().await?;
+
+ Ok(rows.persons)
+}
+
+/// Rows removed by one `delete_persons_by_ids_in_tx` call.
+#[derive(Debug, Clone, Copy, Default)]
+struct PersonRowsDeleted {
+ persons: i64,
+ distinct_ids: i64,
+ cohort_memberships: i64,
+}
+
+impl PersonRowsDeleted {
+ fn dependents(self) -> i64 {
+ self.distinct_ids + self.cohort_memberships
+ }
+}
+
+/// The delete statements every person delete path shares, run inside the caller's
+/// transaction so a tombstone check can hold its row locks across them.
+async fn delete_persons_by_ids_in_tx(
+ tx: &mut Transaction<'_, Postgres>,
+ team_id: i64,
+ person_ids: &[i64],
+ client: &str,
+ delete_cohortpeople: bool,
+) -> StorageResult<PersonRowsDeleted> {
+ if person_ids.is_empty() {
+ return Ok(PersonRowsDeleted::default());
+ }
+ let mut rows = PersonRowsDeleted::default();
// Delete distinct_id rows first — FK is NO ACTION.
let did_result = sqlx::query!(
@@ -999,8 +1267,9 @@ async fn delete_persons_by_ids_chunk(
team_id as i32,
person_ids
)
- .execute(&mut *tx)
+ .execute(&mut **tx)
.await?;
+ rows.distinct_ids = did_result.rows_affected() as i64;
common_metrics::histogram(
DB_ROWS_RETURNED,
@@ -1019,8 +1288,8 @@ async fn delete_persons_by_ids_chunk(
// Cohort memberships have no FK to posthog_person (the constraint was dropped
// during person-table partitioning), so they don't cascade — delete them
// explicitly for these persons. Gated because the team-teardown path already
- // clears cohortpeople up front by cohort; only the per-person DeletePersons
- // path needs this here.
+ // clears cohortpeople up front by cohort; only the per-person delete paths
+ // need this here.
if delete_cohortpeople {
let cohort_result = sqlx::query!(
r#"
@@ -1029,8 +1298,9 @@ async fn delete_persons_by_ids_chunk(
"#,
person_ids
)
- .execute(&mut *tx)
+ .execute(&mut **tx)
.await?;
+ rows.cohort_memberships = cohort_result.rows_affected() as i64;
common_metrics::histogram(
DB_ROWS_RETURNED,
@@ -1056,7 +1326,7 @@ async fn delete_persons_by_ids_chunk(
team_id as i32,
person_ids
)
- .execute(&mut *tx)
+ .execute(&mut **tx)
.await?;
common_metrics::histogram(
@@ -1072,8 +1342,294 @@ async fn delete_persons_by_ids_chunk(
],
result.rows_affected() as f64,
);
+ rows.persons = result.rows_affected() as i64;
- tx.commit().await?;
+ Ok(rows)
+}
+
+/// Persons probed per statement while admitting a request.
+const PROBE_BATCH_PERSONS: usize = 25;
+
+/// Dependent rows of one tombstoned person, each count read with a `LIMIT`, so a probe never
+/// costs more than that many index entries per table however many rows the person owns.
+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
+struct DependentRowCounts {
+ distinct_ids: i64,
+ hash_key_overrides: i64,
+ cohort_memberships: i64,
+}
+
+impl DependentRowCounts {
+ fn total(self) -> i64 {
+ self.distinct_ids + self.hash_key_overrides + self.cohort_memberships
+ }
+}
+
+async fn probe_dependent_rows<'e, E>(
+ executor: E,
+ team_id: i64,
+ person_ids: &[i64],
+ limit: i64,
+) -> StorageResult<HashMap<i64, DependentRowCounts>>
+where
+ E: sqlx::Executor<'e, Database = Postgres>,
+{
+ let rows = sqlx::query!(
+ r#"
+ SELECT p.id AS "id!",
+ (SELECT count(*) FROM (SELECT 1 FROM posthog_persondistinctid
+ WHERE team_id = $1 AND person_id = p.id LIMIT $3) t) AS "distinct_ids!",
+ (SELECT count(*) FROM (SELECT 1 FROM posthog_featureflaghashkeyoverride
+ WHERE team_id = $1 AND person_id = p.id LIMIT $3) t) AS "hash_key_overrides!",
+ (SELECT count(*) FROM (SELECT 1 FROM posthog_cohortpeople
+ WHERE person_id = p.id LIMIT $3) t) AS "cohort_memberships!"
+ FROM unnest($2::bigint[]) AS p(id)
+ "#,
+ team_id as i32,
+ person_ids,
+ limit
+ )
+ .fetch_all(executor)
+ .await?;
+ Ok(rows
+ .into_iter()
+ .map(|row| {
+ (
+ row.id,
+ DependentRowCounts {
+ distinct_ids: row.distinct_ids,
+ hash_key_overrides: row.hash_key_overrides,
+ cohort_memberships: row.cohort_memberships,
+ },
+ )
+ })
+ .collect())
+}
+
+/// Decides, in id order, which candidates one call deletes whole. A person whose dependent rows
+/// fit the leftover budget is admitted, up to `max_persons`; the first that does not fit is kept
+/// for the trim step; every other candidate is pending. Small persons never wait behind a big one.
+#[derive(Debug)]
+struct Admission {
+ remaining: i64,
+ max_persons: usize,
+ admitted: Vec<(i64, Uuid)>,
+ trim: Option<(i64, Uuid)>,
+ pending: Vec<Uuid>,
+}
+
+impl Admission {
+ fn new(budget: i64, max_persons: usize) -> Self {
+ Self {
+ remaining: budget,
+ max_persons,
+ admitted: Vec::new(),
+ trim: None,
+ pending: Vec::new(),
+ }
+ }
+
+ fn wants_more(&self) -> bool {
+ self.admitted.len() < self.max_persons
+ }
+
+ /// One more than the leftover, so a count at the limit reads as "does not fit".
+ fn probe_limit(&self) -> i64 {
+ self.remaining + 1
+ }
+
+ fn offer(&mut self, id: i64, uuid: Uuid, counts: DependentRowCounts) {
+ let total = counts.total();
+ if self.wants_more() && total <= self.remaining {
+ self.remaining -= total;
+ self.admitted.push((id, uuid));
+ return;
+ }
+ if self.trim.is_none() && total > self.remaining {
+ self.trim = Some((id, uuid));
+ }
+ self.pending.push(uuid);
+ }
+
+ fn defer(&mut self, uuids: impl IntoIterator<Item = Uuid>) {
+ self.pending.extend(uuids);
+ }
+}
+
+/// Deletes up to `budget` dependent rows of a person the caller holds locked: distinct ids
+/// first, then hash key overrides, then cohort memberships. Returns the rows deleted, or `None`
+/// when a live distinct id was found, in which case nothing of this person is deleted.
+async fn trim_locked_person(
+ tx: &mut Transaction<'_, Postgres>,
+ team_id: i64,
+ person_id: i64,
+ budget: i64,
+) -> StorageResult<Option<i64>> {
+ // No is_deleted filter: the scan then visits at most `budget` index entries, and a live
+ // mapping among them means ingestion can still reach the person.
+ let mappings = sqlx::query!(
+ r#"
+ SELECT id::bigint AS "id!", is_deleted AS "is_deleted!"
+ FROM posthog_persondistinctid
+ WHERE team_id = $1 AND person_id = $2
+ LIMIT $3
+ FOR UPDATE
+ "#,
+ team_id as i32,
+ person_id,
+ budget
+ )
+ .fetch_all(&mut **tx)
+ .await?;
+ if mappings.iter().any(|row| !row.is_deleted) {
+ return Ok(None);
+ }
- Ok(result.rows_affected() as i64)
+ let mut remaining = budget;
+ let mut deleted = 0i64;
+ if !mappings.is_empty() {
+ let ids: Vec<i64> = mappings.iter().map(|row| row.id).collect();
+ let n = sqlx::query!(
+ "DELETE FROM posthog_persondistinctid WHERE team_id = $1 AND id = ANY($2)",
+ team_id as i32,
+ ids.as_slice()
+ )
+ .execute(&mut **tx)
+ .await?
+ .rows_affected() as i64;
+ deleted += n;
+ remaining -= n;
+ }
+
+ if remaining > 0 {
+ let ids: Vec<i64> = sqlx::query_scalar!(
+ r#"
+ SELECT id::bigint AS "id!"
+ FROM posthog_featureflaghashkeyoverride
+ WHERE team_id = $1 AND person_id = $2
+ LIMIT $3
+ "#,
+ team_id as i32,
+ person_id,
+ remaining
+ )
+ .fetch_all(&mut **tx)
+ .await?;
+ if !ids.is_empty() {
+ let n = sqlx::query!(
+ "DELETE FROM posthog_featureflaghashkeyoverride WHERE team_id = $1 AND id = ANY($2::bigint[])",
+ team_id as i32,
+ ids.as_slice()
+ )
+ .execute(&mut **tx)
+ .await?
+ .rows_affected() as i64;
+ deleted += n;
+ remaining -= n;
+ }
+ }
+
+ if remaining > 0 {
+ let ids: Vec<i64> = sqlx::query_scalar!(
+ r#"
+ SELECT id::bigint AS "id!"
+ FROM posthog_cohortpeople
+ WHERE person_id = $1
+ LIMIT $2
+ "#,
+ person_id,
+ remaining
+ )
+ .fetch_all(&mut **tx)
+ .await?;
+ if !ids.is_empty() {
+ deleted += sqlx::query!(
+ "DELETE FROM posthog_cohortpeople WHERE id = ANY($1)",
+ ids.as_slice()
+ )
+ .execute(&mut **tx)
+ .await?
+ .rows_affected() as i64;
+ }
+ }
+
+ Ok(Some(deleted))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::{Admission, DependentRowCounts};
+ use uuid::Uuid;
+
+ fn counts(
+ distinct_ids: i64,
+ hash_key_overrides: i64,
+ cohort_memberships: i64,
+ ) -> DependentRowCounts {
+ DependentRowCounts {
+ distinct_ids,
+ hash_key_overrides,
+ cohort_memberships,
+ }
+ }
+
+ fn offer_all(admission: &mut Admission, persons: &[(i64, DependentRowCounts)]) -> Vec<Uuid> {
+ let uuids: Vec<Uuid> = persons.iter().map(|_| Uuid::new_v4()).collect();
+ for ((id, c), uuid) in persons.iter().zip(&uuids) {
+ admission.offer(*id, *uuid, *c);
+ }
+ uuids
+ }
+
+ #[test]
+ fn admits_what_fits_and_keeps_the_first_misfit_for_the_trim() {
+ let mut admission = Admission::new(6, 100);
+ let persons = [
+ (1, counts(2, 1, 0)), // fits, 3 left
+ (2, counts(4, 0, 0)), // misfit: the trim candidate
+ (3, counts(0, 0, 3)), // fits exactly, 0 left
+ (4, counts(5, 0, 0)), // misfit, but the trim slot is taken
+ (5, counts(0, 0, 0)), // still fits with nothing left
+ ];
+ let uuids = offer_all(&mut admission, &persons);
+
+ assert_eq!(
+ admission.admitted,
+ vec![(1, uuids[0]), (3, uuids[2]), (5, uuids[4])]
+ );
+ assert_eq!(admission.trim, Some((2, uuids[1])));
+ assert_eq!(admission.pending, vec![uuids[1], uuids[3]]);
+ assert_eq!(admission.remaining, 0);
+ assert_eq!(admission.probe_limit(), 1);
+ }
+
+ #[test]
+ fn the_person_cap_defers_the_rest_without_choosing_a_trim() {
+ let mut admission = Admission::new(10, 2);
+ let persons = [
+ (1, counts(0, 0, 0)),
+ (2, counts(1, 0, 0)),
+ (3, counts(0, 0, 0)),
+ ];
+ let uuids = offer_all(&mut admission, &persons);
+ assert!(!admission.wants_more());
+ let deferred = Uuid::new_v4();
+ admission.defer([deferred]);
+
+ assert_eq!(admission.admitted, vec![(1, uuids[0]), (2, uuids[1])]);
+ assert_eq!(admission.trim, None);
+ assert_eq!(admission.pending, vec![uuids[2], deferred]);
+ assert_eq!(admission.remaining, 9);
+ }
+
+ #[test]
+ fn a_misfit_over_the_cap_is_still_the_trim_candidate() {
+ let mut admission = Admission::new(3, 1);
+ let persons = [(1, counts(0, 0, 0)), (2, counts(4, 0, 0))];
+ let uuids = offer_all(&mut admission, &persons);
+
+ assert_eq!(admission.admitted, vec![(1, uuids[0])]);
+ assert_eq!(admission.trim, Some((2, uuids[1])));
+ assert_eq!(admission.pending, vec![uuids[1]]);
+ }
}
diff --git a/rust/personhog-replica/src/storage/traits/person.rs b/rust/personhog-replica/src/storage/traits/person.rs
index 1eee1e522503..857eb1c1a849 100644
--- a/rust/personhog-replica/src/storage/traits/person.rs
+++ b/rust/personhog-replica/src/storage/traits/person.rs
@@ -2,7 +2,7 @@ use async_trait::async_trait;
use uuid::Uuid;
use crate::storage::error::StorageResult;
-use crate::storage::types::{Person, SplitResult};
+use crate::storage::types::{Person, SplitResult, TombstonedDeleteOutcome};
/// Person lookup operations by ID, UUID, and distinct ID
#[async_trait]
@@ -58,6 +58,17 @@ pub trait PersonLookup: Send + Sync {
/// deleting already-removed UUIDs is a no-op.
async fn delete_persons(&self, team_id: i64, uuids: &[Uuid]) -> StorageResult<i64>;
+ /// Delete persons that are still tombstoned, at most `max_rows` dependent rows per call:
+ /// persons that fit the budget go whole, the first that does not is trimmed with the leftover
+ /// and returned pending, the rest are returned pending untouched. A revival either wins the
+ /// row lock first and is skipped, or lands afterwards on a fresh row. Idempotent.
+ async fn delete_tombstoned_persons(
+ &self,
+ team_id: i64,
+ uuids: &[Uuid],
+ max_rows: i64,
+ ) -> StorageResult<TombstonedDeleteOutcome>;
+
/// Delete up to `batch_size` persons for a team. Selects person IDs with
/// FOR UPDATE SKIP LOCKED, then splits them into fixed-size chunks and
/// deletes concurrently. Each chunk deletes distinct_ids first (FK is
diff --git a/rust/personhog-replica/src/storage/types/person.rs b/rust/personhog-replica/src/storage/types/person.rs
index 96efe5276e67..e3010e72c344 100644
--- a/rust/personhog-replica/src/storage/types/person.rs
+++ b/rust/personhog-replica/src/storage/types/person.rs
@@ -15,6 +15,23 @@ pub struct DistinctIdWithVersion {
pub version: Option<i64>,
}
+/// Outcome of one bounded DeleteTombstonedPersons call. Every requested uuid lands in at most
+/// one bucket; a uuid with no Postgres row, or whose person is live again, lands in none.
+#[derive(Debug, Clone, Default, PartialEq, Eq)]
+pub struct TombstonedDeleteOutcome {
+ /// Persons hard-deleted together with their dependent rows.
+ pub deleted: i64,
+ /// Persons found with is_deleted = false, so revived after the caller queued them. Untouched.
+ pub skipped_live: i64,
+ /// Persons still tombstoned but referenced by a live distinct id. Untouched. Ingestion never
+ /// produces this state, so the caller should surface it rather than retry blindly.
+ pub blocked_uuids: Vec<Uuid>,
+ /// Persons not finished within the row budget; the caller sends them again.
+ pub pending_uuids: Vec<Uuid>,
+ /// Dependent rows deleted by this call.
+ pub rows_deleted: i64,
+}
+
#[derive(Debug, Clone)]
pub struct SplitResult {
pub distinct_id: String,
diff --git a/rust/personhog-replica/tests/common/mod.rs b/rust/personhog-replica/tests/common/mod.rs
index 2841bc404af1..a2f0e588b511 100644
--- a/rust/personhog-replica/tests/common/mod.rs
+++ b/rust/personhog-replica/tests/common/mod.rs
@@ -36,6 +36,7 @@ impl TestContext {
pool.clone(),
50, // bulk_chunk_size — small so parallel path is exercised with fewer test rows
5, // bulk_max_concurrent_chunks
+ 12, // tombstoned_delete_max_rows, small enough that the clamp is observable
));
let team_id = random_team_id();
@@ -218,6 +219,85 @@ impl TestContext {
Ok(())
}
+ /// Mirror the ingestion tombstone: mark the person and its distinct ids deleted, except one
+ /// distinct id that stays live when `live_distinct_id` is given.
+ pub async fn tombstone_person(
+ &self,
+ person_id: i64,
+ live_distinct_id: Option<&str>,
+ ) -> Result<(), sqlx::Error> {
+ sqlx::query(
+ r#"UPDATE posthog_person
+ SET is_deleted = true, version = COALESCE(version, 0) + 1, properties = '{}'
+ WHERE team_id = $1 AND id = $2"#,
+ )
+ .bind(self.team_id)
+ .bind(person_id)
+ .execute(&self.pool)
+ .await?;
+
+ sqlx::query(
+ r#"UPDATE posthog_persondistinctid
+ SET is_deleted = true, version = COALESCE(version, 0) + 1
+ WHERE team_id = $1 AND person_id = $2
+ AND ($3::text IS NULL OR distinct_id <> $3)"#,
+ )
+ .bind(self.team_id)
+ .bind(person_id)
+ .bind(live_distinct_id)
+ .execute(&self.pool)
+ .await?;
+
+ Ok(())
+ }
+
+ pub async fn delete_distinct_ids_of(&self, person_id: i64) -> Result<(), sqlx::Error> {
+ sqlx::query("DELETE FROM posthog_persondistinctid WHERE team_id = $1 AND person_id = $2")
+ .bind(self.team_id)
+ .bind(person_id)
+ .execute(&self.pool)
+ .await?;
+ Ok(())
+ }
+
+ /// True while the row exists in any state; the storage reads hide tombstoned rows.
+ pub async fn person_row_exists(&self, person_id: i64) -> Result<bool, sqlx::Error> {
+ let id: Option<i64> =
+ sqlx::query_scalar("SELECT id FROM posthog_person WHERE team_id = $1 AND id = $2")
+ .bind(self.team_id)
+ .bind(person_id)
+ .fetch_optional(&self.pool)
+ .await?;
+ Ok(id.is_some())
+ }
+
+ pub async fn distinct_id_row_count(&self, person_id: i64) -> Result<i64, sqlx::Error> {
+ sqlx::query_scalar(
+ "SELECT count(*) FROM posthog_persondistinctid WHERE team_id = $1 AND person_id = $2",
+ )
+ .bind(self.team_id)
+ .bind(person_id)
+ .fetch_one(&self.pool)
+ .await
+ }
+
+ pub async fn hash_key_override_count(&self, person_id: i64) -> Result<i64, sqlx::Error> {
+ sqlx::query_scalar(
+ "SELECT count(*) FROM posthog_featureflaghashkeyoverride WHERE team_id = $1 AND person_id = $2",
+ )
+ .bind(self.team_id)
+ .bind(person_id)
+ .fetch_one(&self.pool)
+ .await
+ }
+
+ pub async fn cohort_membership_count(&self, person_id: i64) -> Result<i64, sqlx::Error> {
+ sqlx::query_scalar("SELECT count(*) FROM posthog_cohortpeople WHERE person_id = $1")
+ .bind(person_id)
+ .fetch_one(&self.pool)
+ .await
+ }
+
pub async fn cleanup(&self) -> Result<(), sqlx::Error> {
sqlx::query("DELETE FROM posthog_featureflaghashkeyoverride WHERE team_id = $1")
.bind(self.team_id)
diff --git a/rust/personhog-replica/tests/service_tests.rs b/rust/personhog-replica/tests/service_tests.rs
index 17467920671c..0098011113ce 100644
--- a/rust/personhog-replica/tests/service_tests.rs
+++ b/rust/personhog-replica/tests/service_tests.rs
@@ -5,19 +5,20 @@ use personhog_proto::personhog::replica::v1::person_hog_replica_server::PersonHo
use personhog_proto::personhog::types::v1::{
CheckCohortMembershipRequest, CountGroupTypeMappingsRequest,
DeleteHashKeyOverridesByTeamsRequest, DeletePersonsBatchForTeamRequest,
- GetDistinctIdsForPersonRequest, GetDistinctIdsForPersonsRequest, GetGroupRequest,
- GetGroupTypeMappingsByProjectIdRequest, GetGroupTypeMappingsByProjectIdsRequest,
- GetGroupTypeMappingsByTeamIdRequest, GetGroupTypeMappingsByTeamIdsRequest,
- GetGroupsBatchRequest, GetGroupsRequest, GetHashKeyOverrideContextRequest,
- GetPersonByDistinctIdRequest, GetPersonByUuidRequest, GetPersonRequest,
- GetPersonsByDistinctIdsInTeamRequest, GetPersonsByDistinctIdsRequest, GetPersonsByUuidsRequest,
- GetPersonsRequest, GroupIdentifier, GroupKey, SetPersonDistinctIdVersionFloorRequest,
- SetPersonVersionFloorRequest, SplitPersonRequest, TeamDistinctId,
- UpsertHashKeyOverridesRequest,
+ DeleteTombstonedPersonsRequest, GetDistinctIdsForPersonRequest,
+ GetDistinctIdsForPersonsRequest, GetGroupRequest, GetGroupTypeMappingsByProjectIdRequest,
+ GetGroupTypeMappingsByProjectIdsRequest, GetGroupTypeMappingsByTeamIdRequest,
+ GetGroupTypeMappingsByTeamIdsRequest, GetGroupsBatchRequest, GetGroupsRequest,
+ GetHashKeyOverrideContextRequest, GetPersonByDistinctIdRequest, GetPersonByUuidRequest,
+ GetPersonRequest, GetPersonsByDistinctIdsInTeamRequest, GetPersonsByDistinctIdsRequest,
+ GetPersonsByUuidsRequest, GetPersonsRequest, GroupIdentifier, GroupKey,
+ SetPersonDistinctIdVersionFloorRequest, SetPersonVersionFloorRequest, SplitPersonRequest,
+ TeamDistinctId, UpsertHashKeyOverridesRequest,
};
use personhog_replica::service::PersonHogReplicaService;
use rstest::rstest;
use tonic::Request;
+use uuid::Uuid;
/// Test context that wraps TestContext and adds a service instance.
pub struct ServiceTestContext {
@@ -1252,9 +1253,72 @@ async fn test_delete_hash_key_overrides_by_teams_invalid_batch_size(#[case] batc
}
// ============================================================
-// Delete persons batch for team tests
+// Delete tombstoned persons tests
// ============================================================
+#[rstest]
+#[case::server_default(0, 10)]
+#[case::caller_budget(5, 3)]
+#[tokio::test]
+async fn test_delete_tombstoned_persons_reports_each_outcome(
+ #[case] max_rows: i64,
+ #[case] expected_trimmed: i64,
+) {
+ // The test storage clamps max_rows to 12. The gone and blocked persons take 2 rows of the
+ // budget; the 20-row person is trimmed with what is left and comes back pending.
+ let ctx = ServiceTestContext::new().await;
+ let gone = ctx.insert_person("svc_tomb_gone", None).await.unwrap();
+ ctx.tombstone_person(gone.id, None).await.unwrap();
+ let live = ctx.insert_person("svc_tomb_live", None).await.unwrap();
+ let blocked = ctx.insert_person("svc_tomb_blocked", None).await.unwrap();
+ ctx.tombstone_person(blocked.id, Some("svc_tomb_blocked"))
+ .await
+ .unwrap();
+ let big = ctx.insert_person("svc_tomb_big", None).await.unwrap();
+ for i in 0..19 {
+ ctx.add_distinct_id_to_person(big.id, &format!("svc_tomb_big_{i}"))
+ .await
+ .unwrap();
+ }
+ ctx.tombstone_person(big.id, None).await.unwrap();
+
+ let response = ctx
+ .service
+ .delete_tombstoned_persons(Request::new(DeleteTombstonedPersonsRequest {
+ team_id: ctx.team_id,
+ person_uuids: vec![
+ gone.uuid.to_string(),
+ live.uuid.to_string(),
+ blocked.uuid.to_string(),
+ big.uuid.to_string(),
+ Uuid::now_v7().to_string(),
+ ],
+ max_rows,
+ }))
+ .await
+ .expect("RPC failed")
+ .into_inner();
+
+ assert_eq!(response.deleted_count, 1);
+ assert_eq!(response.skipped_live_count, 1);
+ assert_eq!(
+ response.blocked_person_uuids,
+ vec![blocked.uuid.to_string()]
+ );
+ assert_eq!(response.pending_person_uuids, vec![big.uuid.to_string()]);
+ assert_eq!(response.rows_deleted, 1 + expected_trimmed);
+ assert!(!ctx.person_row_exists(gone.id).await.unwrap());
+ assert!(ctx.person_row_exists(live.id).await.unwrap());
+ assert!(ctx.person_row_exists(blocked.id).await.unwrap());
+ assert!(ctx.person_row_exists(big.id).await.unwrap());
+ assert_eq!(
+ ctx.distinct_id_row_count(big.id).await.unwrap(),
+ 20 - expected_trimmed
+ );
+
+ ctx.cleanup().await.ok();
+}
+
#[tokio::test]
async fn test_delete_persons_batch_for_team() {
let ctx = ServiceTestContext::new().await;
diff --git a/rust/personhog-replica/tests/storage_tests.rs b/rust/personhog-replica/tests/storage_tests.rs
index 822bc0c8ed99..391bf1e92633 100644
--- a/rust/personhog-replica/tests/storage_tests.rs
+++ b/rust/personhog-replica/tests/storage_tests.rs
@@ -2,9 +2,10 @@ mod common;
use common::TestContext;
use personhog_replica::storage::postgres::ConsistencyLevel;
-use personhog_replica::storage::GroupKey;
+use personhog_replica::storage::{GroupKey, TombstonedDeleteOutcome};
use rand::Rng;
use rstest::rstest;
+use std::time::{Duration, Instant};
use uuid::Uuid;
#[tokio::test]
@@ -2856,3 +2857,537 @@ async fn test_set_person_version_floor_missing_person() {
ctx.cleanup().await.ok();
}
+
+// ============================================================
+// Delete tombstoned persons tests
+// ============================================================
+
+/// The test storage clamps max_rows to this many dependent rows per call.
+const TEST_MAX_ROWS: i64 = 12;
+
+/// (distinct ids, hash key overrides, cohort memberships) a person still owns.
+async fn dependent_rows(ctx: &TestContext, person_id: i64) -> (i64, i64, i64) {
+ (
+ ctx.distinct_id_row_count(person_id).await.unwrap(),
+ ctx.hash_key_override_count(person_id).await.unwrap(),
+ ctx.cohort_membership_count(person_id).await.unwrap(),
+ )
+}
+
+#[derive(Debug, Clone, Copy)]
+enum SeededState {
+ Tombstoned,
+ TombstonedWithoutDistinctIds,
+ TombstonedWithLiveDistinctId,
+ Live,
+}
+
+#[rstest]
+#[case::tombstoned(SeededState::Tombstoned, 1, 0, false, 4)]
+#[case::tombstoned_without_distinct_ids(SeededState::TombstonedWithoutDistinctIds, 1, 0, false, 2)]
+#[case::tombstoned_with_live_distinct_id(SeededState::TombstonedWithLiveDistinctId, 0, 0, true, 0)]
+#[case::live(SeededState::Live, 0, 1, false, 0)]
+#[tokio::test]
+async fn test_delete_tombstoned_persons_single_person(
+ #[case] state: SeededState,
+ #[case] expected_deleted: i64,
+ #[case] expected_skipped_live: i64,
+ #[case] expected_blocked: bool,
+ #[case] expected_rows_deleted: i64,
+) {
+ let ctx = TestContext::new().await;
+ let person = ctx.insert_person("tomb_single", None).await.unwrap();
+ ctx.add_distinct_id_to_person(person.id, "tomb_single_2")
+ .await
+ .unwrap();
+ ctx.add_person_to_cohort(person.id, 4242).await.unwrap();
+ ctx.insert_hash_key_override(person.id, "flag-under-test", "hash-under-test")
+ .await
+ .unwrap();
+ match state {
+ SeededState::Tombstoned => ctx.tombstone_person(person.id, None).await.unwrap(),
+ SeededState::TombstonedWithoutDistinctIds => {
+ ctx.tombstone_person(person.id, None).await.unwrap();
+ ctx.delete_distinct_ids_of(person.id).await.unwrap();
+ }
+ SeededState::TombstonedWithLiveDistinctId => ctx
+ .tombstone_person(person.id, Some("tomb_single_2"))
+ .await
+ .unwrap(),
+ SeededState::Live => {}
+ }
+ let rows_kept = expected_deleted == 0;
+ let rows_before = dependent_rows(&ctx, person.id).await;
+
+ let outcome = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &[person.uuid], TEST_MAX_ROWS)
+ .await
+ .expect("Failed to delete tombstoned persons");
+
+ assert_eq!(
+ outcome,
+ TombstonedDeleteOutcome {
+ deleted: expected_deleted,
+ skipped_live: expected_skipped_live,
+ blocked_uuids: if expected_blocked {
+ vec![person.uuid]
+ } else {
+ vec![]
+ },
+ pending_uuids: vec![],
+ rows_deleted: expected_rows_deleted,
+ }
+ );
+ assert_eq!(ctx.person_row_exists(person.id).await.unwrap(), rows_kept);
+ assert_eq!(
+ dependent_rows(&ctx, person.id).await,
+ if rows_kept { rows_before } else { (0, 0, 0) }
+ );
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_delete_tombstoned_persons_trims_a_person_over_the_budget_until_it_fits() {
+ // 7 distinct ids, 3 overrides and 4 cohort rows against a budget of 4: distinct ids go
+ // first, then overrides, then cohort rows, and the fourth call deletes the person whole.
+ let ctx = TestContext::new().await;
+ let person = ctx.insert_person("tomb_trim", None).await.unwrap();
+ for i in 0..6 {
+ ctx.add_distinct_id_to_person(person.id, &format!("tomb_trim_{i}"))
+ .await
+ .unwrap();
+ }
+ for i in 0..3 {
+ ctx.insert_hash_key_override(person.id, &format!("flag-{i}"), "hash")
+ .await
+ .unwrap();
+ }
+ for cohort_id in 5000..5004 {
+ ctx.add_person_to_cohort(person.id, cohort_id)
+ .await
+ .unwrap();
+ }
+ ctx.tombstone_person(person.id, None).await.unwrap();
+ let uuids = [person.uuid];
+ let call = || {
+ ctx.storage
+ .delete_tombstoned_persons(ctx.team_id, &uuids, 4)
+ };
+ let pending = |rows_deleted| TombstonedDeleteOutcome {
+ pending_uuids: vec![person.uuid],
+ rows_deleted,
+ ..TombstonedDeleteOutcome::default()
+ };
+
+ assert_eq!(call().await.unwrap(), pending(4));
+ assert_eq!(dependent_rows(&ctx, person.id).await, (3, 3, 4));
+ assert_eq!(call().await.unwrap(), pending(4));
+ assert_eq!(dependent_rows(&ctx, person.id).await, (0, 2, 4));
+ assert_eq!(call().await.unwrap(), pending(4));
+ assert_eq!(dependent_rows(&ctx, person.id).await, (0, 0, 2));
+ assert_eq!(
+ call().await.unwrap(),
+ TombstonedDeleteOutcome {
+ deleted: 1,
+ rows_deleted: 2,
+ ..TombstonedDeleteOutcome::default()
+ }
+ );
+ assert_eq!(dependent_rows(&ctx, person.id).await, (0, 0, 0));
+ assert!(!ctx.person_row_exists(person.id).await.unwrap());
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_delete_tombstoned_persons_converges_in_ceil_rows_over_budget_calls() {
+ // A 30-row person against a budget of 2 converges in ceil(30 / 2) calls: 14 trim calls, then
+ // the last two rows fit and the fifteenth call deletes the person whole. Never blocked.
+ let ctx = TestContext::new().await;
+ let person = ctx.insert_person("tomb_steps", None).await.unwrap();
+ for i in 0..29 {
+ ctx.add_distinct_id_to_person(person.id, &format!("tomb_steps_{i}"))
+ .await
+ .unwrap();
+ }
+ ctx.tombstone_person(person.id, None).await.unwrap();
+
+ let mut calls = 0;
+ loop {
+ let outcome = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &[person.uuid], 2)
+ .await
+ .unwrap();
+ calls += 1;
+ assert!(outcome.blocked_uuids.is_empty());
+ if outcome.pending_uuids.is_empty() {
+ assert_eq!((outcome.deleted, outcome.rows_deleted), (1, 2));
+ break;
+ }
+ assert_eq!(
+ (outcome.pending_uuids.clone(), outcome.rows_deleted),
+ (vec![person.uuid], 2)
+ );
+ assert!(calls < 15, "the person did not converge");
+ }
+
+ assert_eq!(calls, 15);
+ assert!(!ctx.person_row_exists(person.id).await.unwrap());
+ assert_eq!(ctx.distinct_id_row_count(person.id).await.unwrap(), 0);
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_delete_tombstoned_persons_blocks_a_person_over_the_budget_that_owns_a_live_distinct_id(
+) {
+ // 3 distinct ids (one live) and 10 cohort rows: over the budget of 12, so the trim step
+ // reads every distinct id, finds the live one and deletes nothing.
+ let ctx = TestContext::new().await;
+ let person = ctx.insert_person("tomb_big_live", None).await.unwrap();
+ for i in 0..2 {
+ ctx.add_distinct_id_to_person(person.id, &format!("tomb_big_live_{i}"))
+ .await
+ .unwrap();
+ }
+ for cohort_id in 6000..6010 {
+ ctx.add_person_to_cohort(person.id, cohort_id)
+ .await
+ .unwrap();
+ }
+ ctx.tombstone_person(person.id, Some("tomb_big_live"))
+ .await
+ .unwrap();
+
+ let outcome = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &[person.uuid], TEST_MAX_ROWS)
+ .await
+ .unwrap();
+
+ assert_eq!(
+ outcome,
+ TombstonedDeleteOutcome {
+ blocked_uuids: vec![person.uuid],
+ ..TombstonedDeleteOutcome::default()
+ }
+ );
+ assert_eq!(dependent_rows(&ctx, person.id).await, (3, 0, 10));
+ assert!(ctx.person_row_exists(person.id).await.unwrap());
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_delete_tombstoned_persons_mixed_batch_deletes_the_small_persons_and_trims_the_big_one(
+) {
+ // Budget 12, ids in random order: the five one-row persons and the one-row blocked person
+ // are admitted (6 rows), the 20-row person is trimmed with the 6 rows left and comes back
+ // pending.
+ let ctx = TestContext::new().await;
+ let big = ctx.insert_person("tomb_mixed_big", None).await.unwrap();
+ for i in 0..19 {
+ ctx.add_distinct_id_to_person(big.id, &format!("tomb_mixed_big_{i}"))
+ .await
+ .unwrap();
+ }
+ ctx.tombstone_person(big.id, None).await.unwrap();
+ let mut small = Vec::new();
+ for i in 0..5 {
+ let person = ctx
+ .insert_person(&format!("tomb_mixed_s_{i}"), None)
+ .await
+ .unwrap();
+ ctx.tombstone_person(person.id, None).await.unwrap();
+ small.push(person);
+ }
+ let mut live = Vec::new();
+ for i in 0..3 {
+ live.push(
+ ctx.insert_person(&format!("tomb_mixed_l_{i}"), None)
+ .await
+ .unwrap(),
+ );
+ }
+ let blocked = ctx.insert_person("tomb_mixed_b", None).await.unwrap();
+ ctx.tombstone_person(blocked.id, Some("tomb_mixed_b"))
+ .await
+ .unwrap();
+ let mut uuids: Vec<Uuid> = small.iter().chain(live.iter()).map(|p| p.uuid).collect();
+ uuids.extend([big.uuid, blocked.uuid, Uuid::now_v7(), Uuid::now_v7()]);
+ // One duplicate per bucket: none may be counted or reported twice.
+ uuids.extend([small[0].uuid, live[0].uuid, blocked.uuid, big.uuid]);
+ uuids.reverse();
+
+ let outcome = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &uuids, TEST_MAX_ROWS)
+ .await
+ .expect("Failed to delete tombstoned persons");
+
+ assert_eq!(
+ outcome,
+ TombstonedDeleteOutcome {
+ deleted: 5,
+ skipped_live: 3,
+ blocked_uuids: vec![blocked.uuid],
+ pending_uuids: vec![big.uuid],
+ rows_deleted: 11,
+ }
+ );
+ for person in &small {
+ assert!(!ctx.person_row_exists(person.id).await.unwrap());
+ }
+ for person in live.iter().chain([&blocked, &big]) {
+ assert!(ctx.person_row_exists(person.id).await.unwrap());
+ }
+ assert_eq!(ctx.distinct_id_row_count(big.id).await.unwrap(), 14);
+ assert_eq!(ctx.distinct_id_row_count(blocked.id).await.unwrap(), 1);
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_delete_tombstoned_persons_leaves_later_persons_pending_once_the_budget_is_spent() {
+ // In id order against a budget of 4: a 3-row person fits, a 2-row person does not and is
+ // trimmed with the 1 row left, the next 2-row person is left untouched, a 0-row person fits.
+ let ctx = TestContext::new().await;
+ let mut persons = Vec::new();
+ for i in 0..4 {
+ persons.push(
+ ctx.insert_person(&format!("tomb_order_{i}"), None)
+ .await
+ .unwrap(),
+ );
+ }
+ persons.sort_by_key(|p| p.id);
+ for i in 0..2 {
+ ctx.add_distinct_id_to_person(persons[0].id, &format!("tomb_order_first_{i}"))
+ .await
+ .unwrap();
+ }
+ ctx.add_distinct_id_to_person(persons[1].id, "tomb_order_second_x")
+ .await
+ .unwrap();
+ ctx.add_distinct_id_to_person(persons[2].id, "tomb_order_third_x")
+ .await
+ .unwrap();
+ for person in &persons {
+ ctx.tombstone_person(person.id, None).await.unwrap();
+ }
+ ctx.delete_distinct_ids_of(persons[3].id).await.unwrap();
+ let uuids: Vec<Uuid> = persons.iter().map(|p| p.uuid).collect();
+
+ let outcome = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &uuids, 4)
+ .await
+ .unwrap();
+
+ assert_eq!(
+ outcome,
+ TombstonedDeleteOutcome {
+ deleted: 2,
+ pending_uuids: vec![persons[1].uuid, persons[2].uuid],
+ rows_deleted: 4,
+ ..TombstonedDeleteOutcome::default()
+ }
+ );
+ assert!(!ctx.person_row_exists(persons[0].id).await.unwrap());
+ assert!(!ctx.person_row_exists(persons[3].id).await.unwrap());
+ assert_eq!(ctx.distinct_id_row_count(persons[1].id).await.unwrap(), 1);
+ assert_eq!(ctx.distinct_id_row_count(persons[2].id).await.unwrap(), 2);
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_delete_tombstoned_persons_caps_the_persons_deleted_per_call() {
+ // The test storage deletes at most 50 persons per call (bulk_chunk_size): the two highest
+ // ids come back pending and untouched, and a second call with them finishes the request.
+ let ctx = TestContext::new().await;
+ let mut persons = Vec::new();
+ for i in 0..52 {
+ let person = ctx
+ .insert_person(&format!("tomb_cap_{i}"), None)
+ .await
+ .unwrap();
+ ctx.tombstone_person(person.id, None).await.unwrap();
+ ctx.delete_distinct_ids_of(person.id).await.unwrap();
+ persons.push(person);
+ }
+ persons.sort_by_key(|p| p.id);
+ let uuids: Vec<Uuid> = persons.iter().map(|p| p.uuid).collect();
+
+ let first = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &uuids, TEST_MAX_ROWS)
+ .await
+ .unwrap();
+ assert_eq!(
+ first,
+ TombstonedDeleteOutcome {
+ deleted: 50,
+ pending_uuids: vec![persons[50].uuid, persons[51].uuid],
+ ..TombstonedDeleteOutcome::default()
+ }
+ );
+ assert!(ctx.person_row_exists(persons[50].id).await.unwrap());
+ assert!(ctx.person_row_exists(persons[51].id).await.unwrap());
+
+ let second = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &first.pending_uuids, TEST_MAX_ROWS)
+ .await
+ .unwrap();
+ assert_eq!(
+ second,
+ TombstonedDeleteOutcome {
+ deleted: 2,
+ ..TombstonedDeleteOutcome::default()
+ }
+ );
+ for person in &persons {
+ assert!(!ctx.person_row_exists(person.id).await.unwrap());
+ }
+
+ ctx.cleanup().await.ok();
+}
+
+#[rstest]
+#[case::above_the_maximum(1_000_000, TEST_MAX_ROWS)]
+#[case::zero(0, 1)]
+#[case::negative(-5, 1)]
+#[tokio::test]
+async fn test_delete_tombstoned_persons_clamps_max_rows(
+ #[case] max_rows: i64,
+ #[case] expected_rows: i64,
+) {
+ let ctx = TestContext::new().await;
+ let person = ctx.insert_person("tomb_clamp", None).await.unwrap();
+ for i in 0..19 {
+ ctx.add_distinct_id_to_person(person.id, &format!("tomb_clamp_{i}"))
+ .await
+ .unwrap();
+ }
+ ctx.tombstone_person(person.id, None).await.unwrap();
+
+ let outcome = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &[person.uuid], max_rows)
+ .await
+ .unwrap();
+
+ assert_eq!(
+ outcome,
+ TombstonedDeleteOutcome {
+ pending_uuids: vec![person.uuid],
+ rows_deleted: expected_rows,
+ ..TombstonedDeleteOutcome::default()
+ }
+ );
+ assert_eq!(
+ ctx.distinct_id_row_count(person.id).await.unwrap(),
+ 20 - expected_rows
+ );
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_delete_tombstoned_persons_second_call_is_a_no_op() {
+ let ctx = TestContext::new().await;
+ let person = ctx.insert_person("tomb_idem", None).await.unwrap();
+ ctx.tombstone_person(person.id, None).await.unwrap();
+
+ let first = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &[person.uuid], TEST_MAX_ROWS)
+ .await
+ .expect("Failed to delete tombstoned persons");
+ assert_eq!(first.deleted, 1);
+
+ let second = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &[person.uuid], TEST_MAX_ROWS)
+ .await
+ .expect("Failed to delete tombstoned persons");
+ assert_eq!(second, TombstonedDeleteOutcome::default());
+
+ ctx.cleanup().await.ok();
+}
+
+#[rstest]
+#[case::empty(vec![])]
+#[case::unknown(vec![Uuid::now_v7(), Uuid::now_v7()])]
+#[tokio::test]
+async fn test_delete_tombstoned_persons_nothing_to_do(#[case] uuids: Vec<Uuid>) {
+ let ctx = TestContext::new().await;
+
+ let outcome = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &uuids, TEST_MAX_ROWS)
+ .await
+ .expect("Failed to delete tombstoned persons");
+
+ assert_eq!(outcome, TombstonedDeleteOutcome::default());
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_delete_tombstoned_persons_cross_team_isolation() {
+ let ctx = TestContext::new().await;
+ let other = TestContext::new().await;
+ let person = other.insert_person("tomb_other_team", None).await.unwrap();
+ other.tombstone_person(person.id, None).await.unwrap();
+
+ let outcome = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &[person.uuid], TEST_MAX_ROWS)
+ .await
+ .expect("Failed to delete tombstoned persons");
+
+ assert_eq!(outcome, TombstonedDeleteOutcome::default());
+ assert!(other.person_row_exists(person.id).await.unwrap());
+
+ ctx.cleanup().await.ok();
+ other.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_delete_tombstoned_persons_gives_up_when_a_writer_holds_the_row() {
+ // lock_timeout makes the request fail fast behind a held row; without it this call would
+ // block until the holder commits.
+ let ctx = TestContext::new().await;
+ let person = ctx.insert_person("tomb_locked", None).await.unwrap();
+ ctx.tombstone_person(person.id, None).await.unwrap();
+ let mut holder = ctx.pool.begin().await.unwrap();
+ sqlx::query("SELECT id FROM posthog_person WHERE team_id = $1 AND id = $2 FOR UPDATE")
+ .bind(ctx.team_id)
+ .bind(person.id)
+ .execute(&mut *holder)
+ .await
+ .unwrap();
+
+ let started = Instant::now();
+ let result = ctx
+ .storage
+ .delete_tombstoned_persons(ctx.team_id, &[person.uuid], TEST_MAX_ROWS)
+ .await;
+
+ assert!(
+ matches!(
+ result,
+ Err(personhog_replica::storage::StorageError::Query(_))
+ ),
+ "expected the lock_timeout to fail the chunk, got {result:?}"
+ );
+ assert!(started.elapsed() < Duration::from_secs(20));
+ holder.rollback().await.unwrap();
+ assert!(ctx.person_row_exists(person.id).await.unwrap());
+
+ ctx.cleanup().await.ok();
+}
diff --git a/rust/personhog-router/src/proxy.rs b/rust/personhog-router/src/proxy.rs
index 5a6049ec0079..c426d520cce2 100644
--- a/rust/personhog-router/src/proxy.rs
+++ b/rust/personhog-router/src/proxy.rs
@@ -39,6 +39,7 @@ pub const KNOWN_METHODS: &[&str] = &[
"DeleteHashKeyOverridesByTeams",
"DeletePersons",
"DeletePersonsBatchForTeam",
+ "DeleteTombstonedPersons",
"FencePerson",
"FencePersons",
"FoldPersonDocument",
diff --git a/rust/personhog-router/tests/common/mod.rs b/rust/personhog-router/tests/common/mod.rs
index bb27979abe60..13ade3e60f88 100644
--- a/rust/personhog-router/tests/common/mod.rs
+++ b/rust/personhog-router/tests/common/mod.rs
@@ -33,6 +33,7 @@ use personhog_proto::personhog::types::v1::{
DeleteGroupsBatchForTeamResponse, DeleteHashKeyOverridesByTeamsRequest,
DeleteHashKeyOverridesByTeamsResponse, DeletePersonsBatchForTeamRequest,
DeletePersonsBatchForTeamResponse, DeletePersonsRequest, DeletePersonsResponse,
+ DeleteTombstonedPersonsRequest, DeleteTombstonedPersonsResponse,
GetDistinctIdsForPersonRequest, GetDistinctIdsForPersonResponse,
GetDistinctIdsForPersonsRequest, GetDistinctIdsForPersonsResponse, GetGroupRequest,
GetGroupResponse, GetGroupTypeMappingByDashboardIdRequest,
@@ -454,6 +455,13 @@ impl PersonHogReplica for TestReplicaService {
}))
}
+ async fn delete_tombstoned_persons(
+ &self,
+ _request: Request<DeleteTombstonedPersonsRequest>,
+ ) -> Result<Response<DeleteTombstonedPersonsResponse>, Status> {
+ Ok(Response::new(DeleteTombstonedPersonsResponse::default()))
+ }
+
async fn split_person(
&self,
_request: Request<SplitPersonRequest>,
diff --git a/rust/property-defs-rs/tests/group_type_resolver.rs b/rust/property-defs-rs/tests/group_type_resolver.rs
index d0720096f517..4775cdcd08ff 100644
--- a/rust/property-defs-rs/tests/group_type_resolver.rs
+++ b/rust/property-defs-rs/tests/group_type_resolver.rs
@@ -352,6 +352,13 @@ impl PersonHogService for MockPersonHogService {
) -> Result<Response<DeletePersonsBatchForTeamResponse>, Status> {
Err(Status::unimplemented(""))
}
+
+ async fn delete_tombstoned_persons(
+ &self,
+ _: Request<DeleteTombstonedPersonsRequest>,
+ ) -> Result<Response<DeleteTombstonedPersonsResponse>, Status> {
+ Err(Status::unimplemented(""))
+ }
async fn get_group_type_mapping_by_dashboard_id(
&self,
_: Request<GetGroupTypeMappingByDashboardIdRequest>,