exam lock isolation
This commit is contained in:
parent
743d9044c8
commit
a0ca72e3ea
1 changed files with 5 additions and 4 deletions
|
@ -30,6 +30,7 @@ import org.mybatis.dynamic.sql.update.UpdateDSL;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Isolation;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -328,7 +329,7 @@ public class ExamDAOImpl implements ExamDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.SERIALIZABLE)
|
||||||
public Result<Long> placeLock(final Long examId, final String updateId) {
|
public Result<Long> placeLock(final Long examId, final String updateId) {
|
||||||
return Result.tryCatch(() -> {
|
return Result.tryCatch(() -> {
|
||||||
|
|
||||||
|
@ -339,7 +340,7 @@ public class ExamDAOImpl implements ExamDAO {
|
||||||
// consistency check
|
// consistency check
|
||||||
if (BooleanUtils.isTrue(BooleanUtils.toBooleanObject(examRec.getUpdating()))) {
|
if (BooleanUtils.isTrue(BooleanUtils.toBooleanObject(examRec.getUpdating()))) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Exam to end update is not in expected state: " + examRec.getExternalId());
|
"Exam to place lock is not in expected state: " + examRec.getExternalId());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ExamRecord newRecord = new ExamRecord(
|
final ExamRecord newRecord = new ExamRecord(
|
||||||
|
@ -356,7 +357,7 @@ public class ExamDAOImpl implements ExamDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.SERIALIZABLE)
|
||||||
public Result<Long> releaseLock(final Long examId, final String updateId) {
|
public Result<Long> releaseLock(final Long examId, final String updateId) {
|
||||||
return Result.tryCatch(() -> {
|
return Result.tryCatch(() -> {
|
||||||
|
|
||||||
|
@ -369,7 +370,7 @@ public class ExamDAOImpl implements ExamDAO {
|
||||||
|| !updateId.equals(examRec.getLastupdate())) {
|
|| !updateId.equals(examRec.getLastupdate())) {
|
||||||
|
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Exam to end update is not in expected state: " + examRec.getExternalId());
|
"Exam to release lock is not in expected state: " + examRec.getExternalId());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ExamRecord newRecord = new ExamRecord(
|
final ExamRecord newRecord = new ExamRecord(
|
||||||
|
|
Loading…
Reference in a new issue