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

[Dashboard] Add corruption handlers to Data Stores using Protocol Buffer schemas. #13058

Merged
merged 10 commits into from
Dec 4, 2024

Conversation

ThomazFB
Copy link
Contributor

@ThomazFB ThomazFB commented Dec 3, 2024

Note: This change was originally implemented here, but we recreated it since we decided to branch it off a release branch. Adding it here for reference, since the original PR contains discussions.

Summary

This is a follow-up to #12891, where reverting the Data Store library upgrade didn't clear the corrupted files to some users. We verified that the corruption exception we're getting is very likely to be connected with a parsing failure of the Protocol Buffer schemas we have in the app, affecting two Data Stores: Dashboard and CustomDateRange.

This PR adds a corruption handler to the DataStore creation, which simply restarts the DataStore with the default instance of each schema.

Additionally, this PR also updates all the Preferences DataStores used through the app to recover automatically and report the corruption event to Sentry.

Steps to Reproduce

Copy this file to your device in /data/data/com.woocommerce.android.dev/files/datastore.

  1. Open Dashboard
  2. Edit the custom range for Most active coupons card
  3. Tap on Save and verify the crash

Update release notes:

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@ThomazFB ThomazFB added type: crash The worst kind of bug. feature: dashboard Related to home screen project labels Dec 3, 2024
@ThomazFB ThomazFB added this to the 21.2 ❄️ milestone Dec 3, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented Dec 3, 2024

1 Warning
⚠️ This PR is assigned to the milestone 21.2 ❄️. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 3, 2024

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit5bfed0d
Direct Downloadwoocommerce-wear-prototype-build-pr13058-5bfed0d.apk

@ThomazFB
Copy link
Contributor Author

ThomazFB commented Dec 3, 2024

@malinajirka Regarding the hotfix procedures for this PR, given we're mid week already and a few days away from the Play Store submission, I'm considering avoiding a beta cut and letting go of the release right away instead. WDYT?

@ThomazFB
Copy link
Contributor Author

ThomazFB commented Dec 3, 2024

Also, to follow up on what we discussed in peaMlT-XN#comment-2680, I verified the Crash Logging injection instance during the app startup, and it's working as expected. We shouldn't see any issues, just as you predicted.

@wpmobilebot
Copy link
Collaborator

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit5bfed0d
Direct Downloadwoocommerce-prototype-build-pr13058-5bfed0d.apk

Copy link
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @ThomazFB !

I've tested the following flows:

  • Corrupted - /data/data/com.woocommerce.android.dev/files/datastore/custom_date_range_configuration.preferences_pb
  • Corrupted - /data/data/com.woocommerce.android.dev/files/datastore/dashboard_configuration_275
  • Corrupted - /data/data/com.woocommerce.android.dev/files/datastore/dashboard_coupons_custom_date_range_configuration.preferences_pb
  • Corrupted - /data/data/com.woocommerce.android.dev/files/datastore/tracker.preferences_pb
  • Login on clear app installation

All of them worked as expected, even those which are loaded on startup seem to have Sentry initialized. Having said that, I haven't tested the events get actually sent to Sentry - I'm having troubles enabling Sentry on a debuggable build and I can't corrupt the files on a production build.

I think it would be good to include flows that you tested in the description. Feel free to check the Manual Testing: The author listed all the... checkbox after you update the description. Thanks!

Regarding the hotfix procedures for this PR, given we're mid week already and a few days away from the Play Store submission, I'm considering avoiding a beta cut and letting go of the release right away instead. WDYT?

Considering the next release is on Monday, which is still several days away and more importantly, this change might potentially result in crashes on startup, I'd definitely suggest releasing a new beta. @toupper let us know in case you'd have a different opinion.

@malinajirka malinajirka merged commit 47ed84d into release/21.2 Dec 4, 2024
20 checks passed
@malinajirka malinajirka deleted the hotfix/recover-from-data-store-corruption branch December 4, 2024 09:57
@irfano
Copy link
Contributor

irfano commented Dec 4, 2024

A new beta, including this fix, has been published with 21.2-rc-3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: dashboard Related to home screen project type: crash The worst kind of bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants