diff --git a/backend/src/main/java/io/metersphere/performance/service/JmeterFileService.java b/backend/src/main/java/io/metersphere/performance/service/JmeterFileService.java index 292f6dd410..1b206a28eb 100644 --- a/backend/src/main/java/io/metersphere/performance/service/JmeterFileService.java +++ b/backend/src/main/java/io/metersphere/performance/service/JmeterFileService.java @@ -9,7 +9,6 @@ import io.metersphere.commons.utils.LogUtil; import io.metersphere.performance.engine.EngineContext; import io.metersphere.performance.engine.EngineFactory; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.ByteArrayOutputStream; @@ -17,13 +16,13 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import static org.python.modules.time.Time.sleep; +// 非事务运行 @Service -@Transactional(rollbackFor = Exception.class) public class JmeterFileService { @Resource private ExtLoadTestReportMapper extLoadTestReportMapper; @@ -32,14 +31,14 @@ public class JmeterFileService { public byte[] downloadZip(String reportId, double[] ratios, int resourceIndex) { try { - LoadTestReportWithBLOBs loadTestReport = null; - double waitingSeconds = 0; + LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); + int wait = 0; while (loadTestReport == null) { - if (waitingSeconds > 12000) { + if (wait > 120_000) { break; } - sleep(0.3); - waitingSeconds += 0.3; + TimeUnit.MILLISECONDS.sleep(200); + wait += 200; loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); } if (loadTestReport == null) {