astronomer-cosmos icon indicating copy to clipboard operation
astronomer-cosmos copied to clipboard

Reuse connections accross entire Dag

Open DanMawdsleyBA opened this issue 1 year ago • 2 comments

I have run into issues when running an airflow dag with multiple tasks running in parallel which has caused tasks to hang waiting on a connection. As each tasks opens up 3 connections each it might be worth seeing if those connections can be reused across multiple tasks perhaps some sort of setup and teardown task (Airflow 2.7). Could also be extended to deal with initial profile mapping setup also

I have raised a separate issue on the dbt snowflake repo to see if there is anything possible within dbt itself to help manage these connections better. https://github.com/dbt-labs/dbt-snowflake/issues/824

DanMawdsleyBA avatar Nov 03 '23 17:11 DanMawdsleyBA

@DanMawdsleyBA I've been thinking about this issue. Is it only happening when running models?

We could consider using an Airflow Snowflake (potentially async) operator to run the compiled SQL file using Cosmos. We could experiment with this using: https://astronomer.github.io/astronomer-cosmos/configuration/render-config.html#customizing-how-nodes-are-rendered-experimental

We may need to add the compiled SQL to the DbtNode definition.

If we see this approach is successful, we could consider having a Cosmos.AIRFLOW execution mode, where we'd attempt to use native Airflow operators to communicate with the database.

tatiana avatar Nov 08 '23 23:11 tatiana

This is likely associated to the original request: https://github.com/astronomer/astronomer-cosmos/issues/925

tatiana avatar May 14 '24 11:05 tatiana

We'll be doing the following ticket, and hopefully, the original issue will be solved:

  1. https://github.com/astronomer/astronomer-cosmos/issues/924
  2. https://github.com/astronomer/astronomer-cosmos/issues/925

tatiana avatar May 17 '24 10:05 tatiana