Skip to content

Full sync: Ensure procesing of start end cancel actions in wpcom #43287

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

Conversation

darssen
Copy link
Contributor

@darssen darssen commented Apr 29, 2025

Fixes VULCAN-74

Proposed changes:

  • Full Sync Status Enhancements:
    • Add three new keys to the full sync status:
      • start_action_processed: Tracks whether the jetpack_full_sync_start action has been successfully processed.
      • cancelled_action_processed: Tracks whether the jetpack_full_sync_cancelled action has been successfully processed.
      • context: Stores the original context (e.g., initial-sync ) of the full sync request.
  • New Private Methods:
    • maybe_send_cancelled_action():
      • Tries to send the jetpack_full_sync_cancelled action if needed.
      • Updates the status upon successful sending.
      • Retries sending on future runs if the action fails.
    • maybe_send_full_sync_start():
      • Tries to send the jetpack_full_sync_start action if needed.
      • Updates the progress and marks the start action as processed upon success.
      • Retries on future runs if sending fails.
  • Update send() Flow:
    • Always call maybe_send_cancelled_action() first.
    • Then call maybe_send_full_sync_start().
    • Only proceed with sending regular sync items after both actions have been successfully processed.
    • Fail early if sending either the cancel or start action fails.
  • Update send_full_sync_end():
    • Ensure jetpack_full_sync_end is sent before marking the sync as finished.
    • Skip setting finished status if sending full_sync_end fails.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

No

Testing instructions:

Run a Full Sync and check nothing major changed

In Debugger, run a Full Sync of Everything and check that all actions are processed as expected.

Try sabotaging the different actions to see that we retry them until they are processed

Similar to what was done in #43229, we will sabotage the processing of full sync actions in WPCOM by adding something like below snippet inside process_event after getting the action name.

if ( 'jetpack_full_sync_start' === $action_name ) {
	error_log('Trying start but not allowed');
	die();
}

Also, to speed up things, we could lower LOCK_TRANSIENT_EXPIRY to something like 10s. We could also lower the 60 seconds to 10 here since we will be processing WP_Errors and setting the RETRY_AFTER_PREFIX option to not try after 1 minute.
Start

  • Sabotage the jetpack_full_sync_start action, start a full sync.
  • Start a Full Sync
  • Check that you get the error in your sandbox.
  • Refresh wp_admin after a minute ( or whatever time you need to wait based on LOCK and RETRY) and check that we try again to send a start action by seeing the log again.
  • No matter how long you wait, the Full Sync will not send any module. Debugger marks the Full SYnc as started which is correct and is based on the status, but the new start_action_processed should be set to false

Cancelled

  • Remove the sabotaging for a moment and check that Full Sync is in progress in Debugger
  • Soon after that (while the Full Sync is in progress), sabotage the full sync but this time for the jetpack_full_sync_cancelled action. Change the error message to show Trying cancelled but not allowed
  • Start a new Full Sync
  • Check that you get the new error in your sandbox.
  • Refresh wp_admin and check that Full Sync does not proceed.
  • No matter how long you wait, the Full Sync will not proceed.
  • Remove the sabotaging.
  • By refreshing wp_admin, check that Full Sync actions start to flow again for the new full sync.

End

  • Sabotage the jetpack_full_sync_end action. Change the error message to show Trying end but not allowed
  • Check that you get the new error in your sandbox.
  • Refresh wp_admin and check that Full Sync never really finishes.
  • No matter how long you wait, the Full Sync will never finish.
  • Remove the sabotaging.
  • Refresh wp_admin and check that Full Sync finishes.

Copy link
Contributor

github-actions bot commented Apr 29, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the update/full-sync-ensure-procesing-of-start-end-cancel-actions-in-wpcom branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/full-sync-ensure-procesing-of-start-end-cancel-actions-in-wpcom
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/full-sync-ensure-procesing-of-start-end-cancel-actions-in-wpcom

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

github-actions bot commented Apr 29, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: May 6, 2025
    • Code freeze: May 5, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Apr 29, 2025
@darssen darssen self-assigned this Apr 29, 2025
@darssen darssen requested a review from a team April 29, 2025 15:35
@darssen darssen added [Package] Sync [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it and removed [Package] Sync [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Apr 29, 2025
Copy link

jp-launch-control bot commented Apr 29, 2025

Code Coverage Summary

Coverage changed in 13 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/packages/sync/src/class-listener.php 27/153 (17.65%) -41.18% 63 💔
projects/packages/sync/src/modules/class-full-sync-immediately.php 31/179 (17.32%) -23.24% 63 💔
projects/packages/sync/src/modules/class-callables.php 18/182 (9.89%) -14.84% 27 💔
projects/packages/sync/src/class-actions.php 190/397 (47.86%) -3.78% 15 💔
projects/packages/sync/src/modules/class-options.php 21/110 (19.09%) -10.91% 12 💔

Full summary · PHP report · JS report

Coverage check overridden by Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code .

@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests labels Apr 30, 2025
@darssen darssen marked this pull request as ready for review April 30, 2025 12:29
@darssen darssen added Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Apr 30, 2025
Copy link
Contributor

@fgiannar fgiannar left a comment

Choose a reason for hiding this comment

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

Great work here @darssen 👍

Looks and tests well :shipit:

Copy link
Contributor

@coder-karen coder-karen left a comment

Choose a reason for hiding this comment

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

Tests well :)

@darssen darssen merged commit 672512b into trunk May 2, 2025
93 checks passed
@darssen darssen deleted the update/full-sync-ensure-procesing-of-start-end-cancel-actions-in-wpcom branch May 2, 2025 08:57
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label May 2, 2025
@github-actions github-actions bot added this to the jetpack/14.6 milestone May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code [Package] Sync [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests [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.

3 participants