TSK-1757: Added lock for update to custom attribute initialization.
This commit is contained in:
parent
1df190d1da
commit
e05120cc93
|
@ -8,6 +8,10 @@ import pro.taskana.common.api.exceptions.SystemException;
|
|||
|
||||
public class ParallelThreadHelper {
|
||||
|
||||
private ParallelThreadHelper() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static void runInThread(Runnable runnable, int threadCount) throws Exception {
|
||||
Thread[] threads = new Thread[threadCount];
|
||||
|
||||
|
|
|
@ -14,8 +14,14 @@ public interface ConfigurationMapper {
|
|||
@Insert("INSERT INTO CONFIGURATION(ENFORCE_SECURITY) VALUES (#{securityEnabled})")
|
||||
void setSecurityEnabled(@Param("securityEnabled") boolean securityEnabled);
|
||||
|
||||
@Select("SELECT CUSTOM_ATTRIBUTES FROM CONFIGURATION")
|
||||
Map<String, Object> getAllCustomAttributes();
|
||||
@Select(
|
||||
"<script> SELECT CUSTOM_ATTRIBUTES FROM CONFIGURATION "
|
||||
+ "<if test='lockForUpdate == true'>"
|
||||
+ "FETCH FIRST ROW ONLY FOR UPDATE "
|
||||
+ "<if test=\"_databaseId == 'db2'\">WITH RS USE AND KEEP UPDATE LOCKS </if> "
|
||||
+ "</if>"
|
||||
+ "</script>")
|
||||
Map<String, Object> getAllCustomAttributes(boolean lockForUpdate);
|
||||
|
||||
@Update("UPDATE CONFIGURATION SET CUSTOM_ATTRIBUTES = #{customAttributes}")
|
||||
void setAllCustomAttributes(@Param("customAttributes") Map<String, ?> customAttributes);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class ConfigurationServiceImpl implements ConfigurationService {
|
|||
internalTaskanaEngine.executeInDatabaseConnection(
|
||||
CheckedRunnable.wrap(
|
||||
() -> {
|
||||
if (mapper.getAllCustomAttributes() == null) {
|
||||
if (mapper.getAllCustomAttributes(true) == null) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("custom attributes are not set. Setting default value");
|
||||
}
|
||||
|
@ -58,7 +58,8 @@ public class ConfigurationServiceImpl implements ConfigurationService {
|
|||
|
||||
@Override
|
||||
public Map<String, Object> getAllCustomAttributes() {
|
||||
return internalTaskanaEngine.executeInDatabaseConnection(mapper::getAllCustomAttributes);
|
||||
return internalTaskanaEngine.executeInDatabaseConnection(
|
||||
() -> mapper.getAllCustomAttributes(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ConfigurationServiceImplAccTest {
|
|||
ConfigurationServiceImpl.class, "defaultCustomAttributes.json"))
|
||||
.toMap();
|
||||
|
||||
Map<String, Object> allCustomAttributes = configurationMapper.getAllCustomAttributes();
|
||||
Map<String, Object> allCustomAttributes = configurationMapper.getAllCustomAttributes(false);
|
||||
|
||||
assertThat(allCustomAttributes).isEqualTo(expectedCustomAttributes);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue