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

Open
#292 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
kotlin, sqlite

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.

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.<init> (SQLiteProgram.java:61)
android.database.sqlite.SQLiteStatement.<init> (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

Dominant language
Kotlin
Stars
557
Forks
242
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from android/codelab-android-workmanager

All issues in android/codelab-android-workmanager

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.