From a17c3f8b1edce25f78095eceae0accfd5c90bc6d Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Thu, 17 Oct 2024 15:27:04 -0700 Subject: [PATCH] Reraise `KeyboardInterrupt`s and `SystemExit`s during microbatch model execution Previously we were catching all execptions during microbatch model execution, and gracefully handling them. This ensured that one failing batch didn't cause the rest of the batches to fail / be skipped unnecessarily. However if there is a KeyboardInterrupt or SystemExit, execution should halt. To get this to happen, we're now catching and reraising `KeybaordInterrupts`s and `SystemExit`s. --- core/dbt/task/run.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/dbt/task/run.py b/core/dbt/task/run.py index 99913a551c5..8611b3ce56a 100644 --- a/core/dbt/task/run.py +++ b/core/dbt/task/run.py @@ -549,6 +549,9 @@ def _execute_microbatch_materialization( # Update context vars for future batches context["is_incremental"] = lambda: True context["should_full_refresh"] = lambda: False + except (KeyboardInterrupt, SystemExit): + # reraise it for GraphRunnableTask.execute_nodes to handle + raise except Exception as e: exception = e batch_run_result = self._build_failed_run_batch_result(