Repository: firebase/firebase-android-sdk

Issue #1531: SQLiteException in firebase-crashlytics
Created: 2020-05-06T03:49:22Z
[REQUIRED] Step 2: Describe your environment

Android Studio version: 3.4.2
Firebase Component:  firebase-crashlytics
Component version:
FIREBASE_ANALYTICS = "17.4.0"
FIREBASE_MESSAGING = "20.1.6"
FIREBASE_CRASHLYTICS = "17.0.0"

[REQUIRED] Step 3: Describe the problem
We have a significant number of crash reports in crashlytics with SQLiteException
duplicate column name: extras (code 1 SQLITE_ERROR): , while compiling: ALTER TABLE transport_contexts ADD COLUMN extras BLOB android.database.sqlite.SQLiteConnection.nativePrepareStatement 
We upgraded from Fabric Crashlytics SDK to Firebase Crashlytics SDK in March and downgrade to Fabric Crashlytics SDK. When we upgrade from Fabric Crashlytics SDK to Firebase Crashlytics SDK this week, the crash happened.
Log
Fatal Exception: android.database.sqlite.SQLiteException: duplicate column name: extras (code 1 SQLITE_ERROR): , while compiling: ALTER TABLE transport_contexts ADD COLUMN extras BLOB at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:903) at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:514) at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58) at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31) at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1770) at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1698) at com.google.android.datatransport.runtime.scheduling.persistence.SchemaManager.lambda$static$1(SchemaManager.java:97) at com.google.android.datatransport.runtime.scheduling.persistence.SchemaManager$$Lambda$2.upgrade(SchemaManager.java) at com.google.android.datatransport.runtime.scheduling.persistence.SchemaManager.upgrade(SchemaManager.java:182) at com.google.android.datatransport.runtime.scheduling.persistence.SchemaManager.onUpgrade(SchemaManager.java:152) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:398) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:298) at com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore$$Lambda$1.produce(SQLiteEventStore.java:2) at com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore.retryIfDbLocked(SQLiteEventStore.java:517) at com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore.getDb(SQLiteEventStore.java:82) at com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore.runCriticalSection(SQLiteEventStore.java:549) at com.google.android.datatransport.runtime.scheduling.jobscheduling.WorkInitializer.lambda$ensureContextsScheduled$1(WorkInitializer.java:54) at com.google.android.datatransport.runtime.scheduling.jobscheduling.WorkInitializer$$Lambda$1.run(WorkInitializer.java:1054) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764)
Steps to reproduce:
install version with firebase crashlytics SDK-> upgrade version to one without firebase crashlytics SDK-> upgrade version to one with firebase crashlytics SDK

Duplicate issue #1568: Runtime SQLite Table crash after upgrading Core and Messaging Versions
Created: 2020-05-18T17:05:41Z
[REQUIRED] Step 2: Describe your environment

Android Studio version: 3.6.3
Firebase Component: Core & Messaging
Component version: Core 17.4.1 & Messaging 20.1.7

[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
We recently updated our Firebase Messaging version from 19.0.1 to 20.1.7  and Firebase Core from 17.0.0 to 17.4.1 .
After doing so, when we relaunched our app, a crash surfaced related to the package: com.google.android.datatransport
Here is the stack trace:
Process: com.sproutsocial.android.debug, PID: 11938
    android.database.sqlite.SQLiteException: table event_payloads already exists (code 1 SQLITE_ERROR): , while compiling: CREATE TABLE event_payloads (sequence_num INTEGER NOT NULL, event_id INTEGER NOT NULL, bytes BLOB NOT NULL,FOREIGN KEY (event_id) REFERENCES events(_id) ON DELETE CASCADE,PRIMARY KEY (sequence_num, event_id))
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:986)
        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:593)
        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:61)
        at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:33)
        at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1805)
        at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1733)
        at com.google.android.datatransport.runtime.scheduling.persistence.SchemaManager.lambda$static$3(com.google.android.datatransport:transport-runtime@@2.2.1:109)
        at com.google.android.datatransport.runtime.scheduling.persistence.SchemaManager$$Lambda$4.upgrade(Unknown Source:0)
        at com.google.android.datatransport.runtime.scheduling.persistence.SchemaManager.upgrade(com.google.android.datatransport:transport-runtime@@2.2.1:182)
        at com.google.android.datatransport.runtime.scheduling.persistence.SchemaManager.onUpgrade(com.google.android.datatransport:transport-runtime@@2.2.1:152)
        at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:417)
        at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:317)
        at com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore$$Lambda$1.produce(Unknown Source:2)
        at com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore.retryIfDbLocked(com.google.android.datatransport:transport-runtime@@2.2.1:517)
        at com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore.getDb(com.google.android.datatransport:transport-runtime@@2.2.1:82)
        at com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore.runCriticalSection(com.google.android.datatransport:transport-runtime@@2.2.1:549)
        at com.google.android.datatransport.runtime.scheduling.jobscheduling.WorkInitializer.lambda$ensureContextsScheduled$1(com.google.android.datatransport:transport-runtime@@2.2.1:54)
        at com.google.android.datatransport.runtime.scheduling.jobscheduling.WorkInitializer$$Lambda$1.run(Unknown Source:2)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

I could reproduce it by having a version of the app, which had the old firebase version installed, and then upgrading the apk to the app with the updated firebase versions.
It's unclear if this crash and upgrade of Firebase Versions are related.

Closing comment (2020-05-18T19:47:08Z): This looks very similar to #1531