Skip to content

Commit 1e54324

Browse files
szzabanmoy
authored andcommitted
[Enhancement] no need to getLabelState if an existing label is finished (StarRocks#231)
Signed-off-by: shuzz <[email protected]>
1 parent 0212807 commit 1e54324

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

starrocks-stream-load-sdk/src/main/java/com/starrocks/data/load/stream/DefaultStreamLoader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,13 @@ protected StreamLoadResponse send(StreamLoadTableProperties tableProperties, Tab
272272
streamLoadResponse.setCostNanoTime(System.nanoTime() - startNanoTime);
273273
region.complete(streamLoadResponse);
274274
} else if (StreamLoadConstants.RESULT_STATUS_LABEL_EXISTED.equals(status)) {
275-
String labelState = getLabelState(host, region.getDatabase(), region.getTable(), label, Collections.singleton(StreamLoadConstants.LABEL_STATE_PREPARE));
276-
if (StreamLoadConstants.LABEL_STATE_COMMITTED.equals(labelState) || StreamLoadConstants.LABEL_STATE_VISIBLE.equals(labelState)) {
275+
String existingJobStatus = streamLoadBody.getExistingJobStatus();
276+
if (StreamLoadConstants.EXISTING_JOB_STATUS_FINISHED.equals(existingJobStatus)) {
277277
streamLoadResponse.setCostNanoTime(System.nanoTime() - startNanoTime);
278278
region.complete(streamLoadResponse);
279279
} else {
280280
String errorMsage = String.format("Stream load failed because label existed, " +
281-
"db: %s, table: %s, label: %s, label state: %s", region.getDatabase(), region.getTable(), label, labelState);
281+
"db: %s, table: %s, label: %s, existingJobStatus: %s", region.getDatabase(), region.getTable(), label, existingJobStatus);
282282
throw new StreamLoadFailException(errorMsage);
283283
}
284284
} else {

starrocks-stream-load-sdk/src/main/java/com/starrocks/data/load/stream/StreamLoadConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public interface StreamLoadConstants {
2020
String RESULT_STATUS_TRANSACTION_COMMIT_TIMEOUT = "Commit Timeout";
2121
String RESULT_STATUS_TRANSACTION_PUBLISH_TIMEOUT = "Publish Timeout";
2222

23+
String EXISTING_JOB_STATUS_FINISHED = "FINISHED";
24+
2325
String LABEL_STATE_VISIBLE = "VISIBLE";
2426
String LABEL_STATE_COMMITTED = "COMMITTED";
2527
String LABEL_STATE_PREPARED = "PREPARED";

starrocks-stream-load-sdk/src/main/java/com/starrocks/data/load/stream/StreamLoadResponse.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ public String getStatus() {
174174
return status;
175175
}
176176

177+
public String getExistingJobStatus() {
178+
return this.existingJobStatus;
179+
}
180+
177181
public String getMsg() {
178182
return msg;
179183
}

0 commit comments

Comments
 (0)