Skip to content

Commit

Permalink
Check db for triggering jobs less frequently
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewWestberg committed Sep 17, 2024
1 parent 4dc2c68 commit 88663a0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ val databaseKoinModule =
}
isAutoCommit = false
transactionIsolation = "TRANSACTION_REPEATABLE_READ"
connectionTimeout = 40_000L
connectionTimeout = 30_000L
maximumPoolSize = 30
minimumIdle = 5
maxLifetime = 600_000L // 10 minutes
validationTimeout = 12_000L
idleTimeout = 12_000L
maxLifetime = 300_000L // 5 minutes
validationTimeout = 10_000L
idleTimeout = 60_000L
leakDetectionThreshold = 60_000L
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import io.newm.shared.koin.inject
import io.newm.shared.ktx.toUUID
import io.newm.txbuilder.ktx.extractFields
import java.math.BigInteger
import java.sql.Connection.TRANSACTION_SERIALIZABLE
import java.time.LocalDateTime
import java.time.ZoneOffset
import kotlin.time.Duration.Companion.minutes
Expand Down Expand Up @@ -214,7 +213,7 @@ class MonitorClaimOrderJob : Job {
val submitTransactionResponse =
cardanoRepository.submitTransaction(transactionBuilderResponse.transactionCbor)
if (submitTransactionResponse.result == "MsgAcceptTx") {
newSuspendedTransaction(transactionIsolation = TRANSACTION_SERIALIZABLE) {
newSuspendedTransaction {
earningsRepository.claimed(
claimOrderId = claimOrder.id!!,
earningsIds = claimOrder.earningsIds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import io.newm.server.typealiases.SongId
import io.newm.shared.koin.inject
import io.newm.shared.ktx.toDate
import io.newm.shared.ktx.toHexString
import java.sql.Connection.TRANSACTION_SERIALIZABLE
import java.time.Instant
import java.time.LocalDateTime
import java.util.UUID
Expand Down Expand Up @@ -210,7 +209,7 @@ class EarningsRepositoryImpl(

private suspend fun createClaimOrderInternal(claimOrderRequest: ClaimOrderRequest): ClaimOrder? {
val claimOrder =
newSuspendedTransaction(transactionIsolation = TRANSACTION_SERIALIZABLE) {
newSuspendedTransaction {
val stakeAddress = claimOrderRequest.walletAddress.extractStakeAddress(cardanoRepository.isMainnet())
// check for existing open claim record first
getActiveClaimOrderByStakeAddress(stakeAddress) ?: run {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
org.quartz.scheduler.instanceId = AUTO
org.quartz.scheduler.instanceName = ClaimOrdersScheduler
org.quartz.threadPool.threadCount = 100
org.quartz.threadPool.threadCount = 50
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.dataSource = newmServerDatasource
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 30000
org.quartz.dataSource.newmServerDatasource.connectionProvider.class = io.newm.server.features.scheduler.SchedulerPoolingConnectionProvider
org.quartz.scheduler.batchTriggerAcquisitionFireAheadTimeWindow = 10000
1 change: 1 addition & 0 deletions newm-server/src/main/resources/quartz.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ org.quartz.jobStore.dataSource = newmServerDatasource
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 30000
org.quartz.dataSource.newmServerDatasource.connectionProvider.class = io.newm.server.features.scheduler.SchedulerPoolingConnectionProvider
org.quartz.scheduler.batchTriggerAcquisitionFireAheadTimeWindow = 10000

0 comments on commit 88663a0

Please sign in to comment.