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.

chore(data-warehouse): remove dwh-postgres-xmin feature flag (#71588)

Daniel RC8cf6a52fef2b
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index b492e6e724ad..acaf11067327 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -295,7 +295,6 @@ export const FEATURE_FLAGS = {
DROP_PERSON_LIST_ORDER_BY: 'drop-person-list-order-by', // owner: @arthurdedeus #team-customer-analytics
DWH_JOIN_TABLE_PREVIEW: 'dwh-join-table-preview', // owner: @arthurdedeus #team-customer-analytics
DWH_POSTGRES_CDC: 'dwh-postgres-cdc', // owner: #team-warehouse-sources
- DWH_POSTGRES_XMIN: 'dwh-postgres-xmin', // owner: #team-warehouse-sources
DWH_SOURCE_METRICS: 'dwh-source-metrics', // owner: #team-warehouse-sources
EDITOR_DRAFTS: 'editor-drafts', // owner: @EDsCODE #team-data-tools
ENDPOINTS: 'embedded-analytics', // owner: @sakce #team-clickhouse
diff --git a/products/data_warehouse/backend/facade/api.py b/products/data_warehouse/backend/facade/api.py
index 8b45647d896f..cb0a8e16808e 100644
--- a/products/data_warehouse/backend/facade/api.py
+++ b/products/data_warehouse/backend/facade/api.py
@@ -39,7 +39,6 @@ _LAZY = {
"is_any_external_data_schema_paused": "logic.data_load.service",
"is_cdc_enabled_for_team": "logic.data_load.service",
"is_custom_source_ai_builder_enabled_for_team": "logic.data_load.service",
- "is_xmin_enabled_for_team": "logic.data_load.service",
"pause_cdc_extraction_schedule": "logic.data_load.service",
"pause_external_data_schedule": "logic.data_load.service",
"sync_cdc_extraction_schedule": "logic.data_load.service",
diff --git a/products/data_warehouse/backend/logic/data_load/service.py b/products/data_warehouse/backend/logic/data_load/service.py
index a98fabbfd887..2d68ec19ce6b 100644
--- a/products/data_warehouse/backend/logic/data_load/service.py
+++ b/products/data_warehouse/backend/logic/data_load/service.py
@@ -410,15 +410,6 @@ def is_cdc_enabled_for_team(team: Team) -> bool:
)
-def is_xmin_enabled_for_team(team: Team) -> bool:
- return feature_enabled_or_false(
- "dwh-postgres-xmin",
- str(team.organization_id),
- groups={"organization": str(team.organization_id)},
- group_properties={"organization": {"id": str(team.organization_id)}},
- )
-
-
def is_custom_source_ai_builder_enabled_for_team(team: Team) -> bool:
return feature_enabled_or_false(
"dwh-custom-source-ai-builder",
diff --git a/products/data_warehouse/backend/presentation/views/external_data_schema.py b/products/data_warehouse/backend/presentation/views/external_data_schema.py
index 9897ad70f93b..ebf7ac430e4e 100644
--- a/products/data_warehouse/backend/presentation/views/external_data_schema.py
+++ b/products/data_warehouse/backend/presentation/views/external_data_schema.py
@@ -34,7 +34,6 @@ from products.data_warehouse.backend.facade.api import (
hide_direct_snowflake_table,
is_any_external_data_schema_paused,
is_cdc_enabled_for_team,
- is_xmin_enabled_for_team,
pause_external_data_schedule,
reconcile_webhook_events,
reproject_direct_mysql_table,
@@ -711,17 +710,12 @@ class ExternalDataSchemaSerializer(serializers.ModelSerializer):
raise ValidationError("CDC is not enabled for this team")
# Close the enum-exposure window: `XMIN` is a valid `SyncType` choice, so the field accepts
- # "xmin" the moment the foundation lands. Reject it unless the source is Postgres, the flag is
- # on for the team, and the table actually advertises xmin support — otherwise a raw PATCH would
- # persist an xmin schema that silently degrades to full_refresh.
+ # "xmin" the moment the foundation lands. Reject it unless the source is Postgres and the table
+ # actually advertises xmin support — otherwise a raw PATCH would persist an xmin schema that
+ # silently degrades to full_refresh.
if sync_type == ExternalDataSchema.SyncType.XMIN:
- from posthog.models import Team
-
if instance.source.source_type != ExternalDataSourceType.POSTGRES:
raise ValidationError("xmin replication is only available for Postgres sources.")
- team = Team.objects.get(id=self.context["team_id"])
- if not is_xmin_enabled_for_team(team):
- raise ValidationError("xmin replication is not enabled for this team")
if not self._xmin_available_for_schema(instance):
raise ValidationError(
f"xmin replication is not available for table '{instance.name}'. "
@@ -1611,12 +1605,8 @@ class ExternalDataSchemaViewset(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
# strings, so bool(...) would treat "False" as truthy. str_to_bool decodes both.
source_cdc_enabled = str_to_bool(source.job_inputs.get("cdc_enabled"))
cdc_available = schema.supports_cdc if is_cdc_enabled_for_team(self.team) and source_cdc_enabled else None
- # xmin is Postgres-only AND flag-gated, mirroring the database_schema endpoint.
- xmin_available = (
- schema.supports_xmin
- if (source.source_type == ExternalDataSourceType.POSTGRES and is_xmin_enabled_for_team(self.team))
- else None
- )
+ # xmin is Postgres-only, mirroring the database_schema endpoint.
+ xmin_available = schema.supports_xmin if source.source_type == ExternalDataSourceType.POSTGRES else None
data = {
"incremental_fields": schema.incremental_fields,
diff --git a/products/data_warehouse/backend/presentation/views/external_data_source.py b/products/data_warehouse/backend/presentation/views/external_data_source.py
index f943df559c76..4a69ac0996a5 100644
--- a/products/data_warehouse/backend/presentation/views/external_data_source.py
+++ b/products/data_warehouse/backend/presentation/views/external_data_source.py
@@ -87,7 +87,6 @@ from products.data_warehouse.backend.facade.api import (
is_cdc_enabled_for_team,
is_custom_source_ai_builder_enabled_for_team,
is_multi_schema_capable_sql_source,
- is_xmin_enabled_for_team,
reconcile_github_repositories,
reconcile_mysql_schemas,
reconcile_postgres_schemas,
@@ -3161,7 +3160,6 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi
# which makes a network round-trip per call. With large schema lists (e.g. Slack workspaces with
# thousands of channels) the per-iteration call inflated the response loop past the 120s gateway.
cdc_enabled = is_cdc_enabled_for_team(self.team)
- xmin_enabled = is_xmin_enabled_for_team(self.team)
# xmin is Postgres-only — gate on the source type so the capability never leaks to another SQL source.
is_postgres = source_type_model == ExternalDataSourceType.POSTGRES
data = [
@@ -3173,7 +3171,7 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi
"incremental_available": schema.supports_incremental,
"append_available": schema.supports_append,
"cdc_available": schema.supports_cdc if cdc_enabled else None,
- "xmin_available": schema.supports_xmin if (is_postgres and xmin_enabled) else None,
+ "xmin_available": schema.supports_xmin if is_postgres else None,
"incremental_field": schema.incremental_fields[0]["field"]
if len(schema.incremental_fields) > 0 and len(schema.incremental_fields[0]["field"]) > 0
else None,
diff --git a/products/data_warehouse/backend/tests/api/test_external_data_schema.py b/products/data_warehouse/backend/tests/api/test_external_data_schema.py
index f93c00a7b96d..21f09e58b9c0 100644
--- a/products/data_warehouse/backend/tests/api/test_external_data_schema.py
+++ b/products/data_warehouse/backend/tests/api/test_external_data_schema.py
@@ -232,7 +232,7 @@ class TestExternalDataSchema(APIBaseTest):
"incremental_available": True,
"append_available": True,
"cdc_available": None,
- "xmin_available": None,
+ "xmin_available": True,
"full_refresh_available": True,
"supports_webhooks": False,
"webhook_only": False,
@@ -351,10 +351,6 @@ class TestExternalDataSchema(APIBaseTest):
with (
mock.patch.object(source_impl, "validate_credentials", return_value=(True, None)),
mock.patch.object(source_impl, "get_schemas", return_value=[fake_schema]),
- mock.patch(
- "products.data_warehouse.backend.presentation.views.external_data_schema.is_xmin_enabled_for_team",
- return_value=True,
- ),
):
response = self.client.post(
f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}/incremental_fields",
@@ -916,7 +912,7 @@ class TestExternalDataSchema(APIBaseTest):
)
@staticmethod
- def _xmin_discovery_patches(supports_xmin: bool = True, flag_enabled: bool = True):
+ def _xmin_discovery_patch(supports_xmin: bool = True):
from products.warehouse_sources.backend.temporal.data_imports.sources.postgres.source import PostgresSource
fake_schema = SourceSchema(
@@ -928,13 +924,7 @@ class TestExternalDataSchema(APIBaseTest):
columns=[("id", "integer", False)],
detected_primary_keys=["id"],
)
- return (
- mock.patch.object(PostgresSource, "get_schemas", return_value=[fake_schema]),
- mock.patch(
- "products.data_warehouse.backend.presentation.views.external_data_schema.is_xmin_enabled_for_team",
- return_value=flag_enabled,
- ),
- )
+ return mock.patch.object(PostgresSource, "get_schemas", return_value=[fake_schema])
def test_update_schema_to_xmin_succeeds_with_primary_key(self):
source = self._xmin_postgres_source()
@@ -947,8 +937,7 @@ class TestExternalDataSchema(APIBaseTest):
sync_type_config={},
)
- get_schemas_patch, flag_patch = self._xmin_discovery_patches()
- with get_schemas_patch, flag_patch:
+ with self._xmin_discovery_patch():
response = self.client.patch(
f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}",
data={"sync_type": "xmin", "primary_key_columns": ["id"]},
@@ -972,8 +961,7 @@ class TestExternalDataSchema(APIBaseTest):
sync_type_config={},
)
- get_schemas_patch, flag_patch = self._xmin_discovery_patches()
- with get_schemas_patch, flag_patch:
+ with self._xmin_discovery_patch():
response = self.client.patch(
f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}",
data={"sync_type": "xmin"},
@@ -999,14 +987,10 @@ class TestExternalDataSchema(APIBaseTest):
sync_type_config={"primary_key_columns": ["id"]},
)
- with mock.patch(
- "products.data_warehouse.backend.presentation.views.external_data_schema.is_xmin_enabled_for_team",
- return_value=True,
- ):
- response = self.client.patch(
- f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}",
- data={"sync_type": "xmin", "primary_key_columns": ["id"]},
- )
+ response = self.client.patch(
+ f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}",
+ data={"sync_type": "xmin", "primary_key_columns": ["id"]},
+ )
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert "postgres" in str(response.json()).lower()
@@ -1025,8 +1009,7 @@ class TestExternalDataSchema(APIBaseTest):
sync_type_config={"primary_key_columns": ["id"]},
)
- get_schemas_patch, flag_patch = self._xmin_discovery_patches(supports_xmin=False)
- with get_schemas_patch, flag_patch:
+ with self._xmin_discovery_patch(supports_xmin=False):
response = self.client.patch(
f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}",
data={"sync_type": "xmin", "primary_key_columns": ["id"]},
@@ -1037,29 +1020,6 @@ class TestExternalDataSchema(APIBaseTest):
schema.refresh_from_db()
assert schema.sync_type == ExternalDataSchema.SyncType.FULL_REFRESH
- def test_update_schema_to_xmin_rejected_when_flag_disabled(self):
- source = self._xmin_postgres_source()
- schema = ExternalDataSchema.objects.create(
- name="public.orders",
- team=self.team,
- source=source,
- should_sync=False,
- sync_type=ExternalDataSchema.SyncType.FULL_REFRESH,
- sync_type_config={"primary_key_columns": ["id"]},
- )
-
- get_schemas_patch, flag_patch = self._xmin_discovery_patches(flag_enabled=False)
- with get_schemas_patch, flag_patch:
- response = self.client.patch(
- f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}",
- data={"sync_type": "xmin", "primary_key_columns": ["id"]},
- )
-
- assert response.status_code == status.HTTP_400_BAD_REQUEST
- assert "not enabled" in str(response.json()).lower()
- schema.refresh_from_db()
- assert schema.sync_type == ExternalDataSchema.SyncType.FULL_REFRESH
-
def test_update_schema_xmin_accepts_row_filters(self):
source = self._xmin_postgres_source()
schema = ExternalDataSchema.objects.create(
@@ -1074,8 +1034,7 @@ class TestExternalDataSchema(APIBaseTest):
},
)
- get_schemas_patch, flag_patch = self._xmin_discovery_patches()
- with get_schemas_patch, flag_patch:
+ with self._xmin_discovery_patch():
response = self.client.patch(
f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}",
data={"row_filters": [{"column": "id", "operator": ">", "value": "5"}]},
@@ -1105,10 +1064,8 @@ class TestExternalDataSchema(APIBaseTest):
sync_type_config={"primary_key_columns": ["id"]},
)
- get_schemas_patch, flag_patch = self._xmin_discovery_patches()
with (
- get_schemas_patch,
- flag_patch,
+ self._xmin_discovery_patch(),
mock.patch(
"products.data_warehouse.backend.presentation.views.external_data_schema.external_data_workflow_exists",
return_value=False,
@@ -1142,10 +1099,8 @@ class TestExternalDataSchema(APIBaseTest):
table=table,
)
- get_schemas_patch, flag_patch = self._xmin_discovery_patches()
with (
- get_schemas_patch,
- flag_patch,
+ self._xmin_discovery_patch(),
mock.patch(
"products.data_warehouse.backend.presentation.views.external_data_schema.trigger_external_data_workflow"
) as mock_trigger,
diff --git a/products/data_warehouse/backend/tests/api/test_external_data_source.py b/products/data_warehouse/backend/tests/api/test_external_data_source.py
index a6ec5442967a..f09991c087c9 100644
--- a/products/data_warehouse/backend/tests/api/test_external_data_source.py
+++ b/products/data_warehouse/backend/tests/api/test_external_data_source.py
@@ -4157,10 +4157,6 @@ class TestExternalDataSource(APIBaseTest):
with (
patch.object(source, "validate_credentials_for_access_method", return_value=(True, None)),
patch.object(source, "get_schemas", return_value=[fake_schema]),
- patch(
- "products.data_warehouse.backend.presentation.views.external_data_source.is_xmin_enabled_for_team",
- return_value=True,
- ),
):
response = self.client.post(
f"/api/environments/{self.team.pk}/external_data_sources/database_schema/",
@@ -4557,7 +4553,7 @@ class TestExternalDataSource(APIBaseTest):
"incremental_available": True,
"append_available": True,
"cdc_available": None,
- "xmin_available": None,
+ "xmin_available": False,
"incremental_field": "id",
"sync_type": None,
"supports_webhooks": False,
@@ -4628,7 +4624,7 @@ class TestExternalDataSource(APIBaseTest):
"incremental_available": True,
"append_available": True,
"cdc_available": None,
- "xmin_available": None,
+ "xmin_available": False,
"incremental_field": "id",
"sync_type": None,
"supports_webhooks": False,
diff --git a/products/data_warehouse/frontend/shared/components/forms/SyncMethodForm.test.tsx b/products/data_warehouse/frontend/shared/components/forms/SyncMethodForm.test.tsx
index 44247c397d8d..b5552a546cb8 100644
--- a/products/data_warehouse/frontend/shared/components/forms/SyncMethodForm.test.tsx
+++ b/products/data_warehouse/frontend/shared/components/forms/SyncMethodForm.test.tsx
@@ -23,12 +23,11 @@ const baseSchema: ExternalDataSourceSyncSchema = {
describe('SyncMethodForm', () => {
it.each([
- ['flag on + available', { xmin_available: true }, true, true],
- ['flag off', { xmin_available: true }, false, false],
- ['not available', { xmin_available: false }, true, false],
- ['webhook-only table', { xmin_available: true, webhook_only: true }, true, false],
- ])('offers xmin: %s', (_, overrides, flagEnabled, expected) => {
- expect(shouldOfferXmin({ ...baseSchema, ...overrides }, flagEnabled)).toBe(expected)
+ ['available', { xmin_available: true }, true],
+ ['not available', { xmin_available: false }, false],
+ ['webhook-only table', { xmin_available: true, webhook_only: true }, false],
+ ])('offers xmin: %s', (_, overrides, expected) => {
+ expect(shouldOfferXmin({ ...baseSchema, ...overrides })).toBe(expected)
})
it('exposes a label for the xmin sync type', () => {
diff --git a/products/data_warehouse/frontend/shared/components/forms/SyncMethodForm.tsx b/products/data_warehouse/frontend/shared/components/forms/SyncMethodForm.tsx
index a43546ee4880..63427172ae67 100644
--- a/products/data_warehouse/frontend/shared/components/forms/SyncMethodForm.tsx
+++ b/products/data_warehouse/frontend/shared/components/forms/SyncMethodForm.tsx
@@ -2,7 +2,6 @@ import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
import { LemonButton, LemonInput, LemonSelect, LemonTag, lemonToast } from '@posthog/lemon-ui'
-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { LemonInputSelect } from 'lib/lemon-ui/LemonInputSelect'
import { LemonRadio } from 'lib/lemon-ui/LemonRadio'
@@ -124,9 +123,9 @@ const getCdcSyncSupported = (
}
}
-// xmin is offered only when the source advertises it for the table and the gating flag is on.
-export const shouldOfferXmin = (schema: ExternalDataSourceSyncSchema, xminFlagEnabled: boolean): boolean =>
- !schema.webhook_only && xminFlagEnabled && !!schema.xmin_available
+// xmin is offered only when the source advertises it for the table.
+export const shouldOfferXmin = (schema: ExternalDataSourceSyncSchema): boolean =>
+ !schema.webhook_only && !!schema.xmin_available
const getSaveDisabledReason = (
syncType: 'full_refresh' | 'incremental' | 'append' | 'webhook' | 'cdc' | 'xmin' | undefined,
@@ -188,7 +187,6 @@ export const SyncMethodForm = forwardRef<SyncMethodFormHandle, SyncMethodFormPro
},
ref
): JSX.Element {
- const xminFlagEnabled = useFeatureFlag('DWH_POSTGRES_XMIN')
const incrementalSyncSupported = getIncrementalSyncSupported(schema)
const appendSyncSupported = getAppendOnlySyncSupported(schema)
const cdcSyncSupported = getCdcSyncSupported(schema)
@@ -331,7 +329,7 @@ export const SyncMethodForm = forwardRef<SyncMethodFormHandle, SyncMethodFormPro
})
}
- if (shouldOfferXmin(schema, xminFlagEnabled)) {
+ if (shouldOfferXmin(schema)) {
radioOptions.push({
value: 'xmin',
label: (