Skip to content

Preserve absolute event timestamps in Gossip - #10418

Merged
auvipy merged 7 commits into
celery:mainfrom
phanky1:gossip
Jul 27, 2026
Merged

auvipy merged 7 commits into
celery:mainfrom
phanky1:gossip

Conversation

@phanky1

@phanky1 phanky1 commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes: #6213.

Worker event timestamps are Unix epochs and are already independent of timezone: the heartbeat stamps events with time.time()

def Event(type, _fields=None, __dict__=dict, __now__=time.time, **fields):
"""Create an event.
Notes:
An event is simply a dictionary: the only required field is ``type``.
A ``timestamp`` field will be set to the current time if not provided.
"""
event = __dict__(_fields, **fields) if _fields else fields
if 'timestamp' not in event:
event.update(timestamp=__now__(), type=type)

and Gossip records the receive time the same way through event_from_message's now=time.time default
def event_from_message(self, body, localize=True,
now=time.time, tzfields=_TZGETTER,
adjust_timestamp=adjust_timestamp,
CLIENT_CLOCK_SKEW=CLIENT_CLOCK_SKEW):
type = body['type']
if type == 'task-sent':
# clients never sync so cannot use their clock value
_c = body['clock'] = (self.clock.value or 1) + CLIENT_CLOCK_SKEW
self.adjust_clock(_c)
else:
try:
clock = body['clock']
except KeyError:
body['clock'] = self.forward_clock()
else:
self.adjust_clock(clock)
if localize:
try:
offset, timestamp = tzfields(body)
except KeyError:
pass
else:
body['timestamp'] = adjust_timestamp(timestamp, offset)
body['local_received'] = now()

The two values are directly comparable epochs.

However, Gossip currently uses event_from_message with its default localize=True, which shifts received timestamps by the difference between the sender's and receiver's timezone offsets, thus generating this false warning:

[2020-07-02 14:01:58,138: WARNING/MainProcess] Substantial drift from celery@worker-two may mean clocks are out of sync.  Current drift is 25200 seconds.  [orig: 2020-07-02 14:01:58.138430 recv: 2020-07-02 21:01:58.134958]

This doesn't happen in Django because Django sets the same TZ environment variable for all processes.

@codecov

codecov Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.43%. Comparing base (f85031f) to head (bb28259).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10418   +/-   ##
=======================================
  Coverage   88.43%   88.43%           
=======================================
  Files         153      153           
  Lines       19802    19802           
  Branches     2301     2301           
=======================================
+ Hits        17511    17512    +1     
  Misses       1994     1994           
+ Partials      297      296    -1     
Flag Coverage Δ
unittests 88.41% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@auvipy auvipy added this to the 5.7.0 milestone Jul 18, 2026
Comment thread celery/worker/consumer/gossip.py Resolved
@phanky1
phanky1 requested a review from auvipy July 18, 2026 13:13
@auvipy
auvipy merged commit 6e435fc into celery:main Jul 27, 2026
17 checks passed
@phanky1
phanky1 deleted the gossip branch July 27, 2026 15:08
Zir0-93 added a commit to hadi-technology/striff-io that referenced this pull request Jul 28, 2026
…bile fixes

Examples: replace all four language examples with structurally impressive,
multi-finding live PRs found via api.striff.io on the fixed C# parser stack:
apache/pinot#19073 (Java, first-ever core-to-plugin edge, Copilot contrast),
celery/celery#10418 (Python, smoke suite wired 4 layers into core),
typeorm/typeorm#12647 (TypeScript, drivers rewired into the platform layer,
Qodo contrast), dotnet/efcore#38676 (C#, Query.Internal to root namespace
edge seeding a near-cycle, Copilot contrast). Diagrams open zoomed on the
flagged component; PR titles deep-link to the original PRs.

FAQ: rewritten from a buyer's perspective; adds "how does Striff know my
architecture", corrects the unverifiable under-30-seconds claim, and makes
the third-party/code-storage answer precise (structural model, not raw
source). Extension copy now reflects that a GitHub token is required.

Pricing: verified against striff-api's EntitlementTier (5/15/50 caps at
$29/$59/$149, 24h upgrade grace); fixes installed.astro claiming 20 repos
for Team where the code enforces 15.

Header: primary CTA now installs the GitHub App; new amber Chrome-styled
Extension button beside it (desktop and mobile menus).

Mobile: finding rows and code chips wrap instead of clipping, example cards
no longer overflow the viewport, and the gallery diagram opens fit-to-width
on phones.

Also removes ICCQ references and the last em dashes in shipped HTML.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01X9W3whWjXLxAQFHY61Gk61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clock drift between workers in different timezones

3 participants