@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

After a fulltext write to a particular service fails, keep trying writes to other services

Summary:
Ref T12450. Currently, if a write fails, we stop and don't try to write to other index services. There's no technical reason not to keep trying writes, it makes some testing easier, and it would improve behavior in a scenario where engines are configured as "primary" and "backup" and the primary service is having some issues.

Also, make "no writable services are configured" acceptable, rather than an error. This state is probably goofy but if we want to detect it I think it should probably be a config-validation issue, not a write-time check. I also think it's not totally unreasonable to want to just turn off all writes for a while (maybe to reduce load while you're doing a background update).

Test Plan:
- Configured a bad ElasticSearch engine and a good MySQL engine.
- Ran `bin/search index ... --force`.
- Saw MySQL get updated even though ElasticSearch failed.

Reviewers: chad, 20after4

Reviewed By: 20after4

Maniphest Tasks: T12450

Differential Revision: https://secure.phabricator.com/D17599

+19 -9
+19 -9
src/infrastructure/cluster/search/PhabricatorSearchService.php
··· 212 212 /** 213 213 * (re)index the document: attempt to pass the document to all writable 214 214 * fulltext search hosts 215 - * @throws PhabricatorClusterNoHostForRoleException 216 215 */ 217 216 public static function reindexAbstractDocument( 218 - PhabricatorSearchAbstractDocument $doc) { 219 - $indexed = 0; 217 + PhabricatorSearchAbstractDocument $document) { 218 + 219 + $exceptions = array(); 220 220 foreach (self::getAllServices() as $service) { 221 - $hosts = $service->getAllHostsForRole('write'); 222 - if (count($hosts)) { 223 - $service->getEngine()->reindexAbstractDocument($doc); 224 - $indexed++; 221 + if (!$service->isWritable()) { 222 + continue; 223 + } 224 + 225 + $engine = $service->getEngine(); 226 + try { 227 + $engine->reindexAbstractDocument($document); 228 + } catch (Exception $ex) { 229 + $exceptions[] = $ex; 225 230 } 226 231 } 227 - if ($indexed == 0) { 228 - throw new PhabricatorClusterNoHostForRoleException('write'); 232 + 233 + if ($exceptions) { 234 + throw new PhutilAggregateException( 235 + pht( 236 + 'Writes to search services failed while reindexing document "%s".', 237 + $document->getPHID()), 238 + $exceptions); 229 239 } 230 240 } 231 241