Browse Source

[cherry-pick-2.0.2][BUG-7554] Fix database lose data in standalone (#7621)

* [cherry-pick][BUG-7554] Fix database lose data in standalone

* Fix thread starts too early

Co-authored-by: caishunfeng <534328519@qq.com>
Co-authored-by: kezhenxu94 <kezhenxu94@apache.org>
2.0.7-release
wind 3 years ago committed by GitHub
parent
commit
8c5f364796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertPluginManager.java
  2. 8
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
  3. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/aspect/AccessLogAnnotation.java
  4. 19
      dolphinscheduler-dao/src/main/resources/application-h2.yaml
  5. 6
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
  6. 23
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/plugin/TaskPluginManager.java

8
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertPluginManager.java

@ -35,9 +35,9 @@ import java.util.Optional;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import java.util.Set; import java.util.Set;
import javax.annotation.PostConstruct;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
@ -52,8 +52,8 @@ public final class AlertPluginManager {
this.pluginDao = pluginDao; this.pluginDao = pluginDao;
} }
@PostConstruct @EventListener
public void installPlugin() { public void installPlugin(ApplicationReadyEvent readyEvent) {
final Set<String> names = new HashSet<>(); final Set<String> names = new HashSet<>();
ServiceLoader.load(AlertChannelFactory.class).forEach(factory -> { ServiceLoader.load(AlertChannelFactory.class).forEach(factory -> {

8
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java

@ -32,16 +32,16 @@ import java.util.List;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType; import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.event.EventListener;
@EnableAutoConfiguration @EnableAutoConfiguration
@ComponentScan(value = { @ComponentScan(value = {
@ -73,8 +73,8 @@ public class AlertServer implements Closeable {
.run(args); .run(args);
} }
@PostConstruct @EventListener
public void start() { public void start(ApplicationReadyEvent readyEvent) {
log.info("Starting Alert server"); log.info("Starting Alert server");
checkTable(); checkTable();

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/aspect/AccessLogAnnotation.java

@ -28,7 +28,7 @@ import java.lang.annotation.Target;
@Documented @Documented
public @interface AccessLogAnnotation { public @interface AccessLogAnnotation {
// ignore request args // ignore request args
String[] ignoreRequestArgs() default {}; String[] ignoreRequestArgs() default {"loginUser"};
boolean ignoreRequest() default false; boolean ignoreRequest() default false;

19
dolphinscheduler-dao/src/main/resources/application-h2.yaml

@ -16,19 +16,14 @@
# under the License. # under the License.
# #
spring: spring:
sql:
init:
schema-locations: classpath:sql/dolphinscheduler_h2.sql
datasource: datasource:
driver-class-name: org.h2.Driver driver-class-name: org.h2.Driver
url: jdbc:h2:mem:dolphinscheduler;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true;INIT=runscript from 'classpath:sql/dolphinscheduler_h2.sql' url: jdbc:h2:mem:dolphinscheduler;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true
username: sa username: sa
password: "" password: ""
hikari: jpa:
connection-test-query: select 1 hibernate:
minimum-idle: 5 ddl-auto: none
auto-commit: true
validation-timeout: 3000
pool-name: DolphinScheduler
maximum-pool-size: 50
connection-timeout: 30000
idle-timeout: 600000
leak-detection-threshold: 0
initialization-fail-timeout: 1

6
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java

@ -50,8 +50,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.WebApplicationType; import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.FilterType;
import org.springframework.context.event.EventListener;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
/** /**
@ -127,8 +129,8 @@ public class MasterServer implements IStoppable {
/** /**
* run master server * run master server
*/ */
@PostConstruct @EventListener
public void run() { public void run(ApplicationReadyEvent ignored) {
PropertyUtils.setValue(SPRING_DATASOURCE_DRIVER_CLASS_NAME, driverClassName); PropertyUtils.setValue(SPRING_DATASOURCE_DRIVER_CLASS_NAME, driverClassName);
// init remoting server // init remoting server

23
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/plugin/TaskPluginManager.java

@ -17,6 +17,8 @@
package org.apache.dolphinscheduler.server.worker.plugin; package org.apache.dolphinscheduler.server.worker.plugin;
import static java.lang.String.format;
import org.apache.dolphinscheduler.common.enums.PluginType; import org.apache.dolphinscheduler.common.enums.PluginType;
import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.enums.TaskType;
import org.apache.dolphinscheduler.dao.PluginDao; import org.apache.dolphinscheduler.dao.PluginDao;
@ -25,15 +27,20 @@ import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.task.TaskChannel; import org.apache.dolphinscheduler.spi.task.TaskChannel;
import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import org.apache.dolphinscheduler.spi.task.TaskChannelFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import java.util.Collections;
import java.util.*; import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import static java.lang.String.format; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
@Component @Component
public class TaskPluginManager { public class TaskPluginManager {
@ -56,8 +63,8 @@ public class TaskPluginManager {
return Collections.unmodifiableMap(taskChannelMap); return Collections.unmodifiableMap(taskChannelMap);
} }
@PostConstruct @EventListener
public void installPlugin() { public void installPlugin(ApplicationReadyEvent readyEvent) {
final Set<String> names = new HashSet<>(); final Set<String> names = new HashSet<>();
ServiceLoader.load(TaskChannelFactory.class).forEach(factory -> { ServiceLoader.load(TaskChannelFactory.class).forEach(factory -> {

Loading…
Cancel
Save