Skip to content

Reuse existing ORM session when resolving OpenLineage dag_team_name - #70452

Closed
SameerMesiah97 wants to merge 1 commit into
apache:mainfrom
SameerMesiah97:OpenLineage-Team-Name-Metrics-Fix
Closed

Reuse existing ORM session when resolving OpenLineage dag_team_name#70452
SameerMesiah97 wants to merge 1 commit into
apache:mainfrom
SameerMesiah97:OpenLineage-Team-Name-Metrics-Fix

Conversation

@SameerMesiah97

@SameerMesiah97 SameerMesiah97 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Description

This is a follow-up to PR #69109, which introduced the dag_team_name field to the OpenLineage airflowDagRun run facet.

This change updates the OpenLineage provider to reuse the existing SQLAlchemy session associated with the DagRun when resolving the dag_team_name field.

Rationale

During manual testing, it was discovered that creating a new managed session triggered Airflow's HA lock protection by performing an unexpected commit within the scheduler callback. Reusing the existing DagRun session ensures the lookup participates in the surrounding transaction while continuing to emit the dag_team_name field correctly.

Tests

Updated the existing test_dag_run_team_name unit test to verify that the existing SQLAlchemy session associated with the DagRun is reused when resolving dag_team_name.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: [GPT 5.5] following the guidelines

@SameerMesiah97
SameerMesiah97 force-pushed the OpenLineage-Team-Name-Metrics-Fix branch from aed48e6 to 2e12431 Compare July 25, 2026 21:34
@SameerMesiah97
SameerMesiah97 marked this pull request as ready for review July 25, 2026 22:51
@SameerMesiah97
SameerMesiah97 force-pushed the OpenLineage-Team-Name-Metrics-Fix branch from 2e12431 to 6dbc989 Compare July 26, 2026 06:46
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jul 28, 2026
@kacpermuda

Copy link
Copy Markdown
Collaborator

@SameerMesiah97 did you perhaps test openlineage event emission on actual multi team airflow deployment? I have a fix in #70626, as I think all the task level event emission crashes there. Can you confirm that is the case, as we're trying to access the DB from the worker currently ?

@SameerMesiah97

Copy link
Copy Markdown
Contributor Author

@SameerMesiah97 did you perhaps test openlineage event emission on actual multi team airflow deployment? I have a fix in #70626, as I think all the task level event emission crashes there. Can you confirm that is the case, as we're trying to access the DB from the worker currently ?

I believe that PR just merged very recently. I will retest using the latest code from main and see if the original issue is resolved. If that is the case then this PR is no longer needed.

@SameerMesiah97
SameerMesiah97 marked this pull request as draft July 29, 2026 19:07
Reuse the existing SQLAlchemy session associated with the DagRun when
resolving the team name instead of creating a new managed session via
@provide_session. This avoids an unexpected commit within the scheduler
callback while continuing to emit the dag_team_name facet correctly.
@kacpermuda

Copy link
Copy Markdown
Collaborator

I verified it myself, and yes, my previous PR was needed for sure, openlineage crashed on workers trying to access db. Also, the fix you're proposing here is needed as well, as on scheduler, the openlineage was failing with the commit locks message you mentioned. I applied this fix in #70772 and extended it a bit. Please take a look, I think we can close this one in favor of #70772

@SameerMesiah97

Copy link
Copy Markdown
Contributor Author

This has been closed as it has been superseded by PR #70772.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants