11 #include <unordered_map>
14 #include "common/datatypes/DataSet.h"
16 #define ErrorCodeEnums \
20 X(E_DISCONNECTED, -1) \
21 X(E_FAIL_TO_CONNECT, -2) \
22 X(E_RPC_FAILURE, -3) \
23 X(E_LEADER_CHANGED, -4) \
26 X(E_SPACE_NOT_FOUND, -5) \
27 X(E_TAG_NOT_FOUND, -6) \
28 X(E_EDGE_NOT_FOUND, -7) \
29 X(E_INDEX_NOT_FOUND, -8) \
30 X(E_EDGE_PROP_NOT_FOUND, -9) \
31 X(E_TAG_PROP_NOT_FOUND, -10) \
32 X(E_ROLE_NOT_FOUND, -11) \
33 X(E_CONFIG_NOT_FOUND, -12) \
34 X(E_MACHINE_NOT_FOUND, -13) \
35 X(E_ZONE_NOT_FOUND, -14) \
36 X(E_LISTENER_NOT_FOUND, -15) \
37 X(E_PART_NOT_FOUND, -16) \
38 X(E_KEY_NOT_FOUND, -17) \
39 X(E_USER_NOT_FOUND, -18) \
40 X(E_DRAINER_NOT_FOUND, -21) \
41 X(E_DRAINER_CLIENT_NOT_FOUND, -22) \
42 X(E_PART_STOPPED, -23) \
45 X(E_BACKUP_FAILED, -24) \
46 X(E_BACKUP_EMPTY_TABLE, -25) \
47 X(E_BACKUP_TABLE_FAILED, -26) \
48 X(E_PARTIAL_RESULT, -27) \
49 X(E_REBUILD_INDEX_FAILED, -28) \
50 X(E_INVALID_PASSWORD, -29) \
51 X(E_FAILED_GET_ABS_PATH, -30) \
52 X(E_LISTENER_PROGRESS_FAILED, -31) \
53 X(E_SYNC_LISTENER_NOT_FOUND, -32) \
54 X(E_DRAINER_PROGRESS_FAILED, -33) \
55 X(E_PART_DISABLED, -34) \
56 X(E_PART_ALREADY_STARTED, -35) \
57 X(E_PART_ALREADY_STOPPED, -36) \
60 X(E_BAD_USERNAME_PASSWORD, -1001) \
61 X(E_SESSION_INVALID, -1002) \
62 X(E_SESSION_TIMEOUT, -1003) \
63 X(E_SYNTAX_ERROR, -1004) \
64 X(E_EXECUTION_ERROR, -1005) \
65 X(E_STATEMENT_EMPTY, -1006) \
67 X(E_BAD_PERMISSION, -1008) \
68 X(E_SEMANTIC_ERROR, -1009) \
69 X(E_TOO_MANY_CONNECTIONS, -1010) \
70 X(E_PARTIAL_SUCCEEDED, -1011) \
73 X(E_NO_HOSTS, -2001) \
75 X(E_INVALID_HOST, -2003) \
76 X(E_UNSUPPORTED, -2004) \
77 X(E_NOT_DROP, -2005) \
78 X(E_BALANCER_RUNNING, -2006) \
79 X(E_CONFIG_IMMUTABLE, -2007) \
80 X(E_CONFLICT, -2008) \
81 X(E_INVALID_PARM, -2009) \
82 X(E_WRONGCLUSTER, -2010) \
83 X(E_ZONE_NOT_ENOUGH, -2011) \
84 X(E_ZONE_IS_EMPTY, -2012) \
85 X(E_LISTENER_CONFLICT, -2013) \
86 X(E_SCHEMA_NAME_EXISTS, -2014) \
87 X(E_RELATED_INDEX_EXISTS, -2015) \
88 X(E_RELATED_SPACE_EXISTS, -2016) \
89 X(E_RELATED_FULLTEXT_INDEX_EXISTS, -2017) \
90 X(E_HISTORY_CONFLICT, -2018) \
92 X(E_STORE_FAILURE, -2021) \
93 X(E_STORE_SEGMENT_ILLEGAL, -2022) \
94 X(E_BAD_BALANCE_PLAN, -2023) \
95 X(E_BALANCED, -2024) \
96 X(E_NO_RUNNING_BALANCE_PLAN, -2025) \
97 X(E_NO_VALID_HOST, -2026) \
98 X(E_CORRUPTED_BALANCE_PLAN, -2027) \
99 X(E_NO_INVALID_BALANCE_PLAN, -2028) \
100 X(E_NO_VALID_DRAINER, -2029) \
103 X(E_IMPROPER_ROLE, -2030) \
104 X(E_INVALID_PARTITION_NUM, -2031) \
105 X(E_INVALID_REPLICA_FACTOR, -2032) \
106 X(E_INVALID_CHARSET, -2033) \
107 X(E_INVALID_COLLATE, -2034) \
108 X(E_CHARSET_COLLATE_NOT_MATCH, -2035) \
109 X(E_PRIVILEGE_ALL_TAG_EDGE_SETTLED, -2036) \
110 X(E_PRIVILEGE_NOT_EXIST, -2037) \
111 X(E_PRIVILEGE_NEED_BASIC_ROLE, -2038) \
112 X(E_PRIVILEGE_ACTION_INVALID, -2039) \
115 X(E_SNAPSHOT_FAILURE, -2040) \
116 X(E_SNAPSHOT_RUNNING_JOBS, -2056) \
117 X(E_SNAPSHOT_NOT_FOUND, -2057) \
118 X(E_BLOCK_WRITE_FAILURE, -2041) \
119 X(E_REBUILD_INDEX_FAILURE, -2042) \
120 X(E_INDEX_WITH_TTL, -2043) \
121 X(E_ADD_JOB_FAILURE, -2044) \
122 X(E_STOP_JOB_FAILURE, -2045) \
123 X(E_SAVE_JOB_FAILURE, -2046) \
124 X(E_BALANCER_FAILURE, -2047) \
125 X(E_JOB_NOT_FINISHED, -2048) \
126 X(E_TASK_REPORT_OUT_DATE, -2049) \
127 X(E_JOB_NOT_IN_SPACE, -2050) \
128 X(E_JOB_NEED_RECOVER, -2051) \
129 X(E_JOB_ALREADY_FINISH, -2052) \
130 X(E_JOB_SUBMITTED, -2053) \
131 X(E_JOB_NOT_STOPPABLE, -2054) \
132 X(E_JOB_HAS_NO_TARGET_STORAGE, -2055) \
133 X(E_INVALID_JOB, -2065) \
136 X(E_BACKUP_RUNNING_JOBS, -2066) \
137 X(E_BACKUP_SPACE_NOT_FOUND, -2067) \
140 X(E_RESTORE_FAILURE, -2068) \
141 X(E_SESSION_NOT_FOUND, -2069) \
144 X(E_LIST_CLUSTER_FAILURE, -2070) \
145 X(E_LIST_CLUSTER_GET_ABS_PATH_FAILURE, -2071) \
146 X(E_LIST_CLUSTER_NO_AGENT_FAILURE, -2072) \
148 X(E_QUERY_NOT_FOUND, -2073) \
149 X(E_AGENT_HB_FAILUE, -2074) \
150 X(E_INVALID_VARIABLE, -2080) \
151 X(E_VARIABLE_TYPE_VALUE_MISMATCH, -2081) \
152 X(E_HOST_CAN_NOT_BE_ADDED, -2082) \
153 X(E_ACCESS_ES_FAILURE, -2090) \
154 X(E_GRAPH_MEMORY_EXCEEDED, -2600) \
156 X(E_CONSENSUS_ERROR, -3001) \
157 X(E_KEY_HAS_EXISTS, -3002) \
158 X(E_DATA_TYPE_MISMATCH, -3003) \
159 X(E_INVALID_FIELD_VALUE, -3004) \
160 X(E_INVALID_OPERATION, -3005) \
161 X(E_NOT_NULLABLE, -3006) \
163 X(E_FIELD_UNSET, -3007) \
165 X(E_OUT_OF_RANGE, -3008) \
167 X(E_ATOMIC_OP_FAILED, -3009) \
169 X(E_DATA_CONFLICT_ERROR, -3010) \
171 X(E_WRITE_STALLED, -3011) \
174 X(E_IMPROPER_DATA_TYPE, -3021) \
175 X(E_INVALID_SPACEVIDLEN, -3022) \
178 X(E_INVALID_FILTER, -3031) \
179 X(E_INVALID_UPDATER, -3032) \
180 X(E_INVALID_STORE, -3033) \
181 X(E_INVALID_PEER, -3034) \
182 X(E_RETRY_EXHAUSTED, -3035) \
183 X(E_TRANSFER_LEADER_FAILED, -3036) \
184 X(E_INVALID_STAT_TYPE, -3037) \
185 X(E_INVALID_VID, -3038) \
186 X(E_NO_TRANSFORMED, -3039) \
189 X(E_LOAD_META_FAILED, -3040) \
192 X(E_FAILED_TO_CHECKPOINT, -3041) \
193 X(E_CHECKPOINT_BLOCKED, -3042) \
196 X(E_FILTER_OUT, -3043) \
197 X(E_INVALID_DATA, -3044) \
199 X(E_MUTATE_EDGE_CONFLICT, -3045) \
200 X(E_MUTATE_TAG_CONFLICT, -3046) \
203 X(E_OUTDATED_LOCK, -3047) \
206 X(E_INVALID_TASK_PARA, -3051) \
207 X(E_USER_CANCEL, -3052) \
208 X(E_TASK_EXECUTION_FAILED, -3053) \
210 X(E_PLAN_IS_KILLED, -3060) \
211 X(E_CLIENT_SERVER_INCOMPATIBLE, -3061) \
213 X(E_ID_FAILED, -3062) \
216 X(E_RAFT_UNKNOWN_PART, -3500) \
219 X(E_RAFT_LOG_GAP, -3501) \
220 X(E_RAFT_LOG_STALE, -3502) \
221 X(E_RAFT_TERM_OUT_OF_DATE, -3503) \
222 X(E_RAFT_UNKNOWN_APPEND_LOG, -3504) \
225 X(E_RAFT_WAITING_SNAPSHOT, -3511) \
226 X(E_RAFT_SENDING_SNAPSHOT, -3512) \
227 X(E_RAFT_INVALID_PEER, -3513) \
228 X(E_RAFT_NOT_READY, -3514) \
229 X(E_RAFT_STOPPED, -3515) \
230 X(E_RAFT_BAD_ROLE, -3516) \
233 X(E_RAFT_WAL_FAIL, -3521) \
234 X(E_RAFT_HOST_STOPPED, -3522) \
235 X(E_RAFT_TOO_MANY_REQUESTS, -3523) \
236 X(E_RAFT_PERSIST_SNAPSHOT_FAILED, -3524) \
237 X(E_RAFT_RPC_EXCEPTION, -3525) \
238 X(E_RAFT_NO_WAL_FOUND, -3526) \
239 X(E_RAFT_HOST_PAUSED, -3527) \
240 X(E_RAFT_WRITE_BLOCKED, -3528) \
241 X(E_RAFT_BUFFER_OVERFLOW, -3529) \
242 X(E_RAFT_ATOMIC_OP_FAILED, -3530) \
243 X(E_LEADER_LEASE_FAILED, -3531) \
244 X(E_RAFT_CAUGHT_UP, -3532) \
247 X(E_LOG_GAP, -4001) \
248 X(E_LOG_STALE, -4002) \
249 X(E_INVALID_DRAINER_STORE, -4003) \
250 X(E_SPACE_MISMATCH, -4004) \
251 X(E_PART_MISMATCH, -4005) \
252 X(E_DATA_CONFLICT, -4006) \
253 X(E_REQ_CONFLICT, -4007) \
254 X(E_DATA_ILLEGAL, -4008) \
257 X(E_CACHE_CONFIG_ERROR, -5001) \
258 X(E_NOT_ENOUGH_SPACE, -5002) \
259 X(E_CACHE_MISS, -5003) \
260 X(E_POOL_NOT_FOUND, -5004) \
261 X(E_CACHE_WRITE_FAILURE, -5005) \
265 X(E_NODE_NUMBER_EXCEED_LIMIT, -7001) \
266 X(E_PARSING_LICENSE_FAILURE, -7002) \
268 X(E_STORAGE_MEMORY_EXCEEDED, -3600) \
273 #define X(EnumName, EnumNumber) EnumName = EnumNumber,
275 enum class ErrorCode { ErrorCodeEnums };
279 const char *getErrorCode(ErrorCode code);
281 static inline std::ostream &operator<<(std::ostream &os, ErrorCode code) {
282 os << getErrorCode(code);
286 template <
typename T>
287 bool inline checkPointer(
const T *lhs,
const T *rhs) {
290 }
else if (lhs !=
nullptr && rhs !=
nullptr) {
301 errorCode = ErrorCode::SUCCEEDED;
311 if (errorCode != rhs.errorCode) {
314 if (!checkPointer(sessionId.get(), rhs.sessionId.get())) {
317 if (!checkPointer(errorMsg.get(), rhs.errorMsg.get())) {
320 if (!checkPointer(timeZoneOffsetSeconds.get(), rhs.timeZoneOffsetSeconds.get())) {
323 return checkPointer(timeZoneName.get(), timeZoneName.get());
326 ErrorCode errorCode{ErrorCode::SUCCEEDED};
327 std::unique_ptr<int64_t> sessionId{
nullptr};
328 std::unique_ptr<std::string> errorMsg{
nullptr};
329 std::unique_ptr<int32_t> timeZoneOffsetSeconds{
nullptr};
330 std::unique_ptr<std::string> timeZoneName{
nullptr};
336 execDurationInUs = 0;
337 totalDurationInUs = 0;
338 otherStats =
nullptr;
346 if (rows != rhs.rows) {
349 if (execDurationInUs != rhs.execDurationInUs) {
352 if (totalDurationInUs != rhs.totalDurationInUs) {
355 return checkPointer(otherStats.get(), rhs.otherStats.get());
361 int64_t execDurationInUs{0};
363 int64_t totalDurationInUs{0};
365 std::unique_ptr<std::unordered_map<std::string, std::string>> otherStats;
372 conditionNodeId = -1;
380 return isDoBranch == rhs.isDoBranch && conditionNodeId == rhs.conditionNodeId;
386 int64_t conditionNodeId{-1};
399 bool operator==(
const Pair &rhs)
const {
400 return key == rhs.key && value == rhs.value;
412 description =
nullptr;
414 branchInfo =
nullptr;
415 dependencies =
nullptr;
426 std::string outputVar;
428 std::unique_ptr<std::vector<Pair>> description{
nullptr};
431 std::unique_ptr<std::vector<ProfilingStats>> profiles{
nullptr};
432 std::unique_ptr<PlanNodeBranchInfo> branchInfo{
nullptr};
433 std::unique_ptr<std::vector<int64_t>> dependencies{
nullptr};
438 planNodeDescs.clear();
439 nodeIndexMap.clear();
441 optimize_time_in_us = 0;
449 return planNodeDescs == rhs.planNodeDescs && nodeIndexMap == rhs.nodeIndexMap &&
450 format == rhs.format;
453 std::vector<PlanNodeDescription> planNodeDescs;
455 std::unordered_map<int64_t, int64_t> nodeIndexMap;
459 int32_t optimize_time_in_us{0};
464 errorCode = ErrorCode::SUCCEEDED;
478 if (errorCode != rhs.errorCode) {
481 if (latencyInUs != rhs.latencyInUs) {
484 if (!checkPointer(data.get(), rhs.data.get())) {
487 if (!checkPointer(spaceName.get(), rhs.spaceName.get())) {
490 if (!checkPointer(errorMsg.get(), rhs.errorMsg.get())) {
493 if (!checkPointer(planDesc.get(), rhs.planDesc.get())) {
496 if (!checkPointer(comment.get(), rhs.comment.get())) {
502 ErrorCode errorCode{ErrorCode::SUCCEEDED};
503 int64_t latencyInUs{0};
504 std::unique_ptr<nebula::DataSet> data{
nullptr};
505 std::unique_ptr<std::string> spaceName{
nullptr};
506 std::unique_ptr<std::string> errorMsg{
nullptr};
507 std::unique_ptr<PlanDescription> planDesc{
nullptr};
508 std::unique_ptr<std::string> comment{
nullptr};
512 ErrorCode errorCode{ErrorCode::SUCCEEDED};
513 std::unique_ptr<std::string> errorMsg{
nullptr};
518 std::string version{
"3.0.0"};