Skip to content

Commit

Permalink
Merge pull request #1 from DrexHD/single-threaded-transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
yqs112358 authored Aug 7, 2024
2 parents 8f74fc4 + 292fc12 commit 8966fe5
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.github.quiltservertools.ledger.utility.PlayerResult
import com.google.common.cache.Cache
import com.mojang.authlib.GameProfile
import kotlinx.coroutines.delay
import kotlinx.coroutines.newSingleThreadContext
import net.minecraft.util.Identifier
import net.minecraft.util.math.BlockPos
import org.jetbrains.exposed.dao.Entity
Expand Down Expand Up @@ -74,6 +75,7 @@ object DatabaseManager {
get() = database.dialect.name

private val cache = DatabaseCacheService
private val databaseCoroutine = newSingleThreadContext("Ledger")

fun setup(dataSource: DataSource?) {
val source = dataSource ?: getDefaultDatasource()
Expand Down Expand Up @@ -369,7 +371,7 @@ object DatabaseManager {
delay(timeMillis = 1000)
}

return newSuspendedTransaction(db = database) {
return newSuspendedTransaction(context = databaseCoroutine, db = database) {
repetitionAttempts = MAX_QUERY_RETRIES
minRepetitionDelay = MIN_RETRY_DELAY
maxRepetitionDelay = MAX_RETRY_DELAY
Expand Down

0 comments on commit 8966fe5

Please sign in to comment.