1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-24 07:42:40 +01:00
phorge-phorge/src/applications/feed
epriestley 129e3a1208 Fix a minor/harmless race with feed publishers in certain draft states
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.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13035

Differential Revision: https://secure.phabricator.com/D18852
2018-01-04 08:14:55 -08:00
..
application Make "Core Applications" more reasonable 2016-08-12 07:57:59 -07:00
builder Merge branch 'master' into redesign-2015 2015-07-01 15:07:16 -07:00
conduit Modernize FeedQuery a little bit 2017-05-26 11:53:19 -07:00
config Move FontIcon calls to Icon 2016-01-28 08:48:45 -08:00
controller Update Feed Story page for newPage 2016-04-03 15:34:07 -07:00
management Apply some autofix linter rules 2014-09-10 06:55:05 +10:00
query Allow users to query feed by a date range 2017-05-26 12:23:56 -07:00
storage Fix visiblity of LiskDAO::getConfiguration() 2015-01-14 06:54:13 +11:00
story Prevent media from autoplaying when rendered as a feed story 2016-11-22 14:19:56 -08:00
worker Fix a minor/harmless race with feed publishers in certain draft states 2018-01-04 08:14:55 -08:00
PhabricatorFeedStoryPublisher.php Fix several issues with email-related global preferences 2016-06-14 12:35:31 -07:00