Fix indexing error that sometimes occurs when deleting works

Description

When a work is deleted around the time that it's being reindexed, the indexing code will sometimes load the work, but not be able to find its stat counter. (They're both deleted in the same transaction, but the indexing code loads the work first, and then tries to find its stat counter later.) This results in a NoMethodError when calling comments_count, kudos_count, and bookmarks_count, all of which expect the stat_counter to exist, and all of which are included in the work's JSON document.

This error causes all other works in the same batch to fail to be indexed, which may contribute to AO3-5290.

Testing Instructions: This is an intermittent bug, so I'm not sure it can be consistently replicated. Probably the best policy with this is to deploy it, and check Resque a few days later to see if the error is still happening.

Activity

Show:
Sarken
December 5, 2020, 9:08 PM

reviewer: redsummernight

redsummernight
December 11, 2020, 3:16 PM
Edited

Setting to PAOB: we’ll check https://archiveofourown.org/resque/failed/?class=AsyncIndexer once this fix is deployed. There are a lot of errors there thanks to AO3-6066, so we might need to wait for that fix as well.

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

Works

Priority

Medium

Affects versions

Fix versions

Components

BackEnd

Difficulty

Medium

Milestone

Internal 0.9