Clean WordPress API cache during account and site removal - #25864
Open
crazytonyli wants to merge 3 commits into
Open
Clean WordPress API cache during account and site removal #25864crazytonyli wants to merge 3 commits into
crazytonyli wants to merge 3 commits into
Conversation
Delete SQLite sibling files together with the database, clean up orphaned journal files before creating a new database, and model the result of opening the on-disk cache as an OnDiskCacheOutcome (opened, recovered, or failed) carrying a typed OnDiskCacheFailure. bootstrap() reports failures (each kind from its own call site so wpAssertionFailure's file/line-based analytics identity and suppression stay per-kind) and falls back to the in-memory cache, while the pure worker lets unit tests drive the recovery path without tripping assertionFailure in Debug. A failure to remove a sibling next to a fresh database is itself a corruption vector, so it fails rather than reopening against a stale journal.
Per-client cache instances each opened a connection to the same app.sqlite and re-ran migrations with BEGIN EXCLUSIVE, so concurrent bootstraps could fail with SQLITE_BUSY and delete a database other connections still had open (Sentry JETPACK-IOS-1KCJ). A process-wide shared instance bootstraps once, matching the Android app's singleton cache. Test helpers that built a service from bootstrap() now use the shared instance since bootstrap() is private.
Removing an account or site left its cached API data in app.sqlite, so a later re-add could read stale entries. Delete the cached data for each affected site during removal. The cleanup runs on the process-wide WordPressApiCache.shared instance rather than opening a separate connection to the database. A second connection would reintroduce the bootstrap contention this branch eliminates and would not notify the shared instance's update listeners, since SQLite update hooks fire only for writes on their own connection.
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 33589 | |
| Version | PR #25864 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | b0d3966 | |
| Installation URL | 5o4guceqaht8g |
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 33589 | |
| Version | PR #25864 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | b0d3966 | |
| Installation URL | 0kfb3p9qpdl70 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Note
This is an alternative of #25853. I recommend reviewing this PR commit by commit.
Description
The main changes is in
WordPressApiCache.Every
WordPressClientopened its ownWordPressApiCacheagainst the sameapp.sqliteand re-ran migrations. This PR makes the cache a single process-wide instance and to avoid unnecessary migration runs, which matches the Android app's singleton cache.The main changes:
OnDiskCacheOutcome(opened, recovered, or failed) carrying a typed failure.WordPressApiCache.sharedinstead of bootstrapping per client, so the database is opened and migrated once per process.