# dbt run --fail-fast gets stuck on CANCEL (snowflake)

**URL:** <https://discourse.getdbt.com/t/dbt-run-fail-fast-gets-stuck-on-cancel-snowflake/7087>\
**Category:** Help\
**Created:** [March 3, 2023, 1:31pm UTC](https://discourse.getdbt.com/t/dbt-run-fail-fast-gets-stuck-on-cancel-snowflake/7087 "2023-03-03T13:31:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ecerulm](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/ecerulm/32/743_2.png) [@ecerulm](https://discourse.getdbt.com/u/ecerulm)\
**Post date:** [March 3, 2023, 1:31pm UTC](https://discourse.getdbt.com/t/dbt-run-fail-fast-gets-stuck-on-cancel-snowflake/7087/1 "2023-03-03T13:31:43Z")

</div>

## The problem I’m having

I’m using dbt-core==1.4.1 and dbt-snowflake==1.4.1

I’m running with dbt run --fail-fast

```auto
dbt run -x
13:26:08 Running with dbt=1.4.1
13:26:08 Found 2 models, 0 tests, 0 snapshots, 0 analyses, 304 macros, 0 operations, 0 seed files, 2 sources, 0 exposures, 0 metrics
13:26:08
13:26:10 Concurrency: 1 threads (target='dev')
13:26:10
13:26:10 1 of 2 START sql table model xxx.model1 [RUN]
13:26:11 1 of 2 ERROR creating sql table model xxx.model1 [ERROR in 0.80s]
13:26:11 2 of 2 START sql table model xxx.model2 ... [RUN]
13:26:11 CANCEL query model.myproject.model1 ......... [CANCEL]

```

step 1 fails (the model container a syntax error `Snowflake adapter: Snowflake error: 001003 (42000): SQL compilation error: syntax error line 40`) ,

then it starts step 2 (model2) , which surprises me because I though that the --fail-fast meant that it won’t continue at all.

Then it gets stuck on CANCEL (or maybe it’s waiting for the model2 to complete, hard to tell)

Is there any way to make it fail fast for real? not starting model2 at all?

---

<div class="post-metadata">

**Author:** ![ecerulm](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/ecerulm/32/743_2.png) [@ecerulm](https://discourse.getdbt.com/u/ecerulm)\
**Post date:** [March 3, 2023, 2:05pm UTC](https://discourse.getdbt.com/t/dbt-run-fail-fast-gets-stuck-on-cancel-snowflake/7087/2 "2023-03-03T14:05:53Z")

</div>

I waited and it’s not stuck forever. Instead of failing fast it just waits for the other model to complete

I reported it as as bug

> <https://github.com/dbt-labs/dbt-core/issues/7110>
>
> \### Is this a new bug in dbt-core?
> 
> \- \[X\] I believe this is a new bug in dbt-cor…e
> \- \[X\] I have searched the existing issues, and I could not find an existing issue for this bug
> 
> \### Current Behavior
> 
> When running with \`dbt run -x \` or \`dbt run --fail-fast\` , if one of the models fails to build, it won't cancel the second one
> 
> With dbt==1.4.1 dbt-snowflake==1.4.1
> 
> It starts \`model2\` and then \`CANCEL model1\` (the one that already failed / ERRORed), then waits for completion of \`model2\`. I think it was supposed to cancel \`model2\` not wait for it to complete. 
> 
> 
> \### Expected Behavior
> 
> From the documentation at https://docs.getdbt.com/reference/global-configs#failing-fast I would expected to 
> 
> START model1
> ERROR model1
> START model2
> CANCEL model2
> ERROR model2
> 
> but in my case it does
> 
> START model1
> ERROR model1
> START model2
> CANCEL \*\*model1\*\*
> OK model2
> 
> 
> I think it was supposed to CANCEL model2 since model1 failed. But no, it waits for completion of model2. 
> 
> 
> \### Steps To Reproduce
> 
> 1. create a new project
> 2. add 2 models that take 5 minutes to complete each 
> 3. introduce a SQL syntax error in the one that executes first
> 4. run with \`dbt run -x\` 
> 5. dbt should exit quickly since the syntax error, it detected quickly. but it instead waits for the second one to complete (which defeats the purpose of --fail-fast)
> 
> \### Relevant log output
> 
> \`\`\`shell
> dbt run -x
> 13:26:08 Running with dbt=1.4.1
> 13:26:08 Found 2 models, 0 tests, 0 snapshots, 0 analyses, 304 macros, 0 operations, 0 seed files, 2 sources, 0 exposures, 0 metrics
> 13:26:08
> 13:26:10 Concurrency: 1 threads (target='dev')
> 13:26:10
> 13:26:10 1 of 2 START sql table model xxx.model1 \[RUN\]
> 13:26:11 1 of 2 ERROR creating sql table model xxx.model1 \[ERROR in 0.80s\]
> 13:26:11 2 of 2 START sql table model xxx.model2 ... \[RUN\]
> 13:26:11 CANCEL query model.myproject.model1 ......... \[CANCEL\]
> 
> \`\`\`
> \`\`\`
> 
> 
> \### Environment
> 
> \`\`\`markdown
> \- OS: macOS Monterey
> \- Python: 3.10.10
> \- dbt: 1.4.1
> \`\`\`
> 
> 
> \### Which database adapter are you using with dbt?
> 
> snowflake
> 
> \### Additional Context
> 
> \_No response\_

---

<div class="post-metadata">

**Author:** ![ecerulm](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/ecerulm/32/743_2.png) [@ecerulm](https://discourse.getdbt.com/u/ecerulm)\
**Post date:** [March 3, 2023, 2:15pm UTC](https://discourse.getdbt.com/t/dbt-run-fail-fast-gets-stuck-on-cancel-snowflake/7087/3 "2023-03-03T14:15:45Z")

</div>

Well, I realized that `--fail-fast` is a global options so `dbt run --fail-fast` is incorrect. The actual right syntax is

`dbt --fail-fast run`

or

`dbt -x run`

but still it’s remarkable that `dbt run --fail-fast` does not produce any error. It should have errored with `dbt: error: unrecognized arguments: --fail-fast` if it’s not supported there.

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [March 4, 2023, 9:56pm UTC](https://discourse.getdbt.com/t/dbt-run-fail-fast-gets-stuck-on-cancel-snowflake/7087/4 "2023-03-04T21:56:47Z")

</div>

@ecerulm Wow, I never noticed that!

Although the docs show the correct usage, I thought that it was `dbt run --fail-fast`, it was automatic to think about the flags after `run`.

Thanks for pointing that out.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [March 11, 2023, 9:57pm UTC](https://discourse.getdbt.com/t/dbt-run-fail-fast-gets-stuck-on-cancel-snowflake/7087/5 "2023-03-11T21:57:20Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
