android / android/codelab-android-workmanager
Fatal Exception: android.database.sqlite.SQLiteException duplicate column name: run_in_foreground (code 1 SQLITE_ERROR): , while compiling: ALTER TABLE workspec ADD COLUMN `run_in_foreground` INTEGER NOT NULL DEFAULT 0
- Dominant language
- Kotlin
- Stars
- 557
- Forks
- 242
- PR merge metrics
- No merged PRs in 30d
Description
Hi Team,
We are getting very heavy crash of WorkManager library whenever database migration happening which code written by workmanager it self
So we found that clevertap also using work manager library which is
`androidx.work:work-runtime:2.3.4`
And We are using which is
`api "androidx.work:work-runtime-ktx:2.2.0"`
Clevertap lib using in our project is
```
api 'com.clevertap.android:push-templates:0.0.8'
api 'com.clevertap.android:clevertap-android-sdk:4.0.0'
implementation 'com.clevertap.android:clevertap-xiaomi-sdk:1.0.0'
```
Have written this piece of code in application class
```
override fun getWorkManagerConfiguration() =
Configuration.Builder()
.setMinimumLoggingLevel(android.util.Log.INFO)
.build()
```
```
android.database.sqlite.SQLiteConnection.nativePrepareStatement (SQLiteConnection.java)
android.database.sqlite.SQLiteConnection.acquirePreparedStatement (SQLiteConnection.java:1055)
android.database.sqlite.SQLiteConnection.prepare (SQLiteConnection.java:662)
android.database.sqlite.SQLiteSession.prepare (SQLiteSession.java:590)
android.database.sqlite.SQLiteProgram. (SQLiteProgram.java:61)
android.database.sqlite.SQLiteStatement. (SQLiteStatement.java:33)
android.database.sqlite.SQLiteDatabase.executeSql (SQLiteDatabase.java:1930)
android.database.sqlite.SQLiteDatabase.execSQL (SQLiteDatabase.java:1852)
androidx.sqlite.db.framework.FrameworkSQLiteDatabase.execSQL (FrameworkSQLiteDatabase.java:242)
androidx.work.impl.WorkDatabaseMigrations$6.migrate (WorkDatabaseMigrations.java:209)
androidx.room.RoomOpenHelper.onUpgrade (RoomOpenHelper.java:99)
androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onUpgrade (FrameworkSQLiteOpenHelper.java:177)
android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:421)
android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:321)
androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase (FrameworkSQLiteOpenHelper.java:145)
androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase (FrameworkSQLiteOpenHelper.java:106)
androidx.room.RoomDatabase.beginTransaction (RoomDatabase.java:352)
androidx.work.impl.utils.ForceStopRunnable.cleanUp (ForceStopRunnable.java:156)
androidx.work.impl.utils.ForceStopRunnable.run (ForceStopRunnable.java:87)
androidx.work.impl.utils.SerialExecutor$Task.run (SerialExecutor.java:91)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
java.lang.Thread.run (Thread.java:923)
```
**please help to find out the root cause so we can solve as soon as possible**
This crash happening only when user is in background , but wont able to replicate on our device, So do not have any idea how to solve this
Contributor guide
Research direction
Start with WorkDatabaseMigrations$6.migrate at WorkDatabaseMigrations.java:209 and the RoomOpenHelper.onUpgrade path shown in the stack trace. Compare the androidx.work:work-runtime:2.3.4 and work-runtime-ktx:2.2.0 dependency setup, then determine why the run_in_foreground column is added twice. Done means the migration conflict and a verified resolution are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, sqlite
- Domain
- databases, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100