Updating the Markdown cache version does not flush the "appearances" cache
The Appearance model uses a Redis cache to remove the need for querying the database every time. In https://gitlab.com/gitlab-com/infrastructure/issues/3534#note_54347202 (and the following comments) we discovered that bumping CacheMarkdownField::CACHE_VERSION
doesn't result in the cache being flushed, instead it sticks around. This then leads to Rails constantly updating this row because the cached version reads X while the new version is X + 1.
This particular issue is odd because Appearance
defines an after_commit
hook to flush the cache. For whatever reason this hook is not executed. We can't simply add the markdown cache version to the cache key for Appearance
as this can still lead to stale data being cached. We could add an extra check in Appearance
, but I think the big underlying issue is that for some reason our after_commit
hook is not triggered.