Skip to content

Commit 9c473bc

Browse files
authored
feat: Optimize the load balancing logic to achieve rebalancing after node failure recovery. (#291)
* fix: load properties issue in windows * feat: supports rebalance when node down * fix: WebSocket statement timeout setting resets transport's timeout Closes TD-38565 * --amend * --amend * chore: fix unit test issues * chore: add unit tests
1 parent ce5651d commit 9c473bc

File tree

67 files changed

+5272
-385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+5272
-385
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,5 @@ jobs:
250250
with:
251251
name: service-logs
252252
path: |
253-
/var/log/taosd.log
254-
/var/log/taosadapter.log
255-
retention-days: 1
253+
/var/log/taos/**/*
254+
retention-days: 7

.github/workflows/compatibility-3360.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: build-3360
2+
23
permissions:
34
contents: read
5+
46
on:
57
push:
68
branches:
@@ -69,6 +71,13 @@ jobs:
6971
TDENGINE_CLOUD_URL: ${{ secrets.TDENGINE_CLOUD_URL }}
7072
TD_3360_TEST: 'true'
7173
run: mvn -B clean verify --file pom.xml
72-
74+
- name: Upload logs on failure
75+
if: failure()
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: service-logs
79+
path: |
80+
/var/log/taos/**/*
81+
retention-days: 7
7382

7483

.github/workflows/sonar.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: sonar
22
permissions:
33
contents: read
4+
45
on:
56
push:
67
branches:

deploy-pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<junit.version>4.13.2</junit.version>
5050
<mockito.version>4.11.0</mockito.version>
5151
<slf4j.version>1.7.36</slf4j.version>
52+
<logback.version>1.3.16</logback.version>
5253
</properties>
5354

5455
<dependencies>
@@ -64,6 +65,18 @@
6465
<version>${mockito.version}</version>
6566
<scope>test</scope>
6667
</dependency>
68+
<dependency>
69+
<groupId>org.mockito</groupId>
70+
<artifactId>mockito-inline</artifactId>
71+
<version>${mockito.version}</version>
72+
<scope>test</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>ch.qos.logback</groupId>
76+
<artifactId>logback-classic</artifactId>
77+
<version>${logback.version}</version>
78+
<scope>test</scope>
79+
</dependency>
6780

6881
<dependency>
6982
<groupId>org.apache.httpcomponents</groupId>

pom.xml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@
4444
<netty-all.version>4.1.127.Final</netty-all.version>
4545
<junit.version>4.13.2</junit.version>
4646
<mockito.version>4.11.0</mockito.version>
47-
<slf4j.version>1.7.36</slf4j.version>
48-
47+
<byte-buddy.version>1.12.22</byte-buddy.version>
48+
<slf4j.version>2.0.17</slf4j.version>
49+
<logback.version>1.3.16</logback.version>
4950
</properties>
5051
<dependencies>
5152
<dependency>
@@ -91,6 +92,18 @@
9192
<version>${mockito.version}</version>
9293
<scope>test</scope>
9394
</dependency>
95+
<dependency>
96+
<groupId>net.bytebuddy</groupId>
97+
<artifactId>byte-buddy</artifactId>
98+
<version>${byte-buddy.version}</version>
99+
<scope>test</scope>
100+
</dependency>
101+
<dependency>
102+
<groupId>ch.qos.logback</groupId>
103+
<artifactId>logback-classic</artifactId>
104+
<version>${logback.version}</version>
105+
<scope>test</scope>
106+
</dependency>
94107

95108
</dependencies>
96109

@@ -198,11 +211,19 @@
198211
<plugin>
199212
<groupId>org.apache.maven.plugins</groupId>
200213
<artifactId>maven-surefire-plugin</artifactId>
201-
<version>3.0.0-M6</version>
214+
<version>3.2.5</version>
215+
<configuration>
216+
<skip>true</skip>
217+
</configuration>
202218
<executions>
203219
<execution>
204220
<id>parallel-tests</id>
221+
<phase>test</phase>
222+
<goals>
223+
<goal>test</goal>
224+
</goals>
205225
<configuration>
226+
<skip>false</skip>
206227
<forkCount>10</forkCount>
207228
<reuseForks>false</reuseForks>
208229

@@ -240,6 +261,7 @@
240261
<goal>test</goal>
241262
</goals>
242263
<configuration>
264+
<skip>false</skip>
243265
<forkCount>1</forkCount>
244266
<reuseForks>false</reuseForks>
245267
<parallel>none</parallel>

src/main/java/com/taosdata/jdbc/AbstractConnection.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public void registerStatement(Long stmtId, Statement stmt) {
4242
this.statementsMap.put(stmtId, stmt);
4343
}
4444

45+
public boolean canRebalanced() {
46+
return this.statementsMap.isEmpty();
47+
}
48+
4549
@Override
4650
public abstract Statement createStatement() throws SQLException;
4751

src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,14 @@ private ColumnMetaData buildSuperTableNameMeta(int colIndex) {
17141714
}
17151715

17161716
private String generateDescribeSql(String dbName, String tableName) throws SQLException {
1717-
return "describe " + dbName + "." + getIdentifierQuoteString() + tableName + getIdentifierQuoteString();
1717+
return "describe " +
1718+
getIdentifierQuoteString() +
1719+
dbName +
1720+
getIdentifierQuoteString() +
1721+
"." +
1722+
getIdentifierQuoteString() +
1723+
tableName +
1724+
getIdentifierQuoteString();
17181725
}
17191726

17201727

src/main/java/com/taosdata/jdbc/AbstractDriver.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected Connection getWSConnection(String url, ConnectionParam param, Properti
6262
log.error("Error serializing ConnectionParam", e);
6363
}
6464
}
65-
InFlightRequest inFlightRequest = new InFlightRequest(param.getRequestTimeout(), param.getMaxRequest());
65+
InFlightRequest inFlightRequest = new InFlightRequest(param.getMaxRequest());
6666
param.setTextMessageHandler(message -> {
6767
try {
6868
log.trace("received message: {}", message);
@@ -88,8 +88,6 @@ protected Connection getWSConnection(String url, ConnectionParam param, Properti
8888
FetchBlockData fetchBlockData = FetchDataUtil.getFetchMap().get(id);
8989
if (null != fetchBlockData) {
9090
Utils.retainByteBuf(byteBuf);
91-
byte[] bytes = new byte[byteBuf.readableBytes()];
92-
byteBuf.getBytes(byteBuf.readerIndex(), bytes);
9391

9492
FetchBlockNewResp fetchBlockResp = new FetchBlockNewResp(byteBuf);
9593
try {

src/main/java/com/taosdata/jdbc/SchemalessWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private void init(String host, String port, String user, String password, String
156156
.setRequestTimeout(timeout)
157157
.setUseSsl(useSSL)
158158
.build();
159-
InFlightRequest inFlightRequest = new InFlightRequest(timeout, 20);
159+
InFlightRequest inFlightRequest = new InFlightRequest(20);
160160
param.setTextMessageHandler(message -> {
161161
try {
162162
JsonNode jsonObject = JsonUtil.getObjectReader().readTree(message);

src/main/java/com/taosdata/jdbc/TSDBConstants.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public abstract class TSDBConstants {
9393
public static final int DEFAULT_MESSAGE_WAIT_TIMEOUT = 60_000;
9494
public static final boolean DEFAULT_BATCH_ERROR_IGNORE = false;
9595

96-
9796
public static final short MAX_UNSIGNED_BYTE = 255;
9897
public static final int MAX_UNSIGNED_SHORT = 65535;
9998
public static final long MAX_UNSIGNED_INT = 4294967295L;

0 commit comments

Comments
 (0)