From 8b75ac54f0d38644a1f54dc0562a4beb2300742b Mon Sep 17 00:00:00 2001 From: Nayan Date: Wed, 25 Oct 2023 09:43:29 +0600 Subject: [PATCH] fix: Failing unit tests in import service (#28338) Co-authored-by: Nidhi --- .../imports/internal/ImportApplicationServiceCEImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportApplicationServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportApplicationServiceCEImpl.java index e77cdb07d8..ca73be9f74 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportApplicationServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportApplicationServiceCEImpl.java @@ -523,7 +523,14 @@ public class ImportApplicationServiceCEImpl implements ImportApplicationServiceC // Start the stopwatch to log the execution time Stopwatch stopwatch = new Stopwatch(AnalyticsEvents.IMPORT.getEventName()); - final Mono importedApplicationMono = applicationSpecificImportedEntitiesMono + + /* + Calling the workspaceMono first to avoid creating multiple mongo transactions. + If the first db call inside a transaction is a Flux, then there's a chance of creating multiple mongo + transactions which will lead to NoSuchTransaction exception. + */ + final Mono importedApplicationMono = workspaceMono + .then(applicationSpecificImportedEntitiesMono) .then(getImportApplicationMono( importedApplication, importingMetaDTO, mappedImportableResourcesDTO, currUserMono)) .cache();