From 38d7a3bacdc8c30c0771af6218111d2aa70604b4 Mon Sep 17 00:00:00 2001 From: Tom Owers Date: Sat, 24 Aug 2024 11:06:11 +0100 Subject: [PATCH] fix(data-warehouse): Use better mechanics for resyncing a table (#24557) --- posthog/warehouse/api/external_data_schema.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/posthog/warehouse/api/external_data_schema.py b/posthog/warehouse/api/external_data_schema.py index 7f3f9bb2a4772..5b982e54b8434 100644 --- a/posthog/warehouse/api/external_data_schema.py +++ b/posthog/warehouse/api/external_data_schema.py @@ -21,7 +21,6 @@ trigger_external_data_workflow, unpause_external_data_schedule, cancel_external_data_workflow, - delete_data_import_folder, ) from posthog.warehouse.models.external_data_schema import ( filter_mysql_incremental_fields, @@ -251,17 +250,9 @@ def resync(self, request: Request, *args: Any, **kwargs: Any): if latest_running_job and latest_running_job.workflow_id and latest_running_job.status == "Running": cancel_external_data_workflow(latest_running_job.workflow_id) - all_jobs = ExternalDataJob.objects.filter( - schema_id=instance.pk, team_id=instance.team_id, status="Completed" - ).all() - - # Unnecessary to iterate for incremental jobs since they'll all by identified by the schema_id. Be over eager just to clear remnants - for job in all_jobs: - try: - delete_data_import_folder(job.folder_path()) - except Exception as e: - logger.exception(f"Could not clean up data import folder: {job.folder_path()}", exc_info=e) - pass + source: ExternalDataSource = instance.source + source.job_inputs.update({"reset_pipeline": True}) + source.save() try: trigger_external_data_workflow(instance)