Skip to content

Commit d039fb6

Browse files
committed
[Admin] Fix concurrency issues in admin panel
1 parent c1fe7e0 commit d039fb6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

server/admin/R/MiroProc.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ MiroProc <- R6::R6Class("MiroProc", public = list(
2323
progressSelector, successCallback, overwriteScen = TRUE, requestType = "addApp",
2424
migrationConfigPath = NULL, launchDbMigrationManager = NULL, additionalDataOnError = NULL,
2525
parallelSessionId = NULL, newSession = FALSE) {
26-
private$errorRaised <- FALSE
27-
private$migrationInfo <- NULL
28-
private$stdErr <- ""
2926
if (length(parallelSessionId)) {
3027
stopifnot(is.character(parallelSessionId), identical(length(parallelSessionId), 1L))
3128
if (identical(newSession, TRUE) && length(private$parallelPidMap[[parallelSessionId]])) {
@@ -38,6 +35,9 @@ MiroProc <- R6::R6Class("MiroProc", public = list(
3835
} else {
3936
procId <- "main"
4037
}
38+
private$errorRaised[[procId]] <- FALSE
39+
private$migrationInfo <- NULL
40+
private$stdErr[[procId]] <- ""
4141
if (length(private$miroProc[[procId]]) &&
4242
private$miroProc[[procId]]$is_alive()) {
4343
flog.info("A process with pid: %s is still running. It will be killed.", procId)
@@ -93,7 +93,7 @@ MiroProc <- R6::R6Class("MiroProc", public = list(
9393
outputLines <- c(outputLines, private$miroProc[[procId]]$read_error_lines())
9494
}
9595
for (line in outputLines) {
96-
private$stdErr <- paste(private$stdErr, line, sep = "\n")
96+
private$stdErr[[procId]] <- paste(private$stdErr[[procId]], line, sep = "\n")
9797
if (startsWith(line, "merr:::")) {
9898
flog.debug(paste0("MIRO error message received: ", line))
9999
error <- strsplit(trimws(line), ":::", fixed = TRUE)[[1]][-1]
@@ -114,7 +114,7 @@ MiroProc <- R6::R6Class("MiroProc", public = list(
114114
)
115115
private$session$sendCustomMessage("onHideAddAppProgress", list())
116116
private$showMigrationModal(launchDbMigrationManager)
117-
private$errorRaised <- TRUE
117+
private$errorRaised[[procId]] <- TRUE
118118
} else if (error[1] == "418") {
119119
flog.warn("MIRO signalled that the scenario to import already exists. This should not happen!")
120120
}
@@ -152,11 +152,11 @@ MiroProc <- R6::R6Class("MiroProc", public = list(
152152
private$procObs[[procId]] <- NULL
153153
}
154154
if (procExitStatus == 0) {
155-
flog.debug("MIRO process (pid: %s) finished successfully. Stderr: %s", procId, private$stdErr)
155+
flog.debug("MIRO process (pid: %s) finished successfully. Stderr: %s", procId, private$stdErr[[procId]])
156156
private$miroProc[[procId]] <- NULL
157157
successCallback()
158158
} else {
159-
if (private$errorRaised) {
159+
if (private$errorRaised[[procId]]) {
160160
flog.debug(
161161
"MIRO process (pid: %s) finished with exit code: %s.",
162162
procId,
@@ -171,7 +171,7 @@ MiroProc <- R6::R6Class("MiroProc", public = list(
171171
flog.error(
172172
"Unexpected error when starting MIRO process (pid: %s). Stderr: %s",
173173
procId,
174-
private$stdErr
174+
private$stdErr[[procId]]
175175
)
176176
if (length(additionalDataOnError)) {
177177
dataToSend <- additionalDataOnError
@@ -213,8 +213,8 @@ MiroProc <- R6::R6Class("MiroProc", public = list(
213213
procObs = list(),
214214
procCount = 1L,
215215
parallelPidMap = list(),
216-
stdErr = "",
217-
errorRaised = FALSE,
216+
stdErr = list(),
217+
errorRaised = list(),
218218
migrationInfo = NULL,
219219
showMigrationModal = function(launchDbMigrationManager) {
220220
showModal(modalDialog(

0 commit comments

Comments
 (0)