Page MenuHomePhabricator

Fix a minor/harmless race with feed publishers in certain draft states
ClosedPublic

Authored by epriestley on Jan 3 2018, 9:58 PM.
Tags
None
Referenced Files
F14103569: D18852.diff
Tue, Nov 26, 10:17 PM
Unknown Object (File)
Wed, Nov 20, 6:19 PM
Unknown Object (File)
Sat, Nov 9, 2:52 PM
Unknown Object (File)
Mon, Oct 28, 3:43 PM
Unknown Object (File)
Oct 24 2024, 7:20 PM
Unknown Object (File)
Oct 18 2024, 5:00 PM
Unknown Object (File)
Oct 13 2024, 9:56 PM
Unknown Object (File)
Oct 11 2024, 8:03 AM
Subscribers
None

Details

Summary

Depends on D18851. Ref T13035. After D18819, revision creation transactions may be split into two groups (if prototypes are enabled).

This split means we have two workers. The first worker doesn't publish feed stories or mail; the second one does.

Currently, both workers call shouldPublishFeedStory() before they queue, and then again after the daemons pull them out of the queue. However, the answer to this question can change.

Specifically, this happens:

  • arc creates a revision.
  • The first transaction group applies, creating the revision as a draft, and returns false from shouldPublishFeedStory(), and does not generate related PHIDs. It queues a daemon to send mail, expecting it not to publish a feed story.
  • The second transaction group applies, promoting the revision to "needs review". Since the revision has promoted, shouldPublishFeedStory() now returns true. This editor generates related PHIDs and queues a daemon task, expecting it to send mail / publish feed.
  • A few milliseconds pass.
  • The first job gets pulled out of the daemon queue and worked on. It does not have any feed metadata because the object wasn't publishable when the job was queued -- but shouldPublishFeedStory() now returns true, so it tries to publish a story without any metadata available. Slightly bad stuff happens (see below).
  • The second job gets pulled out of the daemon queue and worked on. This one has metadata and works fine.

The "slightly bad stuff" is that we publish an empty feed story with no references to any objects, then try to push it to hooks and other listeners. Since it doesn't have any references, it fails to load during the "push to external listeners" phase.

This is harmless but clutters the log and doesn't help anything.

Instead, cache the state of "are we publishing a feed story for this object?" when we queue the worker so it can't race.

Test Plan
  • Enabled prototypes.
  • Disabled all Herald triggers for Harbormaster build plans.
  • Ran bin/phd debug task in one window.
  • Created a revision in a separate window.
  • Before patch: saw "unable to load feed story" errors in the daemon log.
  • After patch: no more "unable to load feed story" errors.

Diff Detail

Repository
rP Phabricator
Branch
draft2
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 19000
Build 25630: Run Core Tests
Build 25629: arc lint + arc unit

Event Timeline

epriestley retitled this revision from Fix a minor/harmless race with feed publishers in certain draft states. to Fix a minor/harmless race with feed publishers in certain draft states.Jan 3 2018, 10:01 PM
epriestley edited the summary of this revision. (Show Details)
epriestley edited the test plan for this revision. (Show Details)
This revision is now accepted and ready to land.Jan 4 2018, 2:01 AM
This revision was automatically updated to reflect the committed changes.