Move envelope follow-up operations outside of the transaction.

This commit is contained in:
Greyson Parrelli
2023-10-30 08:51:37 -07:00
parent 297308ad76
commit a8e02b9ced
3 changed files with 18 additions and 16 deletions

View File

@@ -392,18 +392,22 @@ class IncomingMessageObserver(private val context: Application) {
val startTime = System.currentTimeMillis()
GroupsV2ProcessingLock.acquireGroupProcessingLock().use {
ReentrantSessionLock.INSTANCE.acquire().use {
batch.forEach {
batch.forEach { response ->
Log.d(TAG, "Beginning database transaction...")
SignalDatabase.runInTransaction {
val followUpOperations: List<FollowUpOperation>? = processEnvelope(bufferedStore, it.envelope, it.serverDeliveredTimestamp)
val followUpOperations = SignalDatabase.runInTransaction { db ->
val followUps: List<FollowUpOperation>? = processEnvelope(bufferedStore, response.envelope, response.serverDeliveredTimestamp)
bufferedStore.flushToDisk()
if (followUpOperations != null) {
val jobs = followUpOperations.mapNotNull { it.run() }
ApplicationDependencies.getJobManager().addAll(jobs)
}
followUps
}
Log.d(TAG, "Ended database transaction.")
signalWebSocket.sendAck(it)
if (followUpOperations != null) {
Log.d(TAG, "Running ${followUpOperations.size} follow-up operations...")
val jobs = followUpOperations.mapNotNull { it.run() }
ApplicationDependencies.getJobManager().addAll(jobs)
}
signalWebSocket.sendAck(response)
}
}
}