mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'semaphore' into test-semaphore
This commit is contained in:
commit
ba2ad05088
@ -584,6 +584,7 @@ export class ContributionResolver {
|
||||
|
||||
// acquire lock
|
||||
const releaseLock = await TRANSACTIONS_LOCK.acquire()
|
||||
console.log(`locked for confirmContribution ${id}`)
|
||||
const queryRunner = getConnection().createQueryRunner()
|
||||
await queryRunner.connect()
|
||||
await queryRunner.startTransaction('REPEATABLE READ') // 'READ COMMITTED')
|
||||
@ -593,7 +594,7 @@ export class ContributionResolver {
|
||||
.select('transaction')
|
||||
.from(DbTransaction, 'transaction')
|
||||
.where('transaction.userId = :id', { id: contribution.userId })
|
||||
.orderBy('transaction.balanceDate', 'DESC')
|
||||
.orderBy('transaction.id', 'DESC')
|
||||
.getOne()
|
||||
logger.info('lastTransaction ID', lastTransaction ? lastTransaction.id : 'undefined')
|
||||
|
||||
@ -642,10 +643,11 @@ export class ContributionResolver {
|
||||
})
|
||||
} catch (e) {
|
||||
await queryRunner.rollbackTransaction()
|
||||
logger.error(`Creation was not successful: ${e}`)
|
||||
console.log(`Creation was not successful:`, e)
|
||||
throw new Error(`Creation was not successful.`)
|
||||
} finally {
|
||||
await queryRunner.release()
|
||||
console.log(`release for confirmContribution ${id}`)
|
||||
releaseLock()
|
||||
}
|
||||
|
||||
|
||||
@ -171,6 +171,7 @@ export class TransactionLinkResolver {
|
||||
if (code.match(/^CL-/)) {
|
||||
// acquire lock
|
||||
const releaseLock = await TRANSACTIONS_LOCK.acquire()
|
||||
console.log(`locked for redeemTransactionLink ${code}`)
|
||||
logger.info('redeem contribution link...')
|
||||
const queryRunner = getConnection().createQueryRunner()
|
||||
await queryRunner.connect()
|
||||
@ -312,6 +313,7 @@ export class TransactionLinkResolver {
|
||||
throw new Error(`Creation from contribution link was not successful. ${e}`)
|
||||
} finally {
|
||||
await queryRunner.release()
|
||||
console.log(`release for redeemTransactionLink ${code}`)
|
||||
releaseLock()
|
||||
}
|
||||
return true
|
||||
|
||||
@ -66,6 +66,7 @@ export const executeTransaction = async (
|
||||
|
||||
// acquire lock
|
||||
const releaseLock = await TRANSACTIONS_LOCK.acquire()
|
||||
console.log(`locked for executeTransaction ${amount.toString()} ${recipient.firstName}`)
|
||||
|
||||
try {
|
||||
// validate amount
|
||||
@ -189,6 +190,7 @@ export const executeTransaction = async (
|
||||
logger.info(`finished executeTransaction successfully`)
|
||||
return true
|
||||
} finally {
|
||||
console.log(`release for executeTransaction ${amount.toString()} ${recipient.firstName}`)
|
||||
releaseLock()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user