Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #4274] skip master-select task when db num is 1 #4784

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class ExternalDataSourceServiceImpl implements DataSourceService {

private static final int TRANSACTION_QUERY_TIMEOUT = 5;

private static final int DB_MASTER_SLEECT_THRESHOLD = 1;

private static final String DB_LOAD_ERROR_MSG = "[db-load-error]load jdbc.properties error";

private List<HikariDataSource> dataSourceList = new ArrayList<>();
Expand Down Expand Up @@ -107,7 +109,9 @@ public void init() {
throw new RuntimeException(DB_LOAD_ERROR_MSG);
}

ConfigExecutor.scheduleConfigTask(new SelectMasterTask(), 10, 10, TimeUnit.SECONDS);
if (this.dataSourceList.size() > DB_MASTER_SLEECT_THRESHOLD){
ConfigExecutor.scheduleConfigTask(new SelectMasterTask(), 10, 10, TimeUnit.SECONDS);
}
ConfigExecutor.scheduleConfigTask(new CheckDbHealthTask(), 10, 10, TimeUnit.SECONDS);
}
}
Expand Down