Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(dev/core#3166) "Metadata" cache - Strictly separate by version #23148

Merged
merged 1 commit into from
Apr 10, 2022

Conversation

totten
Copy link
Member

@totten totten commented Apr 9, 2022

Overview

This addresses some symptoms identified in the discussion of dev/core#3166 where a recently-updated codebase generates errors due to stale cache data.

With this patch, the metadata cache will be de-facto reset whenever you load new code.

Before

The metadata cache is always stored with the name metadata.

If you load a newer codebase, it still reads metadata from the older code base (until something explicitly clears the cache).

After

The metadata cache is always stored with the name metadata_{version}, eg metadata_5_48_0.

If you load a newer codebase (eg 5.49.0), it will ignore the older metadata_5_48_0 and create a new metadata_5_49_0.

Comments

The upgrade system also clears cache, but many users rely on navigating through the site to get to the upgrader.

The change could make sense with other caches, but I only applied the change to the metadata cache because there is some risk; eg if some caller bypasses the cache objects. (I was also slightly concerned about the possibility the some caller relies on $cache->getName() or $cache->getPrefix() or similar... but I haven't been able to find any methods like that...). It seems safer to put that sort of change into a monthly update rather than minor patch.

The discussion in 3166 touched on a few different error scenarios in a few different environments. I don't know that it helps all of them, but it helps the ones that I experienced/reproduced.

This addresses some symptoms identified in the discussion of 3166.

Before
------

The "metadata" cache is always stored with the name `metadata`.

If you load a newer codebase, it still reads `metadata` from the older code base (until something explicitly clears the cache).

After
-----

The "metadata" cache is always stored with the name `metadata_{version}`, eg `metadata_5_48_0`.

If you load a newer codebase (eg `5.49.0`), it will ignore the older `metadata_5_48_0` and create a new `metadata_5_49_0`.

Comments
--------

The upgrade system also clears cache, but many users rely on navigating through the site to get to the upgrader.

The change could make sense with other caches, but I only applied the change to the `metadata` cache because there is _some_ risk;
eg if some caller bypasses the cache objects. (I was also slightly concerned about the possibility the some caller relies
on `$cache->getName()` or `$cache->getPrefix()` or similar... but I haven't been able to find any methods like that...). It seems
safer to put that sort of change into a monthly update rather than minor patch.
@civibot
Copy link

civibot bot commented Apr 9, 2022

(Standard links)

@civibot civibot bot added the 5.48 label Apr 9, 2022
@totten totten changed the base branch from 5.48 to 5.49 April 9, 2022 21:41
@civibot civibot bot added 5.49 and removed 5.48 labels Apr 9, 2022
@kcristiano
Copy link
Member

r-run on upgrade from 5.47.4 to 5.48.0

Before patch I could replicate dev/core#3166 After applying patch that error is solved and upgrades can proceed as 'normal'.

@demeritcowboy demeritcowboy merged commit ac00628 into civicrm:5.49 Apr 10, 2022
@demeritcowboy
Copy link
Contributor

I had a problem with civigrant again which I first thought might be related but seems to be with or without. So seems ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants