From 7de512d7fed935cd17f86bdd9b866c995c7ff79a Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 11 Nov 2021 16:01:35 +0100 Subject: [PATCH] synchronized running exam cache load to prevent multiple long running transactions while loading an Exam --- .../servicelayer/session/impl/ExamSessionCacheService.java | 2 +- .../servicelayer/session/impl/ExamSessionServiceImpl.java | 2 +- .../webservice/weblayer/oauth/CachableJdbcTokenStore.java | 1 - src/main/resources/config/application-dev-gui.properties | 2 +- src/main/resources/config/application-dev-ws.properties | 4 ++-- src/main/resources/config/application-gui.properties | 3 +-- src/main/resources/config/application-ws.properties | 2 +- 7 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionCacheService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionCacheService.java index c218208f..c93483da 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionCacheService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionCacheService.java @@ -69,7 +69,7 @@ public class ExamSessionCacheService { cacheNames = CACHE_NAME_RUNNING_EXAM, key = "#examId", unless = "#result == null") - public Exam getRunningExam(final Long examId) { + public synchronized Exam getRunningExam(final Long examId) { if (log.isDebugEnabled()) { log.debug("Verify running exam for id: {}", examId); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java index 67a62448..ad376ef0 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java @@ -193,7 +193,7 @@ public class ExamSessionServiceImpl implements ExamSessionService { } @Override - public Result getRunningExam(final Long examId) { + public synchronized Result getRunningExam(final Long examId) { if (log.isTraceEnabled()) { log.trace("Running exam request for exam {}", examId); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/CachableJdbcTokenStore.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/CachableJdbcTokenStore.java index a3ab3987..8933b1bd 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/CachableJdbcTokenStore.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/CachableJdbcTokenStore.java @@ -39,7 +39,6 @@ public class CachableJdbcTokenStore implements TokenStore { } @Override - @Transactional public OAuth2AccessToken getAccessToken(final OAuth2Authentication authentication) { return this.jdbcTokenStore.getAccessToken(authentication); } diff --git a/src/main/resources/config/application-dev-gui.properties b/src/main/resources/config/application-dev-gui.properties index 8069b264..3e830c82 100644 --- a/src/main/resources/config/application-dev-gui.properties +++ b/src/main/resources/config/application-dev-gui.properties @@ -8,7 +8,7 @@ sebserver.gui.webservice.address=localhost sebserver.gui.webservice.port=8080 sebserver.gui.webservice.apipath=/admin-api/v1 # defines the polling interval that is used to poll the webservice for client connection data on a monitored exam page -sebserver.gui.webservice.poll-interval=1000 +#sebserver.gui.webservice.poll-interval=1000 sebserver.gui.theme=css/sebserver.css sebserver.gui.list.page.size=15 diff --git a/src/main/resources/config/application-dev-ws.properties b/src/main/resources/config/application-dev-ws.properties index 374fe1ed..5b2e5488 100644 --- a/src/main/resources/config/application-dev-ws.properties +++ b/src/main/resources/config/application-dev-ws.properties @@ -13,7 +13,7 @@ spring.datasource.hikari.initializationFailTimeout=30000 spring.datasource.hikari.connectionTimeout=30000 spring.datasource.hikari.idleTimeout=600000 spring.datasource.hikari.maxLifetime=1800000 -spring.datasource.hikari.maximumPoolSize=500 +spring.datasource.hikari.maximumPoolSize=5 sebserver.http.client.connect-timeout=15000 sebserver.http.client.connection-request-timeout=10000 @@ -23,7 +23,7 @@ sebserver.webservice.clean-db-on-startup=false # webservice configuration sebserver.init.adminaccount.gen-on-init=false -sebserver.webservice.distributed=false +sebserver.webservice.distributed=true sebserver.webservice.master.delay.threshold=10000 sebserver.webservice.http.external.scheme=http sebserver.webservice.http.external.servername=localhost diff --git a/src/main/resources/config/application-gui.properties b/src/main/resources/config/application-gui.properties index 1b89c317..6b20a69e 100644 --- a/src/main/resources/config/application-gui.properties +++ b/src/main/resources/config/application-gui.properties @@ -25,14 +25,13 @@ sebserver.gui.entrypoint=/gui sebserver.gui.webservice.apipath=${sebserver.webservice.api.admin.endpoint} # defines the polling interval that is used to poll the webservice for client connection data on a monitored exam page -sebserver.gui.webservice.poll-interval=3000 +sebserver.gui.webservice.poll-interval=2000 sebserver.gui.webservice.mock-lms-enabled=true sebserver.gui.webservice.edx-lms-enabled=true sebserver.gui.webservice.moodle-lms-enabled=true sebserver.gui.seb.client.config.download.filename=SEBServerSettings.seb sebserver.gui.seb.exam.config.download.filename=SEBExamSettings.seb sebserver.gui.proctoring.zoom.websdk.version=1.9.8 - sebserver.gui.filter.date.from.years=2 # remote proctoring diff --git a/src/main/resources/config/application-ws.properties b/src/main/resources/config/application-ws.properties index a8b7c3e0..5c3fc468 100644 --- a/src/main/resources/config/application-ws.properties +++ b/src/main/resources/config/application-ws.properties @@ -31,7 +31,7 @@ spring.datasource.hikari.initializationFailTimeout=3000 spring.datasource.hikari.connectionTimeout=30000 spring.datasource.hikari.idleTimeout=600000 spring.datasource.hikari.maxLifetime=1800000 -spring.datasource.hikari.maximumPoolSize=500 +spring.datasource.hikari.maximumPoolSize=100 ### webservice security spring.datasource.password=${sebserver.mariadb.password}