Unverified Commit 85f55cd5 authored by songquanhe-gitstudy's avatar songquanhe-gitstudy Committed by GitHub
Browse files

fix: No operations allowed after statement closed when running sql task (#2265)



* sqlTask failed to run

* get correct attribute value and logger content

Co-authored-by: default avatarsongqh <songquanhe@foxmail.com>
parent 34e2f67e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -425,13 +425,13 @@ public class OSUtils {
   * @return check memory and cpu usage
   */
  public static Boolean checkResource(double systemCpuLoad, double systemReservedMemory){
    // judging usage
    // system load average
    double loadAverage = OSUtils.loadAverage();
    //
    // system available physical memory
    double availablePhysicalMemorySize = OSUtils.availablePhysicalMemorySize();

    if(loadAverage > systemCpuLoad || availablePhysicalMemorySize < systemReservedMemory){
      logger.warn("load or availablePhysicalMemorySize(G) is too high, it's availablePhysicalMemorySize(G):{},loadAvg:{}", availablePhysicalMemorySize , loadAverage);
      logger.warn("load is too high or availablePhysicalMemorySize(G) is too low, it's availablePhysicalMemorySize(G):{},loadAvg:{}", availablePhysicalMemorySize , loadAverage);
      return false;
    }else{
      return true;
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public class WorkerConfig {
    @Value("${worker.max.cpuload.avg}")
    private int workerMaxCpuloadAvg;

    @Value("${master.reserved.memory}")
    @Value("${worker.reserved.memory}")
    private double workerReservedMemory;

    public int getWorkerExecThreads() {
+12 −12
Original line number Diff line number Diff line
@@ -363,7 +363,8 @@ public class SqlTask extends AbstractTask {
        // is the timeout set
        boolean timeoutFlag = taskProps.getTaskTimeoutStrategy() == TaskTimeoutStrategy.FAILED ||
                taskProps.getTaskTimeoutStrategy() == TaskTimeoutStrategy.WARNFAILED;
        try (PreparedStatement  stmt = connection.prepareStatement(sqlBinds.getSql())) {
        // prepare statement
        PreparedStatement stmt = connection.prepareStatement(sqlBinds.getSql());
        if(timeoutFlag){
            stmt.setQueryTimeout(taskProps.getTaskTimeout());
        }
@@ -377,7 +378,6 @@ public class SqlTask extends AbstractTask {
        logger.info("prepare statement replace sql : {} ", stmt);
        return stmt;
    }
    }

    /**
     * send mail as an attachment