Retry FTS rebuild 3 times.

Looks like we still have the old connection pull after a backup restore.
This gives it 3 chances.

Fixes #12902
This commit is contained in:
Greyson Parrelli
2023-04-14 16:29:18 -04:00
parent 7b4d2661ad
commit 236e0faace
2 changed files with 14 additions and 2 deletions

View File

@@ -5,6 +5,8 @@ import org.thoughtcrime.securesms.database.SignalDatabase
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.jobmanager.Job
import java.lang.Exception
import java.lang.IllegalStateException
import kotlin.time.Duration.Companion.seconds
class RebuildMessageSearchIndexJob private constructor(params: Parameters) : BaseJob(params) {
@@ -21,6 +23,7 @@ class RebuildMessageSearchIndexJob private constructor(params: Parameters) : Bas
private constructor() : this(
Parameters.Builder()
.setQueue("RebuildMessageSearchIndex")
.setMaxAttempts(3)
.build()
)
@@ -34,7 +37,11 @@ class RebuildMessageSearchIndexJob private constructor(params: Parameters) : Bas
SignalDatabase.messageSearch.rebuildIndex()
}
override fun onShouldRetry(e: Exception): Boolean = false
override fun getNextRunAttemptBackoff(pastAttemptCount: Int, exception: Exception): Long {
return 10.seconds.inWholeMilliseconds
}
override fun onShouldRetry(e: Exception): Boolean = e is IllegalStateException
class Factory : Job.Factory<RebuildMessageSearchIndexJob> {
override fun create(parameters: Parameters, serializedData: ByteArray?): RebuildMessageSearchIndexJob {

View File

@@ -123,9 +123,10 @@ public class ApplicationMigrations {
static final int SYSTEM_NAME_RESYNC = 78;
static final int RECOVERY_PASSWORD_SYNC = 79;
static final int DECRYPTIONS_DRAINED = 80;
static final int REBUILD_MESSAGE_FTS_INDEX_3 = 81;
}
public static final int CURRENT_VERSION = 80;
public static final int CURRENT_VERSION = 81;
/**
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
@@ -547,6 +548,10 @@ public class ApplicationMigrations {
jobs.put(Version.DECRYPTIONS_DRAINED, new DecryptionsDrainedMigrationJob());
}
if (lastSeenVersion < Version.REBUILD_MESSAGE_FTS_INDEX_3) {
jobs.put(Version.REBUILD_MESSAGE_FTS_INDEX_3, new RebuildMessageSearchIndexMigrationJob());
}
return jobs;
}