26
26
#include " common/status.h"
27
27
#include " runtime/client_cache.h"
28
28
#include " runtime/exec_env.h"
29
+ #include " util/debug_points.h"
29
30
#include " util/runtime_profile.h"
30
31
#include " util/thrift_rpc_helper.h"
31
32
@@ -44,10 +45,18 @@ void AutoIncIDBuffer::set_batch_size_at_least(size_t batch_size) {
44
45
}
45
46
46
47
Result<int64_t > AutoIncIDBuffer::_fetch_ids_from_fe (size_t length) {
48
+ LOG_INFO (
49
+ " [AutoIncIDBuffer::_fetch_ids_from_fe] begin to fetch auto-increment values from fe, "
50
+ " db_id={}, table_id={}, column_id={}, length={}" ,
51
+ _db_id, _table_id, _column_id, length);
47
52
constexpr uint32_t FETCH_AUTOINC_MAX_RETRY_TIMES = 3 ;
48
53
_rpc_status = Status::OK ();
49
54
TNetworkAddress master_addr = ExecEnv::GetInstance ()->cluster_info ()->master_fe_addr ;
50
55
for (uint32_t retry_times = 0 ; retry_times < FETCH_AUTOINC_MAX_RETRY_TIMES; retry_times++) {
56
+ DBUG_EXECUTE_IF (" AutoIncIDBuffer::_fetch_ids_from_fe.failed" , {
57
+ _rpc_status = Status::InternalError<false >(" injected error" );
58
+ break ;
59
+ });
51
60
TAutoIncrementRangeRequest request;
52
61
TAutoIncrementRangeResult result;
53
62
request.__set_db_id (_db_id);
@@ -67,8 +76,9 @@ Result<int64_t> AutoIncIDBuffer::_fetch_ids_from_fe(size_t length) {
67
76
68
77
if (_rpc_status.is <ErrorCode::NOT_MASTER>()) {
69
78
LOG_WARNING (
70
- " Failed to fetch auto-incremnt range, requested to non-master FE@{}:{}, change "
71
- " to request to FE@{}:{}. retry_time={}, db_id={}, table_id={}, column_id={}" ,
79
+ " Failed to fetch auto-increment range, requested to non-master FE@{}:{}, "
80
+ " change to request to FE@{}:{}. retry_time={}, db_id={}, table_id={}, "
81
+ " column_id={}" ,
72
82
master_addr.hostname , master_addr.port , result.master_address .hostname ,
73
83
result.master_address .port , retry_times, _db_id, _table_id, _column_id);
74
84
master_addr = result.master_address ;
@@ -78,15 +88,15 @@ Result<int64_t> AutoIncIDBuffer::_fetch_ids_from_fe(size_t length) {
78
88
79
89
if (!_rpc_status.ok ()) {
80
90
LOG_WARNING (
81
- " Failed to fetch auto-incremnt range, encounter rpc failure. "
91
+ " Failed to fetch auto-increment range, encounter rpc failure. "
82
92
" errmsg={}, retry_time={}, db_id={}, table_id={}, column_id={}" ,
83
93
_rpc_status.to_string (), retry_times, _db_id, _table_id, _column_id);
84
94
std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
85
95
continue ;
86
96
}
87
97
if (result.length != length) [[unlikely]] {
88
98
auto msg = fmt::format (
89
- " Failed to fetch auto-incremnt range, request length={}, but get "
99
+ " Failed to fetch auto-increment range, request length={}, but get "
90
100
" result.length={}, retry_time={}, db_id={}, table_id={}, column_id={}" ,
91
101
length, result.length , retry_times, _db_id, _table_id, _column_id);
92
102
LOG (WARNING) << msg;
@@ -96,14 +106,14 @@ Result<int64_t> AutoIncIDBuffer::_fetch_ids_from_fe(size_t length) {
96
106
}
97
107
98
108
LOG_INFO (
99
- " get auto-incremnt range from FE@{}:{}, start={}, length={}, elapsed={}ms, "
109
+ " get auto-increment range from FE@{}:{}, start={}, length={}, elapsed={}ms, "
100
110
" retry_time={}, db_id={}, table_id={}, column_id={}" ,
101
111
master_addr.hostname , master_addr.port , result.start , result.length ,
102
112
get_auto_inc_range_rpc_ns / 1000000 , retry_times, _db_id, _table_id, _column_id);
103
113
return result.start ;
104
114
}
105
115
CHECK (!_rpc_status.ok ());
106
- return _rpc_status;
116
+ return ResultError ( _rpc_status) ;
107
117
}
108
118
109
119
void AutoIncIDBuffer::_get_autoinc_ranges_from_buffers (
@@ -153,10 +163,19 @@ Status AutoIncIDBuffer::_launch_async_fetch_task(size_t length) {
153
163
RETURN_IF_ERROR (_rpc_token->submit_func ([=, this ]() {
154
164
auto && res = _fetch_ids_from_fe (length);
155
165
if (!res.has_value ()) [[unlikely]] {
166
+ auto && err = res.error ();
167
+ LOG_WARNING (
168
+ " [AutoIncIDBuffer::_launch_async_fetch_task] failed to fetch auto-increment "
169
+ " values from fe, db_id={}, table_id={}, column_id={}, status={}" ,
170
+ _db_id, _table_id, _column_id, err);
156
171
_is_fetching = false ;
157
172
return ;
158
173
}
159
174
int64_t start = res.value ();
175
+ LOG_INFO (
176
+ " [AutoIncIDBuffer::_launch_async_fetch_task] successfully fetch auto-increment "
177
+ " values from fe, db_id={}, table_id={}, column_id={}, start={}, length={}" ,
178
+ _db_id, _table_id, _column_id, start, length);
160
179
{
161
180
std::lock_guard<std::mutex> lock {_latch};
162
181
_buffers.emplace_back (start, length);
@@ -167,4 +186,4 @@ Status AutoIncIDBuffer::_launch_async_fetch_task(size_t length) {
167
186
return Status::OK ();
168
187
}
169
188
170
- } // namespace doris::vectorized
189
+ } // namespace doris::vectorized
0 commit comments