Search index updates sometimes get dropped
Search index updates for edits/merges today have been dropped in at least two cases that I've kept track of. In both cases, edits/merges before and after the missing ones did correctly appear in the search index.
NOTE: This is separate from the updates which got dropped as part of the recent outage. I'm ignoring that as a one time event.
Evidence
-
This merge: https://openlibrary.org/recentchanges/2022/12/31/merge-authors/110156479 didn't result in the works showing up in this author's record: https://openlibrary.org/authors/OL2274627A
-
This merge: https://openlibrary.org/recentchanges/2022/12/31/merge-authors/110153037 didn't result in the works showing up under this author's record: https://openlibrary.org/authors/OL2197410A
Because of the way the works list is constructed for the author's page, this basically means the works have disappeared forever (or until a complete reindex is done).
Proposal & Constraints
Related files
Stakeholders
@cdrini
Here's another example from yesterday afternoon. This author record: https://openlibrary.org/authors/OL2253024A is missing the works that should have been added by this merge: https://openlibrary.org/recentchanges/2023/01/01/merge-authors/110174702
Labelling as P3 because this generally only happens when solr-updater has an outage causing it to try to catch up, which should happen rarely.
@cdrini Please re-read the issue, especially the NOTE:
This is not related to any outage and in all three cases merges which were done both immediately before and immediately after the missing update got indexed correctly.
Ahh gotcha!
Hi @cdrini, I looked into this and I think it's the same race my open PR #14080 fixes.
What happens during an author merge
merge_authors.pyloads the affected works to rewrite their author, then saves everything in onesave_many(action="merge-authors"). Since the merge just read those works, they're likely in memcache.- In infogami's
save_many, the database commit comes first, then thesave_manyevent, which writes the log record the Solr updater polls. Memcache only gets the new versions at the end of the request, incache.unloadhook(), whichserver.pyregisters as an unload hook. - The updater sees the log record during that window and rereads each work through
get_many. On master that goes throughMemcacheMiddleware.get_many, so it gets the old cached copy, still pointing at the duplicate author. - The work is indexed under the old
author_key, and nothing queues it again, so it's missing from the master author until a full reindex. That matches all three examples here, including the edits just before and after being fine. Merges are the likeliest victims, because one long request saves many documents that were all just read.
Why #14080 fixes it
#14080 gives the updater's DatabaseDataProvider a connection without MemcacheMiddleware. Every document read in the data provider goes through get_many (via preload_documents0), and Infobase's get_many is a straight SQL query (dbstore.get_many), so it always sees the committed version.
I haven't reproduced this in production. It's what the code does, and it fits every example in the report.
What I'd do if you assign this to me
- A regression test for the window: a merge-style save whose cached copy is still stale when the updater reads it. It should fail on master and pass with #14080.
- A script that finds works still indexed under a redirected author, meaning their
author_keypoints at an author that's now a redirect, and queues them throughsolr-force-update. That would restore the works lost so far. Someone with production access would need to run it.
I can do these as a follow-up to #14080, or fold them into it if you'd rather have one PR.
If it helps, here's a more recent example. This merge: https://openlibrary.org/recentchanges/2026/10/30/merge-works/174769477 is not reflected in the works listed on author Donald Knuth's page a week and a half later.