Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain how transactions (and rollbacks) are handled for incremental strategies #4635

Closed
1 task done
dbeatty10 opened this issue Dec 13, 2023 · 0 comments · Fixed by #4655
Closed
1 task done

Explain how transactions (and rollbacks) are handled for incremental strategies #4635

dbeatty10 opened this issue Dec 13, 2023 · 0 comments · Fixed by #4655
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear

Comments

@dbeatty10
Copy link
Contributor

dbeatty10 commented Dec 13, 2023

Contributions

  • I have read the contribution docs, and understand what's expected of me.

Link to the page on docs.getdbt.com requiring updates

https://docs.getdbt.com/docs/build/incremental-models

What part(s) of the page would you like to see updated?

Question

The goal of this issue is to document the answer to this question from dbt-labs/dbt-core#7011 (comment):

For the DML, we know that only the delete+insert strategy will work, and not merge. With delete+insert incremental strategy, does Dbt wrap both in a single transaction? If not, and they are treated as 2 separate transactions that would be bad. For example, the delete could succeed, and the subsequent insert could fail. The table would then be left with deleted records = Not Good. Can you elaborate on how Dbt already handles that. I cannot find it anywhere in the doc.

Answer

On data platforms that use transactions, dbt will roll back open transactions if any statement in the materialization fails. This is useful to restore the database to a good state even if the materialization breaks in the middle (due to bad data or a logic bug like a divide by zero issue).

Additional information

This was originally included as part of #2895 on 2023-02-20.

@dbeatty10 dbeatty10 added content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear labels Dec 13, 2023
dbeatty10 added a commit that referenced this issue Dec 15, 2023
…strategies (#4655)

[Preview](https://docs-getdbt-com-git-dbeatty-explain-incremental-957f61-dbt-labs.vercel.app/docs/build/incremental-models#how-do-incremental-models-work-behind-the-scenes)

## What are you changing in this pull request and why?

resolves #4635

The goal of this issue is to document the answer to this question from
dbt-labs/dbt-core#7011 (comment):

> For the DML, we know that only the delete+insert strategy will work,
and not merge. With delete+insert incremental strategy, does Dbt wrap
both in a single transaction? If not, and they are treated as 2 separate
transactions that would be bad. For example, the delete could succeed,
and the subsequent insert could fail. The table would then be left with
deleted records = Not Good. Can you elaborate on how Dbt already handles
that. I cannot find it anywhere in the doc.

### 🎩

<img width="600" alt="image"
src="https://github.com/dbt-labs/docs.getdbt.com/assets/44704949/6c398757-26a2-42c5-9783-8083ab7e20d0">


## Checklist

- [x] Review the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md)
so my content adheres to these guidelines.

---------

Co-authored-by: mirnawong1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear
Projects
None yet
1 participant