Skip to content

[optimize](load) Update Threshold for Force Flush in Batch Stream Load #561

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -84,8 +84,14 @@ public class DorisBatchStreamLoad implements Serializable {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final List<String> DORIS_SUCCESS_STATUS =
new ArrayList<>(Arrays.asList(SUCCESS, PUBLISH_TIMEOUT));
private static final long STREAM_LOAD_MAX_BYTES = 10 * 1024 * 1024 * 1024L; // 10 GB
private static final long STREAM_LOAD_MAX_ROWS = Integer.MAX_VALUE;
// Set the force flush threshold to 0.85 to prevent stream load tasks from failing when the data
// size exceeds 10GB.
private static final double STREAM_LOAD_FORCE_FLUSH_THRESHOLD_RATIO = 0.85;
private static final long STREAM_LOAD_MAX_BYTES =
(long) (10 * 1024 * 1024 * 1024L * STREAM_LOAD_FORCE_FLUSH_THRESHOLD_RATIO);
private static final long STREAM_LOAD_MAX_ROWS =
(long) (Integer.MAX_VALUE * STREAM_LOAD_FORCE_FLUSH_THRESHOLD_RATIO);

private final LabelGenerator labelGenerator;
private final byte[] lineDelimiter;
private static final String LOAD_URL_PATTERN = "http://%s/api/%s/%s/_stream_load";
Expand Down Expand Up @@ -224,7 +230,7 @@ public void writeRecord(String database, String table, byte[] record) {
|| buffer.getNumOfRecords() >= STREAM_LOAD_MAX_ROWS) {
// The buffer capacity exceeds the stream load limit, flush
boolean flush = bufferFullFlush(bufferKey);
LOG.info("trigger flush by buffer exceeding the limit, flush: {}", flush);
LOG.info("trigger flush by buffer exceeding the threshold limit, flush: {}", flush);
}
}

Expand All @@ -244,11 +250,9 @@ private synchronized boolean doFlush(
String bufferKey, boolean waitUtilDone, boolean bufferFull) {
checkFlushException();
if (waitUtilDone || bufferFull) {
boolean flush = flush(bufferKey, waitUtilDone);
return flush;
return flush(bufferKey, waitUtilDone);
} else if (flushQueue.size() < executionOptions.getFlushQueueSize()) {
boolean flush = flush(bufferKey, false);
return flush;
return flush(bufferKey, false);
}
return false;
}
Expand Down