Fix flakiness of the backup tests.
It's possible that pending writes to the key value store (from using .apply()) may not be finished by the time we take the DB snapshot, resulting in us seeing stale data in the snapshot. Now we block on writes finishing.
This commit is contained in:
parent
054b517a04
commit
a76f5e600e
4 changed files with 16 additions and 4 deletions
|
@ -165,6 +165,8 @@ object BackupRepository {
|
|||
private fun createSignalStoreSnapshot(baseName: String): SignalStore {
|
||||
val context = AppDependencies.application
|
||||
|
||||
SignalStore.blockUntilAllWritesFinished()
|
||||
|
||||
// Need to do a WAL checkpoint to ensure that the database file we're copying has all pending writes
|
||||
if (!KeyValueDatabase.getInstance(context).writableDatabase.fullWalCheckpoint()) {
|
||||
Log.w(TAG, "Failed to checkpoint WAL for KeyValueDatabase! Not guaranteed to be using the most recent data.")
|
||||
|
|
|
@ -41,6 +41,8 @@ object RecipientBackupProcessor {
|
|||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
Log.w(TAG, "Missing release channel id on export!")
|
||||
}
|
||||
|
||||
db.recipientTable.getContactsForBackup(selfId).use { reader ->
|
||||
|
|
|
@ -59,6 +59,7 @@ public class JobManager implements ConstraintObserver.Notifier {
|
|||
private final Set<EmptyQueueListener> emptyQueueListeners = new CopyOnWriteArraySet<>();
|
||||
|
||||
private volatile boolean initialized = false;
|
||||
private volatile boolean shutdown = false;
|
||||
|
||||
public JobManager(@NonNull Application application, @NonNull Configuration configuration) {
|
||||
this.application = application;
|
||||
|
@ -123,6 +124,13 @@ public class JobManager implements ConstraintObserver.Notifier {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down the job manager entirely. Should only be used for testing!
|
||||
*/
|
||||
public void shutdown() {
|
||||
shutdown = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for {@link #addListener(JobTracker.JobFilter, JobTracker.JobListener)} that
|
||||
* takes in an ID to filter on.
|
||||
|
@ -456,6 +464,10 @@ public class JobManager implements ConstraintObserver.Notifier {
|
|||
* it through here.
|
||||
*/
|
||||
private void runOnExecutor(@NonNull Runnable runnable) {
|
||||
if (shutdown) {
|
||||
return;
|
||||
}
|
||||
|
||||
executor.execute(() -> {
|
||||
waitUntilInitialized();
|
||||
runnable.run();
|
||||
|
|
|
@ -32,10 +32,6 @@ class ReleaseChannelValues(store: KeyValueStore) : SignalStoreValues(store) {
|
|||
putString(KEY_RELEASE_CHANNEL_RECIPIENT_ID, id.serialize())
|
||||
}
|
||||
|
||||
fun clearReleaseChannelRecipientId() {
|
||||
putString(KEY_RELEASE_CHANNEL_RECIPIENT_ID, "")
|
||||
}
|
||||
|
||||
var nextScheduledCheck by longValue(KEY_NEXT_SCHEDULED_CHECK, 0)
|
||||
var previousManifestMd5 by blobValue(KEY_PREVIOUS_MANIFEST_MD5, ByteArray(0))
|
||||
var highestVersionNoteReceived by integerValue(KEY_HIGHEST_VERSION_NOTE_RECEIVED, 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue