#34878 closed defect (bug) (fixed)
Core Auto Updater Needs to be Aware of Manual Updates
Reported by: | aaroncampbell | Owned by: | dd32 |
---|---|---|---|
Milestone: | 4.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Upgrade/Install | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description
Some of the "critical failures" that we get for automatic core updates of major releases are actually a race condition between a manual update and an auto update.
The auto updater uses an option called auto_updater.lock
to avoid race conditions with itself, but that needs to be extended to account for manual updates as well.
Example:
- A user clicks upgrade and a manual upgrade starts
- WordPress checks and sees that an update is needed and starts and auto update
- The zip is downloaded and extracted by the manual upgrade and it begins to copy files
- The zip is downloaded and extracted to the same location by the auto-update upgrade and it begins to copy files
- The manual update finishes and removes the files it was copying from
- The auto-updater is still trying to copy files, but they no longer exist because the manual updater removed them.
This can happen in either order (manual update can fail because the auto updater finished first).
These two upgrade processes need to be aware of each other.
Attachments (1)
Change History (9)
#2
follow-up:
↓ 3
@
9 years ago
- Keywords has-patch needs-testing added
34878.diff is a first pass at this.
To test, I suggest adding a sleep(120)
after locking and attempting to start another manual update in another window.
One thing worth noting in this patch, was I introduced wp_create_lock()
and wp_release_lock()
, these may be moved internally to the upgraders.
#4
@
9 years ago
- Owner set to dd32
- Resolution set to fixed
- Status changed from new to closed
In 36349:
#5
@
9 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
WP_Automatic_Updater::run()
calls $this->create_lock()
and $this->release_lock()
, both methods of WP_Upgrader
, which causes a fatal: https://travis-ci.org/wp-cli/wp-cli/jobs/103627421
For what it's worth, this is no longer the case in 4.4+, both updates will now succeed as they're copying from unique directories, but we should still attempt to prevent the two updates occurring at the same time to improve the chances that the one which is running will succeed.
Another scenario is where two site admins see the update alert, and hit update at roughly the same time.