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

Cron uses the wrong timestamp method #9943

Merged
merged 2 commits into from
Jun 16, 2017

Conversation

AntonEvers
Copy link
Contributor

@AntonEvers AntonEvers commented Jun 14, 2017

Description

Because the cron job uses a localized timestamp instead of a regular
timestamp, all times in the cron_schedule table are not the actual
times, but times with a double offset.

By using the regular timestamp, all times in cron_schedule are correct.
The cron job execution times are not affected by this change because
schedule generation and job execution depend on the same timestamp.
If both are in the same timezone all will go as intended.

Fixes #4237

Fixed Issues (if relevant)

  1. Cron times in the database have a double timezone correction #4237: Cron times in the database are not UTC

Manual testing scenarios

  1. truncate the cron_schedule table
  2. flush the caches
  3. execute bin/magento cron:run
  4. verify that the earliest created_at time in the database is the current time
  5. wait for one minute
  6. execute bin/magento cron:run again
  7. verify that the earliest executed_at time in the database is the current time
  8. verify that only the jobs that are supposed to run based on their scheduled_at time, have run

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

Anton Evers added 2 commits June 14, 2017 14:47
Because the cron job uses a localized timestamp instead of a regular
timestamp, all times in the cron_schedule table are not the actual
times, but times with a double offset.

By using the regular timestamp, all times in cron_schedule are correct.
The cron job execution times are not affected by this change because
schedule generation and job execution depend on the same timestamp.
If both are in the same timezone all will go as intended.

Fixes magento#4237
@okorshenko okorshenko self-assigned this Jun 14, 2017
@okorshenko okorshenko added this to the June 2017 milestone Jun 14, 2017
@magento-team magento-team merged commit e080dde into magento:develop Jun 16, 2017
ktomk added a commit to netz98/n98-magerun2 that referenced this pull request Jun 16, 2017
Since Magento 2.2.0 the cron database tables will use GMT timestamps,
before that version Magento has used timestamps in a different timezone.

Fix is to branch based on Magento version:

a) Use GMT timestamps from version 2.2.0 or above.

b) Use local timestamps up to version 2.2.0

Refs:

- Command: sys:cron:run

- Command: sys:cron:schedule

- #296

- magento/magento2#9943
cmuench pushed a commit to cmuench/n98-magerun2 that referenced this pull request Oct 11, 2017
Since Magento 2.2.0 the cron database tables will use GMT timestamps,
before that version Magento has used timestamps in a different timezone.

Fix is to branch based on Magento version:

a) Use GMT timestamps from version 2.2.0 or above.

b) Use local timestamps up to version 2.2.0

Refs:

- Command: sys:cron:run

- Command: sys:cron:schedule

- #296

- magento/magento2#9943
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants