Skip to content

feat(engine): terminal status-based idempotency key release#4460

Merged
mrkaye97 merged 24 commits into
mainfrom
mk/idempotency-release
Jul 22, 2026
Merged

feat(engine): terminal status-based idempotency key release#4460
mrkaye97 merged 24 commits into
mainfrom
mk/idempotency-release

Conversation

@mrkaye97

@mrkaye97 mrkaye97 commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a second mechanism for releasing idempotency keys, which is to release them once the task that claimed them reaches a terminal status, as requested by a few people. The implementation is pretty simple - in releaseTasks we just run a new query that does the cleanup, similar to how the other release* queries run

Need to make sure this is okay performance-wise still and push the SDKs and docs

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

Changes have been:

  • Tested (unit, integration, or manually with steps specified)
  • Linted and formatted
  • Documented (where applicable)
  • Added to CHANGELOG (where applicable) -- see Keep a Changelog
🤖 AI Disclosure

Used Claude Code to replicate Python SDK changes to the other SDKs

@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hatchet-docs Ready Ready Preview, Comment Jul 22, 2026 2:45am

Request Review

@github-actions github-actions Bot added sdk-py Related to the Python sdk engine Related to the core Hatchet engine labels Jul 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

CREATE TYPE idempotency_method AS ENUM ('TTL', 'STATUS');

ALTER TABLE "WorkflowVersion"
ADD COLUMN "idempotencyMethod" idempotency_method;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we add a DEFAULT to make this easier on ourselves, so we don't need to deal with the null values?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, since then we'd have most rows with an idempotency method but no expression or ttl - it's probably "correct" to make the idempotency config a separate table instead and then have these all be non-null, but I don't really want to deal with adding joins all over. How strongly do you feel...?

SELECT
UNNEST(@taskIds::BIGINT[]) AS task_id,
UNNEST(@taskInsertedAts::TIMESTAMPTZ[]) AS task_inserted_at,
UNNEST(@taskRetryCounts::INTEGER[]) AS retry_count

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might now lead to some raciness on the behavior of retry_count, though I'm not sure. I'm wondering what happens if the terminal event comes in much later, like let's say that the task retries and then a few milliseconds later the completed event is processed. Does the idempotency key get released or not? And is there ever a case where this could lead to an orphaned idempotency key?

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-online-migrate job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@mrkaye97
mrkaye97 merged commit 939ae47 into main Jul 22, 2026
67 checks passed
@mrkaye97
mrkaye97 deleted the mk/idempotency-release branch July 22, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation engine Related to the core Hatchet engine sdk-go Related to the Go SDK sdk-py Related to the Python sdk sdk-ruby Related to the Ruby SDK sdk-ts Related to the Typescript SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants