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

Add config reconnect timeout #161

Merged
merged 22 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a919f46
modify socketTimeout to 120s
aressu1985 May 2, 2023
efa0f2c
Merge branch 'matrixorigin:main' into main
aressu1985 May 18, 2023
1c62798
add regular match
aressu1985 May 20, 2023
94e47f5
Merge branch 'matrixorigin:main' into main
aressu1985 May 31, 2023
3798e26
support rc + Pessimistic
aressu1985 May 31, 2023
148dfd5
Merge branch 'main' into main
aressu1985 May 31, 2023
a6e0270
Merge branch 'matrixorigin:main' into main
aressu1985 Jul 6, 2023
e111699
Merge branch 'matrixorigin:main' into main
aressu1985 Jul 27, 2023
881add9
Merge branch 'matrixorigin:main' into main
aressu1985 Sep 15, 2023
f339944
revert Fix pessimistic commit wait error
aressu1985 Sep 15, 2023
7558672
revert revert
aressu1985 Sep 15, 2023
e489c5b
Merge branch 'matrixorigin:main' into main
aressu1985 Sep 15, 2023
0773c55
Merge branch 'matrixorigin:main' into main
aressu1985 Sep 15, 2023
50c995d
Merge branch 'matrixorigin:main' into main
aressu1985 Sep 15, 2023
37b8380
Merge branch 'matrixorigin:main' into main
aressu1985 Oct 10, 2023
f0de5ac
Merge branch 'matrixorigin:main' into main
aressu1985 Oct 11, 2023
41a2934
Merge branch 'matrixorigin:main' into main
aressu1985 Oct 18, 2023
2a95912
Merge branch 'matrixorigin:main' into main
aressu1985 Nov 21, 2023
21e93ab
Merge branch 'matrixorigin:main' into main
aressu1985 Jan 16, 2024
fc59c88
Merge branch 'matrixorigin:main' into main
aressu1985 Jan 17, 2024
bc5908f
Merge branch 'matrixorigin:main' into main
aressu1985 Jan 29, 2024
13aab79
add reconnect timeout config
aressu1985 Jan 29, 2024
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
Binary file modified lib/mo-tester-1.0-SNAPSHOT.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions mo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ jdbc:
useLocalSessionState: "true"
zeroDateTimeBehavior: "CONVERT_TO_NULL"
failoverReadOnly: "false"
initialTimeout: 60
autoReconnect: "true"
maxReconnects: 4
serverTimezone: "Asia/Shanghai"
socketTimeout: 120000

#users
user:
name: "dump"
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/mo/Tester.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ public static boolean isInclude(String name){

public static void cleanDatabases(){
Connection connection = ConnectionManager.getConnection();
if(connection == null){
LOG.error("Failed to clean databases,please check the error,the program will exit.");
System.exit(1);
}
String dropDB = "DROP DATABASE IF EXISTS `%s`";
String[] dbs = RunConfUtil.getBuiltinDb();
try {
Expand Down
28 changes: 15 additions & 13 deletions src/main/java/io/mo/db/ConnectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static Connection getConnection(int index){
if(!server_up) return null;

//get db connection,if failed,retry 3 times 10 s interval
for(int i = 0; i < 3; i++) {
//for(int i = 0; i < 3; i++) {
try {
Class.forName(driver);
if (connections[index] == null || connections[index].isClosed()) {
Expand All @@ -43,7 +43,8 @@ public static Connection getConnection(int index){
}
return connections[index];
} catch (SQLException e) {
LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], and will wait 10 seconds and retry...");
//LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], and will wait 10 seconds and retry...");
LOG.error(e.getMessage());
try {
Thread.sleep(10000);
} catch (InterruptedException ex) {
Expand All @@ -52,9 +53,9 @@ public static Connection getConnection(int index){
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}

LOG.error("The mo-tester still can not get valid conneciton from mo, the following cases wil not be executed!");
//}
LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], the following cases wil not be executed!");
server_up = false;
return null;
}
Expand All @@ -64,7 +65,7 @@ public static Connection getConnection(int index, String userName, String pwd){
if(!server_up) return null;

//get db connection,if failed,retry 3 times 10 s interval
for(int i = 0; i < 3; i++) {
//for(int i = 0; i < 3; i++) {
try {
Class.forName(driver);
if (connections[index] == null || connections[index].isClosed()) {
Expand All @@ -74,7 +75,8 @@ public static Connection getConnection(int index, String userName, String pwd){
}
return connections[index];
} catch (SQLException e) {
LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], and will wait 10 seconds and retry...");
//LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], and will wait 10 seconds and retry...");
LOG.error(e.getMessage());
try {
Thread.sleep(10000);
} catch (InterruptedException ex) {
Expand All @@ -83,9 +85,9 @@ public static Connection getConnection(int index, String userName, String pwd){
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
//}

LOG.error("The mo-tester still can not get valid conneciton from mo, the following cases wil not be executed!");
LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], the following cases wil not be executed!");
server_up = false;
return null;
}
Expand All @@ -95,15 +97,15 @@ public static Connection getConnectionForSys(){
if(!server_up) return null;

//get db connection,if failed,retry 3 times 10 s interval
for(int i = 0; i < 3; i++) {
//for(int i = 0; i < 3; i++) {
try {
Class.forName(driver);
if (sysconn == null || sysconn.isClosed()) {
sysconn = DriverManager.getConnection(jdbcURL, sysuser, syspass);
}
return sysconn;
} catch (SQLException e) {
LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"] for sys user, and will wait 10 seconds and retry...");
//LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"] for sys user, and will wait 10 seconds and retry...");
try {
Thread.sleep(10000);
} catch (InterruptedException ex) {
Expand All @@ -112,9 +114,9 @@ public static Connection getConnectionForSys(){
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
//}

LOG.error("The mo-tester still can not get valid conneciton from mo for sys user, the following cases wil not be executed!");
LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], the following cases wil not be executed!");
server_up = false;
return null;
}
Expand Down
Loading