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

Sync: Callables: Allow shutdown sync on CLI commands #12924

Closed
nickdaugherty opened this issue Jul 2, 2019 · 14 comments
Closed

Sync: Callables: Allow shutdown sync on CLI commands #12924

nickdaugherty opened this issue Jul 2, 2019 · 14 comments
Assignees
Milestone

Comments

@nickdaugherty
Copy link
Contributor

nickdaugherty commented Jul 2, 2019

Steps to reproduce the issue

  1. Run wp option update home https://some-new-domain.com
  2. Check the home option on WP.com / Jetpack side - it's unchanged
  3. "Manually" sync callables (such as via the JP Debug tool)
  4. home is now correct on WP.com / Jetpack side

What I expected

Like other content changes that are synced on shutdown, changing options that are handled via "functions/callables" should also cause a sync on shutdown.

What happened instead

The new value was not synced until a sync was manually triggered.

This is because of the conditional here:

if ( ! is_admin() || Settings::is_doing_cron() ) {

Related - it also bails on Cron, which doesn't seem great, because then callables are only synced on admin requests - is that still desired?

cc @Automattic/poseidon

@gititon
Copy link
Contributor

gititon commented Jul 17, 2019

Hi @nickdaugherty,

I wanted to let you know that I've been working on this issue. At this point it's a matter of getting all of the tests passing, which I hope to finish tomorrow.

@tyxla
Copy link
Member

tyxla commented Jul 18, 2019

Hey @nickdaugherty we've also got the tests to pass, so the PR is also in a testable state right now.

We'd appreciate your help in testing/reviewing the PR in order to ship it and resolve the issue as soon as possible.

@jeherve jeherve added this to the 7.6 milestone Jul 18, 2019
@gititon
Copy link
Contributor

gititon commented Jul 18, 2019

@nickdaugherty #13015 has been merged, so this should work now.

@nickdaugherty
Copy link
Contributor Author

Thanks @gititon, much appreciated!

@nickdaugherty
Copy link
Contributor Author

Hey @gititon, I did some testing and I don't think it's quite fixed. The changes come through eventually (I'm guessing through cron), but not in direct response to the CLI command itself, it seems.

I left a note on the PR, I think we're still not properly doing the sync on shutdown for CLI commands, b/c it aborts if the request isn't Cron (which WP CLI is not).

jeherve added a commit that referenced this issue Jul 19, 2019
@gititon
Copy link
Contributor

gititon commented Jul 22, 2019

Hi @nickdaugherty , can you please try again on master and confirm whether the latest changes do the trick? Thanks!

@nickdaugherty
Copy link
Contributor Author

nickdaugherty commented Jul 22, 2019

Hey @gititon, I just retested on fresh build of master, and there are 2 things not working right for me:

The home option syncs correctly and instantly the first 2 times I run it. However, it then stops syncing once the jetpack_sync_callables_await transient exists (which I guess is by design?). The problem is, if a site has that lock for something else, then you run wp option update home https://my-new-domain.com, the new value doesn't get synced, so the syncing is unreliable. It syncs again once the transient expires (60s).

The other problem is that siteurl doesn't seem to be updating at all. I think that's because we also need to map siteurl => site_url in this mapping (?):

'home' => 'home_url',

wp option update siteurl https://my-new-domain.com doesn't sync the new value up.

@gititon
Copy link
Contributor

gititon commented Jul 25, 2019

Thanks for your feedback, @nickdaugherty. I'll prepare another patch in the morning to address site_url and give the wait time some thought. For context, can you please tell me why we need these options to bypass normal sync constraints and always sync immediately?

@gititon
Copy link
Contributor

gititon commented Jul 25, 2019

Hi @nickdaugherty,

I have a pull request in that will let siteurl sync as well, and ensures that both siteurl and home sync instantly when changed via WP CLI, #13132.

@gititon
Copy link
Contributor

gititon commented Jul 26, 2019

Hi @nickdaugherty, #13132 has been merged, so you should have the additional functionality you were looking for now.

@nickdaugherty
Copy link
Contributor Author

nickdaugherty commented Jul 26, 2019

Awesome, I'll try it out as soon as I can. To answer your question, the use case is launching a new site - site has a "placeholder" domain up until the point of DNS switching, then DNS is flipped and the home/siteurls are updated back to back...so it'll start receiving traffic and it's important the cache site is in sync. Technically a delay of a minute or two may be ok, but IMO better to do it straight away.

@gititon
Copy link
Contributor

gititon commented Jul 26, 2019

Roger that, thanks for filling me in, @nickdaugherty. Please let me know how it works for you when you have a chance.

@jeherve
Copy link
Member

jeherve commented Jul 29, 2019

Closing this for now since #13132 has been merged. @nickdaugherty Feel free to reopen if there are still issues in your testing.

@jeherve jeherve closed this as completed Jul 29, 2019
@nickdaugherty
Copy link
Contributor Author

Awesome, tested it out and it seems much better. Changing the home/siteurl several times in a row occasionally ended up with out-of-date data on the cache site, but it does seem much more reliable (and siteurl now syncs). Thanks for working on this!

jeherve added a commit that referenced this issue Jul 30, 2019
* Add initial changelog / testing list changes for 7.6

* Update stable tag to 7.5.3

* changelog: add #12957

* Changelog: add #12932

* Changelog: add #12867

* Changelog: add #12823

* changelog: add #12969

* changelog: add #13012

* changelog: add #12974

* Changelog: add #13059

* Changelog: add #13079

* Changelog: add #12924

* changelog: add #12954

* Changelog: add #12959

* Changelog: add #12977

* Changelog: add #12830

* Changelog: add #12926

* Changelog: add #12958

* Changelog: add #12999

* Changelog: add #13077

* Changelog: add #13083

* Changelog: add #13087

* Changelog: add #13110

* Changelog: add #13116

* Changelog: add #13117

* Changelog: add #12821

* Changelog: add #13120

* changelog: add #13139

* Changelog: add #13143

* Changelog: add #13147

* Testing list: add section about sync
jeherve added a commit that referenced this issue Jul 30, 2019
* Add initial changelog / testing list changes for 7.6

* Update stable tag to 7.5.3

* changelog: add #12957

* Changelog: add #12932

* Changelog: add #12867

* Changelog: add #12823

* changelog: add #12969

* changelog: add #13012

* changelog: add #12974

* Changelog: add #13059

* Changelog: add #13079

* Changelog: add #12924

* changelog: add #12954

* Changelog: add #12959

* Changelog: add #12977

* Changelog: add #12830

* Changelog: add #12926

* Changelog: add #12958

* Changelog: add #12999

* Changelog: add #13077

* Changelog: add #13083

* Changelog: add #13087

* Changelog: add #13110

* Changelog: add #13116

* Changelog: add #13117

* Changelog: add #12821

* Changelog: add #13120

* changelog: add #13139

* Changelog: add #13143

* Changelog: add #13147

* Testing list: add section about sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants