A regression from the fix for T162121 is that cases in refreshLinks and deleteLinksUpdate cause failure like " Category::refreshCounts: Cannot flush pre-lock snapshot because writes are pending (WikiPage::updateCategoryCounts)" because writes are pending while refreshCounts() tries to clear the transaction and a acquire a named lock.
This causes the updates to never happen.