TRIAGE-608: Add max persistence age override option#698
TRIAGE-608: Add max persistence age override option#698junias-rokt wants to merge 4 commits intomParticle:mainfrom
Conversation
PR SummaryMedium Risk Overview Wires this value through Adds instrumentation/unit tests covering builder validation, per-table delete semantics (strict Reviewed by Cursor Bugbot for commit c588b67. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit c588b67. Configure here.
| } finally { | ||
| db.endTransaction(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Swallowed exceptions defeat retry-on-failure throttle logic
Medium Severity
deleteRecordsOlderThan catches all exceptions internally and returns normally, so exceptions never propagate to the caller maybePrunePersistedRecords. This means mLastPersistenceCleanupMillis = nowMillis always executes — even when the sweep fails — arming the 24-hour throttle and preventing the documented retry-on-next-cycle behavior. The unit test passes only because it mocks deleteRecordsOlderThan to throw directly from the mock, bypassing the internal try-catch.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c588b67. Configure here.
|





Background
The iOS mParticle SDK exposes
MParticleOptions.persistenceMaxAgeSeconds, which caps the age of locally persisted events, batches, and sessions to prevent unbounded on-device storage growth. The Android SDK had no equivalent — once data was written to the SQLite store it would sit there until the app either uploaded it or was uninstalled. For apps that batch heavily, go long stretches offline, or see users who rarely background the app, this can produce noticeable storage bloat and a slow drift toward larger database files. TRIAGE-608 was opened to close this feature-parity gap and document it on the Android configuration guide.The companion iOS implementation lives in
MPBackendController.cleanUp:andMPPersistenceController deleteRecordsOlderThan:, which is the behavioral spec this change mirrors.What Has Changed
Public API
MParticleOptions.Builder#persistenceMaxAgeSeconds(int seconds)and the matching getterMParticleOptions#getPersistenceMaxAgeSeconds(). Units are seconds, values must be positive; zero or negative values log a warning and fall back to the default.Wiring
ConfigManagerso the upload pipeline can read it at runtime.Age-based sweep
MParticleDBManager#deleteRecordsOlderThan(long cutoffMillis)orchestrator wraps three new static helpers in a single transaction:MessageService#deleteMessagesOlderThan— deletes fromMessageTableColumns.TABLE_NAMEwherecreated_at < ?UploadService#deleteUploadsOlderThan— deletes fromUploadTableColumns.TABLE_NAMEwherecreated_at < ?SessionService#deleteSessionsOlderThan— deletes fromSessionTableColumns.TABLE_NAMEwhereend_time < ?UploadHandler#upload()now callsmaybePrunePersistedRecords(now)at the start of each cycle. The sweep is throttled to run at most once every 24 hours and defaults to a 90-day retention window whenpersistenceMaxAgeSecondsis unset — matching the iOS defaults precisely.Tests
MParticleOptionsTest#testPersistenceMaxAgeSecondscovers null/positive/zero/negative inputs on the builder.MessageServiceTest#testDeleteMessagesOlderThanverifies the SQL cutoff semantics (strictly<cutoff are deleted; rows at or newer than the cutoff are retained).Screenshots/Video
N/A — this is a configuration/storage-hygiene change with no UI surface.
Checklist
Local validation against JDK 17: `trunk check`, `./gradlew build`, `./gradlew test`, `./gradlew ktlintCheck`, and `./gradlew lint` all pass. `connectedAndroidTest` was not run locally (no emulator available) — will rely on CI.
Additional Notes
Reference Issue (For employees only. Ignore if you are an outside contributor)