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

branch-3.0: [improve](mow) add observability on commit and publish cost time #46487 #46736

Open
wants to merge 1 commit into
base: branch-3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions be/src/cloud/cloud_stream_load_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include "cloud/cloud_stream_load_executor.h"

#include <bvar/bvar.h>

#include "cloud/cloud_meta_mgr.h"
#include "cloud/cloud_storage_engine.h"
#include "cloud/config.h"
Expand All @@ -27,6 +29,10 @@

namespace doris {

bvar::Adder<uint64_t> stream_load_commit_retry_counter;
bvar::Window<bvar::Adder<uint64_t>> stream_load_commit_retry_counter_minute(
&stream_load_commit_retry_counter, 60);

enum class TxnOpParamType : int {
ILLEGAL,
WITH_TXN_ID,
Expand Down Expand Up @@ -114,6 +120,7 @@ Status CloudStreamLoadExecutor::commit_txn(StreamLoadContext* ctx) {
.tag("retry_times", retry_times)
.error(st);
retry_times++;
stream_load_commit_retry_counter << 1;
}
return st;
}
Expand Down
4 changes: 4 additions & 0 deletions be/src/http/action/stream_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(streaming_load_duration_ms, MetricUnit::MIL
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(streaming_load_current_processing, MetricUnit::REQUESTS);

bvar::LatencyRecorder g_stream_load_receive_data_latency_ms("stream_load_receive_data_latency_ms");
bvar::LatencyRecorder g_stream_load_commit_and_publish_latency_ms("stream_load",
"commit_and_publish_ms");

static constexpr size_t MIN_CHUNK_SIZE = 64 * 1024;
static const string CHUNK = "chunked";
Expand Down Expand Up @@ -185,6 +187,8 @@ Status StreamLoadAction::_handle(std::shared_ptr<StreamLoadContext> ctx) {
int64_t commit_and_publish_start_time = MonotonicNanos();
RETURN_IF_ERROR(_exec_env->stream_load_executor()->commit_txn(ctx.get()));
ctx->commit_and_publish_txn_cost_nanos = MonotonicNanos() - commit_and_publish_start_time;
g_stream_load_commit_and_publish_latency_ms
<< ctx->commit_and_publish_txn_cost_nanos / 1000000;
}
return Status::OK();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1018,26 +1018,38 @@ private void debugCalcDeleteBitmapRandomTimeout() throws UserException {
public boolean commitAndPublishTransaction(DatabaseIf db, List<Table> tableList, long transactionId,
List<TabletCommitInfo> tabletCommitInfos, long timeoutMillis)
throws UserException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
int retryTimes = 0;
boolean res = false;
while (true) {
try {
res = commitAndPublishTransaction(db, tableList, transactionId, tabletCommitInfos, timeoutMillis, null);
break;
} catch (UserException e) {
LOG.warn("failed to commit txn, txnId={},retryTimes={},exception={}",
transactionId, retryTimes, e);
// only mow table will catch DELETE_BITMAP_LOCK_ERR and need to retry
if (e.getErrorCode() == InternalErrorCode.DELETE_BITMAP_LOCK_ERR) {
retryTimes++;
if (retryTimes >= Config.mow_calculate_delete_bitmap_retry_times) {
// should throw exception after running out of retry times
try {
while (true) {
try {
res = commitAndPublishTransaction(db, tableList, transactionId, tabletCommitInfos, timeoutMillis,
null);
break;
} catch (UserException e) {
LOG.warn("failed to commit txn, txnId={},retryTimes={},exception={}",
transactionId, retryTimes, e);
// only mow table will catch DELETE_BITMAP_LOCK_ERR and need to retry
if (e.getErrorCode() == InternalErrorCode.DELETE_BITMAP_LOCK_ERR) {
retryTimes++;
if (retryTimes >= Config.mow_calculate_delete_bitmap_retry_times) {
// should throw exception after running out of retry times
throw e;
}
} else {
throw e;
}
} else {
throw e;
}
}
} finally {
stopWatch.stop();
long commitAndPublishTime = stopWatch.getTime();
LOG.info("commitAndPublishTransaction txn {} cost {} ms", transactionId, commitAndPublishTime);
if (MetricRepo.isInit) {
MetricRepo.HISTO_COMMIT_AND_PUBLISH_LATENCY.update(commitAndPublishTime);
}
}
return res;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public final class MetricRepo {
public static GaugeMetricImpl<Double> GAUGE_QUERY_ERR_RATE;
public static GaugeMetricImpl<Long> GAUGE_MAX_TABLET_COMPACTION_SCORE;

public static Histogram HISTO_COMMIT_AND_PUBLISH_LATENCY;

private static Map<Pair<EtlJobType, JobState>, Long> loadJobNum = Maps.newHashMap();

private static ScheduledThreadPoolExecutor metricTimer = ThreadPoolManager.newDaemonScheduledThreadPool(1,
Expand Down Expand Up @@ -549,6 +551,9 @@ public Long getValue() {
HISTO_HTTP_COPY_INTO_QUERY_LATENCY = METRIC_REGISTER.histogram(
MetricRegistry.name("http_copy_into_query", "latency", "ms"));

HISTO_COMMIT_AND_PUBLISH_LATENCY = METRIC_REGISTER.histogram(
MetricRegistry.name("txn_commit_and_publish", "latency", "ms"));

// init system metrics
initSystemMetrics();
CloudMetrics.init();
Expand Down
Loading