: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
refactor(bigquery): Set chunk size separately for multiple consumers (#96070)
Tomás Farías Santana536b00364b54
diff --git a/posthog/settings/batch_exports.py b/posthog/settings/batch_exports.pyindex 0beeeff02b93..3c7225057410 100644--- a/posthog/settings/batch_exports.py+++ b/posthog/settings/batch_exports.py@@ -21,6 +21,7 @@ BATCH_EXPORT_POSTGRES_RECORD_BATCH_QUEUE_MAX_SIZE_BYTES: int = get_from_env()BATCH_EXPORT_BIGQUERY_UPLOAD_CHUNK_SIZE_BYTES: int = 1024 * 1024 * 150 # 150MB+BATCH_EXPORT_BIGQUERY_MULTIPLE_CONSUMERS_UPLOAD_CHUNK_SIZE_BYTES: int = 1024 * 1024 * 150 # 150MBBATCH_EXPORT_BIGQUERY_RECORD_BATCH_QUEUE_MAX_SIZE_BYTES: int = get_from_env("BATCH_EXPORT_BIGQUERY_RECORD_BATCH_QUEUE_MAX_SIZE_BYTES", 1024 * 1024 * 100, type_cast=int)diff --git a/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py b/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.pyindex 9aaad1fd713c..4b8e54f66b31 100644--- a/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py+++ b/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py@@ -1552,8 +1552,10 @@ async def insert_into_bigquery_activity_from_stage(inputs: BigQueryInsertInputs))max_consumers = 1+ max_file_size_bytes_per_consumer = settings.BATCH_EXPORT_BIGQUERY_UPLOAD_CHUNK_SIZE_BYTESif str(inputs.team_id) in settings.BATCH_EXPORT_BIGQUERY_USE_MULTIPLE_CONSUMERS_TEAM_IDS:max_consumers = settings.BATCH_EXPORT_BIGQUERY_MAX_CONSUMERS+ max_file_size_bytes_per_consumer = settings.BATCH_EXPORT_BIGQUERY_MULTIPLE_CONSUMERS_UPLOAD_CHUNK_SIZE_BYTESasync with bq_client:bigquery_target_table = await bq_client.get_or_create_table(target_table)@@ -1601,7 +1603,6 @@ async def insert_into_bigquery_activity_from_stage(inputs: BigQueryInsertInputs)file_format: typing.Literal["Parquet", "JSONLines"] = "Parquet" if can_perform_merge else "JSONLines"- max_file_size_bytes_per_consumer = settings.BATCH_EXPORT_BIGQUERY_UPLOAD_CHUNK_SIZE_BYTES // max_consumersbarrier_size = max_consumers + 1 if can_perform_merge else max_consumersall_consumers_done = asyncio.Barrier(barrier_size)merge_done = asyncio.Event()