kagkarlsson / db-scheduler

Persistent cluster-friendly scheduler for Java
Apache License 2.0
1.23k stars 188 forks source link

Wrong log number of threads of scheduler #517

Open adamalexandru4 opened 1 month ago

adamalexandru4 commented 1 month ago

Expected Behavior

The log message on Scheduler.build() prints out the number of threads from default value (executorThreads), not from the real executor service used.

Current Behavior

ExecutorService candidateExecutorService = executorService;
    if (candidateExecutorService == null) {
      candidateExecutorService =
          Executors.newFixedThreadPool(
              executorThreads, defaultThreadFactoryWithPrefix(THREAD_PREFIX + "-"));
    }

    ExecutorService candidateDueExecutor = dueExecutor;
    if (candidateDueExecutor == null) {
      candidateDueExecutor =
          Executors.newSingleThreadExecutor(
              defaultThreadFactoryWithPrefix(THREAD_PREFIX + "-execute-due-"));
    }

    ScheduledExecutorService candidateHousekeeperExecutor = housekeeperExecutor;
    if (candidateHousekeeperExecutor == null) {
      candidateHousekeeperExecutor =
          Executors.newScheduledThreadPool(
              3, defaultThreadFactoryWithPrefix(THREAD_PREFIX + "-housekeeper-"));
    }

    LOG.info(
        "Creating scheduler with configuration: threads={}, pollInterval={}s, heartbeat={}s enable-immediate-execution={}, table-name={}, name={}",
        executorThreads,
        waiter.getWaitDuration().getSeconds(),
        heartbeatInterval.getSeconds(),
        enableImmediateExecution,
        tableName,
        schedulerName.getName());
kagkarlsson commented 1 month ago

Thank you for reporting. If the ExecutorService is externally managed, I don't think we know anything about number of threads, so the solution here is probably to only log if not externally managed.. (maybe also see if there are other important configuration parameterns that could be logged)