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

Try to set longer timeouts for Register() in connect #7736

Merged
merged 2 commits into from
Sep 25, 2017

Conversation

gravityrail
Copy link
Contributor

@gravityrail gravityrail commented Sep 1, 2017

When users connect Jetpack, the very first step is registration.

A couple of hundred sites a day fail registration because of timeouts, and of these the vast majority are sending us a timeout of 15 seconds or less (the timeout sent by Jetpack is 50% of the max_execution_time, to allow for multiple connection attempts).

This is because in order to register the site, WPCOM must make a couple of requests, and some Jetpack sites are pretty slow.

Some sites appear to have execution timeouts as short as 10 seconds, which is not anywhere near enough to register a lot of the time.

This change tells PHP to increase the local max_execution_time for the duration of the register() step so that WPCOM has more time to register the site. If the request timeout is already longer than 60 seconds, it leaves it unaltered.

To test:

  • set max_execution_time to < 60 seconds in php.ini
  • add logging of $args for register step
  • register Jetpack site
  • observe that timeout sent to WPCOM is 30 seconds

@gravityrail gravityrail requested a review from a team as a code owner September 1, 2017 18:22
@gravityrail gravityrail modified the milestones: 5.3, 5.4 Sep 1, 2017
@gravityrail gravityrail force-pushed the fix/timeouts-for-register branch from e51d603 to 2c56fe0 Compare September 6, 2017 17:47
@jeherve jeherve added General [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it labels Sep 8, 2017
/**
* Sets a minimum request timeout, and returns the current timeout
*
* @since 5.3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to update this to 5.4.

Copy link
Contributor

@ebinnion ebinnion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some feedback. Besides that, this makes sense to me.

The bigger things that we should fix are the doc block and perhaps deprecating the old function somehow.

@@ -4776,11 +4776,25 @@ public static function delete_secrets( $action, $user_id ) {
* @since 2.6
* @return int
**/
public function get_remote_query_timeout_limit() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're effectively deleting and creating a new method here, we should probably update the @since.

@@ -4776,11 +4776,25 @@ public static function delete_secrets( $action, $user_id ) {
* @since 2.6
* @return int
**/
public function get_remote_query_timeout_limit() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we find a way to deprecate get_remote_query_timeout_limit() to minimize errors if other plugins are using this?

$timeout = (int) ini_get( 'max_execution_time' );
if ( ! $timeout ) // Ensure exec time set in php.ini
$timeout = 30;
return intval( $timeout / 2 );
$timeout = 30;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're touching this code, can we add the { and } around the if conditional?

$timeout = (int) ini_get( 'max_execution_time' );
if ( ! $timeout ) // Ensure exec time set in php.ini
$timeout = 30;
return intval( $timeout / 2 );
$timeout = 30;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, there are leading spaces before all lines except one in this method. That's a minor nitpick, but should be an easy fix if you go back in.

Copy link
Member

@zinigor zinigor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes lots of sense to me, let's get this in. Thanks for a very constructive review, @ebinnion !

@zinigor zinigor added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Sep 25, 2017
@dereksmart dereksmart dismissed ebinnion’s stale review September 25, 2017 22:19

seems as though all of the feedback was addressed

@dereksmart dereksmart merged commit 9b97676 into master Sep 25, 2017
@dereksmart dereksmart deleted the fix/timeouts-for-register branch September 25, 2017 22:19
@dereksmart dereksmart removed the [Status] Ready to Merge Go ahead, you can push that green button! label Sep 25, 2017
jeherve added a commit that referenced this pull request Sep 26, 2017
dereksmart added a commit that referenced this pull request Sep 26, 2017
* initial commit for running changelog

* Update stable tag in readme

* Changelog: move old releases to changelog.txt.

Also add release post URL for 5.4

* Changelog: add #7729

* Changelog: add #7736

* Changelog: add #7737

* Changelog: add #7740

* Changelog: add #7742

* Changelog: add #7366

* Changelog: add #7664

* Changelog: add #7751

* Changelog: add #7764

* Changelog: add #7768

* Changelog: add #7796

* Changelog: add #7798

* Changelog: add #7822

* Changelog: add #7824

* Changelog: add #7825

* Changelog: add #7826

* Changelog: add #7829

* Changelog: add #7831

* Changelog: add #7837

* Changelog: add #7850

* Changelog: add #7852

* Changelog: add #6538

* Changelog: add #7767

* Changelog: add #7782

* Changelog: add #7797

* Changelog: add #7819

* update to-test to add misc stuff

* add comment edit fix to changelog
dereksmart added a commit that referenced this pull request Sep 26, 2017
* initial commit for running changelog

* Update stable tag in readme

* Changelog: move old releases to changelog.txt.

Also add release post URL for 5.4

* Changelog: add #7729

* Changelog: add #7736

* Changelog: add #7737

* Changelog: add #7740

* Changelog: add #7742

* Changelog: add #7366

* Changelog: add #7664

* Changelog: add #7751

* Changelog: add #7764

* Changelog: add #7768

* Changelog: add #7796

* Changelog: add #7798

* Changelog: add #7822

* Changelog: add #7824

* Changelog: add #7825

* Changelog: add #7826

* Changelog: add #7829

* Changelog: add #7831

* Changelog: add #7837

* Changelog: add #7850

* Changelog: add #7852

* Changelog: add #6538

* Changelog: add #7767

* Changelog: add #7782

* Changelog: add #7797

* Changelog: add #7819

* update to-test to add misc stuff

* add comment edit fix to changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants