Skip to content

Fix Dag run duration stats crash on PostgreSQL 14+ - #70833

Merged
vatsrahul1001 merged 1 commit into
apache:mainfrom
astronomer:fix-dag-run-stats-decimal-duration
Aug 3, 2026
Merged

Fix Dag run duration stats crash on PostgreSQL 14+#70833
vatsrahul1001 merged 1 commit into
apache:mainfrom
astronomer:fix-dag-run-stats-decimal-duration

Conversation

@pierrejeambrun

Copy link
Copy Markdown
Member

The Dag run duration-stats endpoint crashes with a TypeError on PostgreSQL 14 and newer.

PostgreSQL 14 changed EXTRACT(epoch FROM ...) to return numeric instead of double precision, so DagRun.duration is hydrated as decimal.Decimal on Postgres 14+. The percentile interpolation in compute_duration_stats multiplies that value by a float, which Python disallows for Decimal (unsupported operand type(s) for *: 'decimal.Decimal' and 'float'), so the endpoint 500s for any Dag that has completed runs.

Coercing the durations to float up front keeps the computation backend-agnostic (Postgres Decimal, MySQL int, SQLite float). Adds a parametrized unit test that reproduces the crash with Decimal inputs and passes with the fix.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) following the guidelines

PostgreSQL 14 changed EXTRACT(epoch FROM ...) to return numeric rather than double precision, so DagRun.duration is hydrated as Decimal on Postgres 14+. The duration-stats percentile interpolation then multiplies a Decimal by a float, which Python disallows, so the Dag run stats endpoint raises a TypeError for any Dag that has completed runs.
@boring-cyborg boring-cyborg Bot added the area:API Airflow's REST/HTTP API label Jul 31, 2026
@pierrejeambrun
pierrejeambrun marked this pull request as ready for review July 31, 2026 13:57
@pierrejeambrun pierrejeambrun added this to the Airflow 3.3.1 milestone Jul 31, 2026
@pierrejeambrun pierrejeambrun added the backport-to-v3-3-test Backport to v3-3-test label Jul 31, 2026
@pierrejeambrun

Copy link
Copy Markdown
Member Author
Screenshot 2026-07-31 at 15 58 44

@pierrejeambrun

Copy link
Copy Markdown
Member Author
Screenshot 2026-07-31 at 15 59 55

@vatsrahul1001

Copy link
Copy Markdown
Contributor

LGTM, verified on my end as well

@vatsrahul1001
vatsrahul1001 merged commit 30006eb into apache:main Aug 3, 2026
112 of 136 checks passed
@vatsrahul1001
vatsrahul1001 deleted the fix-dag-run-stats-decimal-duration branch August 3, 2026 05:31
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-3-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-3-test PR Link

vatsrahul1001 pushed a commit that referenced this pull request Aug 3, 2026
… (#70964)

PostgreSQL 14 changed EXTRACT(epoch FROM ...) to return numeric rather than double precision, so DagRun.duration is hydrated as Decimal on Postgres 14+. The duration-stats percentile interpolation then multiplies a Decimal by a float, which Python disallows, so the Dag run stats endpoint raises a TypeError for any Dag that has completed runs.
(cherry picked from commit 30006eb)

Co-authored-by: Pierre Jeambrun <pierrejbrun@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API backport-to-v3-3-test Backport to v3-3-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants