Avoid BadRequest errors when indexing empty batches

Description

When one of the indexing classes generates an empty batch (either because the list of items it's indexing is empty, or because it doesn't need to make any changes to the index), it will submit an empty list to $elasticsearch.bulk(body: batch). This causes a Elasticsearch::Transport::Transport::Errors::BadRequest error.

Because this error only occurs when the indexing classes are trying to submit zero changes to Elasticsearch, this doesn't affect functionality in any way, but it'd be nice to reduce the number of errors in Resque.

Testing Instructions: I think it would be best to check this in production by waiting a few days and checking whether the error shows up in Resque.

(I think this occurs when deleting bookmarks, because multiple people viewing a page with a deleted bookmark during the same second could cause the IndexSweeper to create two jobs with identical Redis keys. That results in the second job running with an empty batch. But that's probably pretty difficult to replicate on demand, so I think it's better to check production, where it happens on average 10+ times per day.)

Activity

Show:
redsummernight
December 13, 2020, 11:16 AM

Setting to PAOB: we’ll check https://archiveofourown.org/resque/failed/?class=AsyncIndexer once this fix is deployed.

redsummernight
January 24, 2021, 10:44 AM

We cleared out all Resque failures on 2021-01-16 and waited a week. No such indexing errors reappeared so far. Looks good.

Done

Assignee

ticking instant

Reporter

ticking instant

Roadmap

Search

Priority

Medium

Affects versions

Fix versions

Components

BackEnd

Difficulty

Medium

Milestone

Internal 0.9