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#174) civicrm_cache - Finish transition from DATETIME to TIMESTAMP #12368

Merged
merged 1 commit into from
Jun 29, 2018

Conversation

totten
Copy link
Member

@totten totten commented Jun 27, 2018

Overview

v4.7.20 (4387c66) updated the definition of civicrm_cache so that created_date and expired_date would default to TIMESTAMP on new deployments. For existing deployments, status-checks and DoctorWhen have been encouraging a transition, but it wasn't mandated, and there was little urgency... because expired_date was generally ignored, and adhoc TTLs on created_date had generally long windows.

However, in v5.4, we'll be using expired_date in more important ways (dev/core#174), and we should ensure that these values are handled precisely and consistently.

Before

  • On new deployments (4.7.20+), created_date and expired_date are TIMESTAMP.
  • On upgraded deployments, created_date and expired_date may be using DATETIME or TIMESTAMP (depending on the particular history and administrative decisions).

After

  • On all deployments, created_date and expired_date are TIMESTAMPs.

Comments

In the interest of full disclosure -- I expect there are scenarios in which having expired_date as DATETIME will lead to bugs in 5.4+, but I haven't empirically proven it. This patch preemptively reduces the number of edge-cases we have to consider in managing cache TTLs.

Generally, I'm inclined to view the change as safe because (a) all new deployments since 4.7.20 have been using this schema anyway and (b) nothing in civicrm-core has been using expired_date.

CC @seamuslee001 (resident expert in timezones). Also, ping @scardinius @systopia. (Grepping universe, I found de.systopia.campaign does a few direct queries on this table - so maybe you have some thought?)

v4.7.20 updated the definition of `created_date` and `expired_date` so that
new installs would default to TIMESTAMP instead of DATETIME.  Status-checks
and DoctorWhen have been encouraging a transition, but it wasn't mandated,
and there was little urgency...  because `expired_date` was ignored, and
adhoc TTLs on `created_date` had generally long windows.  Now that we're
using `expired_date` in more important ways for 5.4 (dev/core#174), we want
to ensure that these values are handled precisely and consistently.

Before
------------------------------
* On new deployments, `created_date` and `expired_date` are TIMESTAMP.
* On upgraded deployments, `created_date` and `expired_date` may
  be using DATETIME or TIMESTAMP (depending on the particular history
  and administrative decisions).

After
------------------------------
* On all deployments, `created_date` and `expired_date` are TIMESTAMP.
@civibot
Copy link

civibot bot commented Jun 27, 2018

(Standard links)

@seamuslee001
Copy link
Contributor

Looks fine to me makes sense, @totten i wonder will this have an impact on current caches and should caches get busted after this upgrade step so that expired and created dates are all re-generated?

@totten
Copy link
Member Author

totten commented Jun 27, 2018

...should caches get busted after this upgrade step so that expired and created dates are all re-generated?

I was wondering about that too. Poking into CRM/Upgrade/Form.php, it will truncate the table as a pro-forma step in the upgrade process (doFinish() ==> $config->cleanupCaches(1);).

@seamuslee001
Copy link
Contributor

ok i think that is ok then, That should ensure that all caches are set properly after the upgrade

@eileenmcnaughton
Copy link
Contributor

I agree this is safe - we have a long history of using timestamp fields where previously date time fields have been used without problems. In the case of the cache tables we are very clearly dealing with a field that should be timestamp. Merging

@eileenmcnaughton eileenmcnaughton merged commit e427e3a into civicrm:master Jun 29, 2018
@totten totten deleted the master-cache-schema branch June 29, 2018 23:10
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.

4 participants