Make WordPress Core

Opened 8 years ago

Last modified 4 years ago

#39340 new defect (bug)

Scheduled Posts are being missed (problem with wp-cron.php?)

Reported by: remarkablemike's profile remarkablemike Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.6.1
Component: Cron API Keywords:
Focuses: Cc:

Description

Scheduled posts are missing their set time. This is not an issue with out server times, nor is it an issue with the cron jobs.

I have seen that many other users are experiencing problems with this, but as of yet there has been no word from WordPress.

Has this been fixed in 4.7? Or is this still outstanding?

Attachments (2)

20170212_1315_CronManager_p1.png (67.2 KB) - added by daviding 7 years ago.
WPX Cron Manager Light p1 showing wp_version_check 13 days late
20170212_1315_CronManager_p3.png (61.1 KB) - added by daviding 7 years ago.
WPX Cron Manager Light p3 showing lifestream_cron reset, but it doesn't run

Download all attachments as: .zip

Change History (13)

#1 in reply to: ↑ description @edent
8 years ago

Replying to remarkablemike:

Has this been fixed in 4.7? Or is this still outstanding?

I have this problem with 4.7–en_GB.

I've tried using Alternative_Cron, disabling plugins, disabling Cloudflare, and manually visiting pages during scheduled times - but it still doesn't work.

Other cron jobs work on my server.

Given the large numbers of people having this problem, and the popularity of plugins which claim to solve this issue, I suspect it is a fundamental flaw with how WordPress works.

As per https://developer.wordpress.org/plugins/cron/

WP-Cron will run tasks regardless of how old they are. Tasks will sit in a queue until a page is loaded to trigger them, thus no task will ever be lost.

This is now demonstrably false.

My suspicion is that wp-cron is failing in an unspecified way. There was a proposal to display detailed error messages - but it was abandoned #23133

Using get_cron_array(), I can see that future posts are being placed in the schedule:

[1484813336] => Array
        (
            [publish_future_post] => Array
                (
                    [0da9aa88af9739142d6b46c1ce06de2d] => Array
                        (
                            [schedule] => 
                            [args] => Array
                                (
                                    [0] => 24563
                                )

                        )

                )

        )

I wonder if there's a problem with the schedule there? Other jobs look like this

[1484187126] => Array
        (
            [jetpack_v2_heartbeat] => Array
                (
                    [40cd750bba9870f18aada2478b24840a] => Array
                        (
                            [schedule] => daily
                            [args] => Array
                                (
                                )

                            [interval] => 86400
                        )

                )

        )

I don't *think* that there should be a schedule for one off events like posting a blog, but I can't be sure.

Last edited 8 years ago by SergeyBiryukov (previous) (diff)

#2 @SergeyBiryukov
8 years ago

  • Component changed from General to Cron API

@daviding
7 years ago

WPX Cron Manager Light p1 showing wp_version_check 13 days late

@daviding
7 years ago

WPX Cron Manager Light p3 showing lifestream_cron reset, but it doesn't run

#3 follow-up: @daviding
7 years ago

  • Summary changed from Scheduled Posts are being missed to Scheduled Posts are being missed (problem with wp-cron.php?)

It's possible that I might have a related problem. I recently moved web hosting providers, and am having a problem that the cron for the wp-lifestream plugin isn't working. However, I have now installed the WPX Cron Manager Light plugin, and there are many other plugins that aren't working. I have attached some screen captures from WPX Cron Manager.

On page 1, wp_version_check is listed as 13 days late.

https://core.trac.wordpress.org/attachment/ticket/39340/20170212_1315_CronManager_p1.png

I have pushed the "Execute Now" for lifestream_cron, which updates the timer, but the actual cron has not created any updates.

https://core.trac.wordpress.org/attachment/ticket/39340/20170212_1315_CronManager_p3.png

I am running Wordpress 4.7.2.

In wp-config.php, I have tried setting ALTERNATE_WP_CRON as directed at https://codex.wordpress.org/Editing_wp-config.php#Alternative_Cron , but this doesn't not seem to help.

If someone would like to suggest additional diagnostic steps, they would be welcomed.

#4 in reply to: ↑ 3 @vonkoga
7 years ago

I had the same problem, and figured out that due to server resource overload, hoster disabled cron automaticaly because it sensed a security issue. You should fix your webpage serving issue, and optimize it more efficiently, or transfer to more resourceful hosting package.

Replying to daviding:

It's possible that I might have a related problem. I recently moved web hosting providers, and am having a problem that the cron for the wp-lifestream plugin isn't working. However, I have now installed the WPX Cron Manager Light plugin, and there are many other plugins that aren't working. I have attached some screen captures from WPX Cron Manager.

On page 1, wp_version_check is listed as 13 days late.

https://core.trac.wordpress.org/attachment/ticket/39340/20170212_1315_CronManager_p1.png

I have pushed the "Execute Now" for lifestream_cron, which updates the timer, but the actual cron has not created any updates.

https://core.trac.wordpress.org/attachment/ticket/39340/20170212_1315_CronManager_p3.png

I am running Wordpress 4.7.2.

In wp-config.php, I have tried setting ALTERNATE_WP_CRON as directed at https://codex.wordpress.org/Editing_wp-config.php#Alternative_Cron , but this doesn't not seem to help.

If someone would like to suggest additional diagnostic steps, they would be welcomed.

#5 @daviding
7 years ago

@vonkoga Thanks for the followup.

I worked with my web provider (PlanetHoster), disabled the Wordpress virtual cron, and created the cron in cPanel. The instructions varied a little bit from https://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/configuring-a-cron-job-for-wordpress , but that's the general idea.

My problem wasn't a server resource overload. My shared web hosting comes with 4GB of RAM (!) and it typically runs at less than half of that, across multiple web domains. I still haven't got a definitive diagnosis of the problem, but have dissolved it by configuring in cPanel.

#6 @archon810
5 years ago

WP's problem with posting scheduled posts reliably, even if they're slightly late - better a bit late than never or really late - has been plaguing it for years. It's time to resolve it.

Numerous solutions have been created, but they're all bloated or use up too many resources (such as checking on every page load):

https://github.com/sLaNGjI/wp-missed-schedule

https://wordpress.org/plugins/scheduled-post-trigger/
https://wordpress.org/support/topic/switch-logic-to-wp-cron/

etc.

Can WP just sort this out so it's not a problem almost every day?

Thanks.

#7 @Mte90
4 years ago

I have the same problem, on the latest 5.3.2 with wordpress under cloudflare with this in the wp-config.php, cron executed by the system cron using php wp-cron.php every 5 minutes on sunday the posts scheduled on that day are not published.

<?php
define('DISABLE_WP_CRON', true);

Debugging the file the script is executed rightly and I don't see any errors but in the dashboard they are marked as missed scheduled. I see that during the week the posts scheduled are published with no errors but just on sunday where the backend is not used there are those issues.
As configured in this way I think that they should be published aldo without accessing the backend because now the cron is server side.

I was thinking to do a script that login on sunday every 5 minutes with a specific user on the backend just to get the posts pubished.

#8 @archon810
4 years ago

I've been digging into this issue for a while and discovered the real culprit - race conditions with the cron array in the db.

See #49520 for the details.

In the meantime, we've implemented a watchdog that fires every minute and checks for posts that had missed schedule.

We're also looking into Cavalcade as the proper solution.

#9 @Mte90
4 years ago

I am wondering if we can patch wordpress as it is now because before that someone reimplement the other ticket you mentioned (that I already saw) can takes years.

As I don't have any errors or some sample data to test is difficult for me to replicate outside production and write a patch.

#10 @Mte90
4 years ago

I am investigating this problem, as wp-cron.php doesn't fire any log information I added a error_log(print_r($crons, true)); at line 149 before the delete of the transient to track at every call what crons are found.

As I can see the crons are found but not executed:

    [1585036816] => Array
        (
            [publish_future_post] => Array
                (
                    [799cb85576dde4649c55321c2ce6e65b] => Array
                        (
                            [schedule] => 
                            [args] => Array
                                (
                                    [0] => 246700
                                )

                        )

                )

        )

So I am wondering if https://github.com/WordPress/WordPress/blob/7004afe4f4bac1fd17a142051832bdf6be8e6fcf/wp-includes/post.php#L4293 it is working.
As I can see this function check_and_publish_future_post doesn't have any test and the last changes to that function are from a lot of years ago.

#11 @Mte90
4 years ago

In my testing, seems that check_and_publish_future_post is not invoked on some posts also if should do it.
The event is removed on deleting the post https://github.com/WordPress/WordPress/blob/7004afe4f4bac1fd17a142051832bdf6be8e6fcf/wp-includes/post.php#L3059 but I cannot see any mention of that execution.

Maybe that hook should be fired more often? It can explain why they appear as post but no cron is executed for them.

Last edited 4 years ago by Mte90 (previous) (diff)
Note: See TracTickets for help on using tickets.