1

Occasionally—I'd say about 30-40% of the time—when submitting a form in the backend, be it saving an entry, updating a custom field, etc, the page will just sit there, loading. This can and often does continue for ~ 299.88 seconds, after which it will proceed to the next screen as if nothing ever happened.

I've looked through the console log, but all the timestamps seem to be within a second of each other, so nothing jumps out as the step where things are getting hung up. I suspect a server problem, but I'm posting here just in case anyone can point me in a more specific direction than "there's a problem somewhere".

To date, this has not occurred on the frontend, but there aren't any frontend forms to submit, either.

Pastebin of the console log (the load time is on line 725): https://pastebin.com/aB4JkrBv

3

I can think of a couple things why this is happening:

1) Custom code doing a save operation.

If you're hooking into onSaveEntry for example, Craft also lets other plugins have a chance at calling their own save code as well.

So when you do a saveEntry (or other element), Craft is going to repeat that call when you do it from your own code, basically putting you into an infinite loop because it keeps getting called until the server times out.

The fix is to make sure you only call saveEntry once. There's a couple ways to do this depending on what you're trying to do.

One way to debug this would be to a create super simple plugin, using Business Logic or PluginFactory that listens for the saveEntry event and logs it.

If you see the plugin's log fill up, then some plugin is putting itself into a loop more than once.

2) runTasksAutomatically is not being called

Over time, Craft generates a lot of cache files, sessions, etc. Craft will automatically do some housekeeping for you and clean this up, however, the runTasksAutomatically config doesn't run on some server setups, forcing you to do the maintenance yourself. It's like a stuffed up drain, if it doesn't run for awhile, it takes longer to purge.

If your server doesn't support cron, you could use an uptime monitoring service like Uptime Robot or Pingdom to trigger the task call for you periodically.

| improve this answer | |
  • Ok, so to debug things, if #1 is the culprit, would disabling all third-party plugins resolve the issue? And where would I see info about runTasksAutomatically? I looked in both the Server Info and Craft Logs screens but found nothing to indicate it wasn't successfully running. The server does appear to have gzip enabled though, which the docs mention is incompatible with runTasksAutomatically. So I'm guessing that's the culprit? – Sandwich Oct 9 '17 at 7:42
  • I've updated my answer for a couple ways you could test this for both. #2 is more insidious. It seems to only happen on Apache, not nginx. I've used PHP's FPM on both and Apache has always given me problems. No need for cron on nginx, it just works. – RitterKnight Oct 10 '17 at 17:57
  • Ok, cool... I still would like to know if disabling 3rd-party plugins would address #1; I barely have any installed, and the site is still in development, so it's easy to do. As for #2, the sysadmin already disabled gzip (and replaced it with "php compression"), so I'll be testing that for a bit. – Sandwich Oct 11 '17 at 11:02
  • @Sandwich: yeh disabling would do the same thing. – RitterKnight Oct 11 '17 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.