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

No downgrade implementation for database causes crash on library downgrade #216

Open
vincent-paing opened this issue May 23, 2023 · 0 comments · May be fixed by #217
Open

No downgrade implementation for database causes crash on library downgrade #216

vincent-paing opened this issue May 23, 2023 · 0 comments · May be fixed by #217

Comments

@vincent-paing
Copy link
Contributor

vincent-paing commented May 23, 2023

In our team, we do regular upgrade of our library versions as a housekeeping chores. Last week, we had to halt our phased roll out and had to revert back to an older version due to a production bug we introduced in one of our feature. However, after releasing the reverted version, we started to see crashes happening for users who already received the update with newer Tealium version.

These crashes happens because the newer version uses Tealium 1.5.0+ where as the rolled back version still has Tealium 1.4.3. I believe database upgrade was added back in 1.5.0 but since the previous library versions didn't implement onDowngrade, the app started crashing when it tries to downgrade back to database version 1.

We were able to patch this by making a hotfix with just changes made to upgrade to Tealium 1.5.0 but however since some of are users are already affected by this and since it crashes on launch, there was no way for us to inform these users to update again to latest version. I believe a proper fix would be to implement onDowngrade going forward.


Problem Statement

Since no downgrade for database is implemented, every time tealium update database version, there is no simple way1 for consumers to downgrade back to previous tealium version.

In the future, this could leads to major issue if tealium introduces a critical bug and apps need to downgrade back to older version as part of mitigation strategy. For example,

  • Tealium version 1.6 updates database version.
  • Users update tealium version to 1.6.
  • Users made a release on Play Store
  • After a week later, the critical vulnerability is discovered,
  • While the devs are working on patch in 1.6.1, users were advised to downgrade back to 1.5.
  • Doing so would lead to hard crash on launch.

1 : You can force delete data/tealium folder before doing anything else in Application's onCreate.

Steps to reproduce

  1. Build & Run the app with Tealium 1.5.0 and forward
  2. Downgrade tealium back to 1.4.3
  3. Observe crash on launch

Fix

In ideal scenario, we would want to revert only the upgrade we made but that would be near impsossible to do since we would need to do what we're upgrading a version ahead of time. For now, We could use destructive migration. The app might loses previously saved data but I think it's better than hard crashing on launch. (See: #217)

vincent-paing added a commit to vincent-paing/tealium-kotlin that referenced this issue May 23, 2023
This might not really be scalable as we need to add one more drop table in `onDowngrade` we have new table. A better solution might be to query the sqlite master table for tables names then recursively drop them one by one. Since we only have 3 tables for now, I made a conscious decision not to do early abstraction.

Fixes Tealium#216
@vincent-paing vincent-paing linked a pull request May 23, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant