more fixes to prevent DB deadlocks

This commit is contained in:
anhefti 2021-11-09 09:39:11 +01:00
parent a747c48458
commit 780a17834c
2 changed files with 5 additions and 2 deletions

View file

@ -77,7 +77,9 @@ public abstract class AbstractPingIndicator extends AbstractClientIndicator {
// Update last ping time on persistent storage // Update last ping time on persistent storage
final long millisecondsNow = DateTimeUtils.currentTimeMillis(); final long millisecondsNow = DateTimeUtils.currentTimeMillis();
if (millisecondsNow - this.lastUpdate > INTERVAL_FOR_PERSISTENT_UPDATE) { if (millisecondsNow - this.lastUpdate > INTERVAL_FOR_PERSISTENT_UPDATE) {
this.distributedPingCache.updatePing(this.pingRecord, millisecondsNow); synchronized (this) {
this.distributedPingCache.updatePing(this.pingRecord, millisecondsNow);
}
} }
} }
} }

View file

@ -24,6 +24,7 @@ import org.springframework.beans.factory.DisposableBean;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.TaskScheduler;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent.EventType; import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent.EventType;
@ -180,7 +181,7 @@ public class DistributedPingCache implements DisposableBean {
} }
} }
@Transactional(readOnly = true) @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED)
public void updateCache() { public void updateCache() {
if (this.pingCache.isEmpty()) { if (this.pingCache.isEmpty()) {