René's URL Explorer Experiment


Title: RetryableTask.compute_next_delay uses wall-clock time causing non-deterministic failures on replay with retry_timeout · Issue #316 · microsoft/durabletask-python · GitHub

Open Graph Title: RetryableTask.compute_next_delay uses wall-clock time causing non-deterministic failures on replay with retry_timeout · Issue #316 · microsoft/durabletask-python

X Title: RetryableTask.compute_next_delay uses wall-clock time causing non-deterministic failures on replay with retry_timeout · Issue #316 · microsoft/durabletask-python

Description: Problem Description When an activity or sub-orchestration is scheduled with a RetryPolicy that specifies a retry_timeout, RetryableTask.compute_next_delay() checks if the retry deadline has passed using system wall-clock time (datetime.n...

Open Graph Description: Problem Description When an activity or sub-orchestration is scheduled with a RetryPolicy that specifies a retry_timeout, RetryableTask.compute_next_delay() checks if the retry deadline has passed ...

X Description: Problem Description When an activity or sub-orchestration is scheduled with a RetryPolicy that specifies a retry_timeout, RetryableTask.compute_next_delay() checks if the retry deadline has passed ...

Opengraph URL: https://github.com/microsoft/durabletask-python/issues/316

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"RetryableTask.compute_next_delay uses wall-clock time causing non-deterministic failures on replay with retry_timeout","articleBody":"### Problem Description\n\nWhen an activity or sub-orchestration is scheduled with a `RetryPolicy` that specifies a `retry_timeout`, `RetryableTask.compute_next_delay()` checks if the retry deadline has passed using system wall-clock time (`datetime.now(tz=UTC).replace(tzinfo=None)`):\n\nhttps://github.com/microsoft/durabletask-python/blob/97427b24b4f80733334e3f8985b9bde339605d42/durabletask/task.py#L829-L850\n\n```python\n    def compute_next_delay(self) -> timedelta | None:\n        if self._attempt_count >= self._retry_policy.max_number_of_attempts:\n            return None\n\n        retry_expiration: datetime = datetime.max\n        if self._retry_policy.retry_timeout is not None and self._retry_policy.retry_timeout != datetime.max:\n            retry_expiration = self._start_time + self._retry_policy.retry_timeout\n\n        if self._retry_policy.backoff_coefficient is None:\n            backoff_coefficient = 1.0\n        else:\n            backoff_coefficient = self._retry_policy.backoff_coefficient\n\n        if datetime.now(tz=UTC).replace(tzinfo=None) \u003c retry_expiration:\n            next_delay_f = math.pow(backoff_coefficient, self._attempt_count - 1) * self._retry_policy.first_retry_interval.total_seconds()\n\n            if self._retry_policy.max_retry_interval is not None:\n                next_delay_f = min(next_delay_f, self._retry_policy.max_retry_interval.total_seconds())\n\n            return timedelta(seconds=next_delay_f)\n\n        return None\n```\n\nThis leads to two critical issues:\n\n1. **Replay Non-determinism**: In Durable Task Framework, orchestrations must be deterministic and replay-safe. Orchestration histories are replayed whenever an instance resumes (e.g. after a worker restart, crash recovery, server failover, long timer expiration, or external event arrival). Because `compute_next_delay()` evaluates the current system wall-clock time (`datetime.now()`) instead of the orchestration's logical time (`ctx.current_utc_datetime` or the history event timestamp), any replay that occurs after `_start_time + retry_timeout` has elapsed in real time will evaluate `datetime.now() \u003c retry_expiration` to `False` and return `None`.\n   - Consequently, in `worker.py` (lines 2876-2881 and 2987-2992), the worker erroneously treats retries as expired, marks the task as failed via `fail()`, and completes the orchestration with `ORCHESTRATION_STATUS_FAILED` rather than scheduling the retry timer. This causes replay divergence and crashes valid in-flight orchestrations.\n2. **Offset-naive vs Offset-aware `TypeError`**: `datetime.now(tz=UTC).replace(tzinfo=None)` strips timezone info. If `_start_time` is timezone-aware (e.g. if `current_utc_datetime` is set with a timezone or in custom providers), `retry_expiration` is offset-aware. Comparing `check \u003c retry_expiration` crashes with `TypeError: can't compare offset-naive and offset-aware datetimes`.\n\n---\n\n### Minimal Reproduction\n\n#### 1. Replay Divergence / Failure\nRun the following script simulating an orchestration history that was recorded 2 minutes ago where an activity with a 10s `retry_timeout` failed after 1 second:\n\n```python\nfrom datetime import datetime, timedelta\nimport logging\nfrom durabletask import task, worker\nfrom durabletask.serialization import JsonDataConverter\nimport durabletask.internal.helpers as helpers\n\ndef dummy_activity(ctx, input):\n    return \"result\"\n\ndef orchestrator(ctx, _):\n    res = yield ctx.call_activity(\n        dummy_activity,\n        retry_policy=task.RetryPolicy(\n            first_retry_interval=timedelta(seconds=1),\n            max_number_of_attempts=5,\n            retry_timeout=timedelta(seconds=10),\n        ),\n    )\n    return res\n\nregistry = worker._Registry()\nname = registry.add_orchestrator(orchestrator)\nregistry.add_activity(dummy_activity)\n\n# Execution originally started 2 minutes ago:\nt0 = datetime.utcnow() - timedelta(minutes=2)\nt1 = t0 + timedelta(seconds=1)\n\nold_history = [\n    helpers.new_orchestrator_started_event(timestamp=t0),\n    helpers.new_execution_started_event(name, \"test-inst\", encoded_input=None),\n    helpers.new_task_scheduled_event(1, task.get_name(dummy_activity)),\n]\nnew_events = [\n    helpers.new_orchestrator_started_event(timestamp=t1),\n    helpers.new_task_failed_event(1, ValueError(\"Transient error\")),\n]\n\nexecutor = worker._OrchestrationExecutor(registry, logging.getLogger(), JsonDataConverter())\nres = executor.execute(\"test-inst\", old_history, new_events)\n\naction_type = res.actions[0].WhichOneof(\"orchestratorActionType\")\nprint(f\"Action produced on replay: {action_type}\")\n# Output:\n# Action produced on replay: completeOrchestration\n# BUG: Expected 'createTimer' (since only 1s of the 10s timeout had elapsed), but got 'completeOrchestration'!\n```\n\n#### 2. Timezone Comparison Crash\n```python\nfrom datetime import datetime, timezone, timedelta\nfrom durabletask import task\n\nrp = task.RetryPolicy(\n    first_retry_interval=timedelta(seconds=1),\n    max_number_of_attempts=5,\n    retry_timeout=timedelta(seconds=30),\n)\nt = task.RetryableTask(\n    retry_policy=rp,\n    action=None,\n    start_time=datetime.now(timezone.utc),\n    is_sub_orch=False,\n)\nt.compute_next_delay()\n# Raises: TypeError: can't compare offset-naive and offset-aware datetimes\n```\n\n---\n\n### Expected Behavior\n\n1. `compute_next_delay` should evaluate retry expiration against the orchestration's deterministic logical clock (`ctx.current_utc_datetime` or event timestamp) rather than system wall-clock time, ensuring replay reproducibility.\n2. Timezone-aware start timestamps should be handled seamlessly without `TypeError`.\n\n---\n\n### Suggested Direction\n\n1. Accept an optional `current_time: datetime | None = None` parameter in `RetryableTask.compute_next_delay()`:\n   ```python\n   def compute_next_delay(self, current_time: datetime | None = None) -> timedelta | None:\n       if self._attempt_count >= self._retry_policy.max_number_of_attempts:\n           return None\n\n       retry_expiration: datetime = datetime.max\n       if self._retry_policy.retry_timeout is not None and self._retry_policy.retry_timeout != datetime.max:\n           retry_expiration = self._start_time + self._retry_policy.retry_timeout\n\n       if self._retry_policy.backoff_coefficient is None:\n           backoff_coefficient = 1.0\n       else:\n           backoff_coefficient = self._retry_policy.backoff_coefficient\n\n       check_time = current_time if current_time is not None else datetime.now(tz=UTC)\n       if retry_expiration != datetime.max:\n           if retry_expiration.tzinfo is None and check_time.tzinfo is not None:\n               check_time = check_time.replace(tzinfo=None)\n           elif retry_expiration.tzinfo is not None and check_time.tzinfo is None:\n               check_time = check_time.replace(tzinfo=UTC)\n\n       if check_time \u003c retry_expiration:\n           next_delay_f = (\n               math.pow(backoff_coefficient, self._attempt_count - 1)\n               * self._retry_policy.first_retry_interval.total_seconds()\n           )\n           if self._retry_policy.max_retry_interval is not None:\n               next_delay_f = min(next_delay_f, self._retry_policy.max_retry_interval.total_seconds())\n           return timedelta(seconds=next_delay_f)\n\n       return None\n   ```\n2. In `worker.py` (lines 2875 and 2986), pass `ctx.current_utc_datetime` when calling `compute_next_delay`:\n   ```python\n   next_delay = retryable_activity_task.compute_next_delay(ctx.current_utc_datetime)\n   ```\n   and\n   ```python\n   next_delay = retryable_sub_orch_task.compute_next_delay(ctx.current_utc_datetime)\n   ```\n","author":{"url":"https://github.com/hardikkaurani","@type":"Person","name":"hardikkaurani"},"datePublished":"2026-10-31T22:19:45Z","url":"https://github.com/microsoft/durabletask-python/issues/316"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:e0dba658-36fb-762e-938b-ff308fa7df40
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idACD4:306EC8:C34972:112CA8A:6AFE2CF2
html-safe-nonce75646283d34950140e2ca3b37688f3a6ec26f38440f1ce88f82976f51f5d23fd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQ0Q0OjMwNkVDODpDMzQ5NzI6MTEyQ0E4QTo2QUZFMkNGMiIsInZpc2l0b3JfaWQiOiI0MDg5ODc5OTcyMzAxMTIyODAzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacbd58f691e02fa723590a6af6b14807d342794b46e690dcd034d36001a0398b4c
hovercard-subject-tagissue:6140424763
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/durabletask-python/316/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9ff07726bb04b0a6e5576fbb02d568216f1f2c5d5d2bf9ad13b919a3573be533/microsoft/durabletask-python/issues/316
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9ff07726bb04b0a6e5576fbb02d568216f1f2c5d5d2bf9ad13b919a3573be533/microsoft/durabletask-python/issues/316
og:image:altProblem Description When an activity or sub-orchestration is scheduled with a RetryPolicy that specifies a retry_timeout, RetryableTask.compute_next_delay() checks if the retry deadline has passed ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamehardikkaurani
hostnamegithub.com
expected-hostnamegithub.com
Nonee973f9ec3625f3faad8cac5c2d11a214b7ffe45f3cc563b828459b290ecaeed3
turbo-cache-controlno-preview
go-importgithub.com/microsoft/durabletask-python git https://github.com/microsoft/durabletask-python.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id627664515
octolytics-dimension-repository_nwomicrosoft/durabletask-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id627664515
octolytics-dimension-repository_network_root_nwomicrosoft/durabletask-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release1f92c367595b9190e0be293896078033886b1913
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/durabletask-python/issues/316#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdurabletask-python%2Fissues%2F316
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdurabletask-python%2Fissues%2F316
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2Fdurabletask-python
Reloadhttps://github.com/microsoft/durabletask-python/issues/316
Reloadhttps://github.com/microsoft/durabletask-python/issues/316
Reloadhttps://github.com/microsoft/durabletask-python/issues/316
microsofthttps://github.com/microsoft
durabletask-pythonhttps://github.com/microsoft/durabletask-python
Codehttps://github.com/microsoft/durabletask-python
Issues15 (15)https://github.com/microsoft/durabletask-python/issues
Pull requests12 (12)https://github.com/microsoft/durabletask-python/pulls
Actionshttps://github.com/microsoft/durabletask-python/actions
Projectshttps://github.com/microsoft/durabletask-python/projects
Security and qualityhttps://github.com/microsoft/durabletask-python/security
Insightshttps://github.com/microsoft/durabletask-python/insights
https://github.com/microsoft/durabletask-python
New issuehttps://github.com/login?return_to=https://github.com/microsoft/durabletask-python/issues/316
New issuehttps://github.com/login?return_to=https://github.com/microsoft/durabletask-python/issues/316
#326https://github.com/microsoft/durabletask-python/pull/326
RetryableTask.compute_next_delay uses wall-clock time causing non-deterministic failures on replay with retry_timeouthttps://github.com/microsoft/durabletask-python/issues/316#top
#326https://github.com/microsoft/durabletask-python/pull/326
https://github.com/hardikkaurani
Hardik K (hardikkaurani)https://github.com/hardikkaurani
on Oct 31, 2026https://github.com/microsoft/durabletask-python/issues/316#issue-6140424763
durabletask-python/durabletask/task.pyhttps://github.com/microsoft/durabletask-python/blob/97427b24b4f80733334e3f8985b9bde339605d42/durabletask/task.py#L829-L850
97427b2https://github.com/microsoft/durabletask-python/commit/97427b24b4f80733334e3f8985b9bde339605d42
https://github.com/hardikkaurani
Hardik K (hardikkaurani)https://github.com/hardikkaurani
on Oct 31, 2026https://github.com/microsoft/durabletask-python/issues/316#issuecomment-6549899405
Bernd Verst (@berndverst)https://github.com/berndverst
andystapleshttps://github.com/andystaples
Bernd Verst (berndverst)https://github.com/berndverst
completedhttps://github.com/microsoft/durabletask-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#326https://github.com/microsoft/durabletask-python/pull/326
on Nov 10, 2026https://github.com/microsoft/durabletask-python/issues/316#event-35710141445
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/durabletask-python/issues/316
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/durabletask-python/issues/316
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.