本文介绍如何获取所有ClickHouse http查询错误代码,通过对比错误代码更好理解HTTP请求的响应头信息。另外ClickHouse会在系统表中保留所有查询日志,如何保留查询相对平衡,避免日志过大占用大量磁盘空间。
ClickHouse错误代码
当通过HTTP协议查询ClickHouse接口时,在错误响应头中会有错误编码,特别要注意 X-ClickHouse-Exception-Code
字段,但有时我们需要理解错误编码对应的含义。通过下面语句可以查看所有可能的错误代码,基于这些代码,可以快速了解错误原因。
SELECT concat('\t', name, ' = ', toString(number))
FROM
(
SELECT
number,
errorCodeToName(number) AS name
FROM system.numbers
LIMIT 2000
)
WHERE NOT empty(errorCodeToName(number))
Query id: 1fa5b4fa-4baf-4aa6-b2f3-ba7780010168
┌─concat('\t', name, ' = ', toString(number))────────────────────┐
│ OK = 0 │
│ UNSUPPORTED_METHOD = 1 │
│ UNSUPPORTED_PARAMETER = 2 │
│ UNEXPECTED_END_OF_FILE = 3 │
│ EXPECTED_END_OF_FILE = 4 │
│ CANNOT_PARSE_TEXT = 6 │
│ INCORRECT_NUMBER_OF_COLUMNS = 7 │
│ THERE_IS_NO_COLUMN = 8 │
│ SIZES_OF_COLUMNS_DOESNT_MATCH = 9 │
│ NOT_FOUND_COLUMN_IN_BLOCK = 10 │
│ POSITION_OUT_OF_BOUND = 11 │
│ PARAMETER_OUT_OF_BOUND = 12 │
│ SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH = 13 │
│ DUPLICATE_COLUMN = 15 │
│ NO_SUCH_COLUMN_IN_TABLE = 16 │
│ DELIMITER_IN_STRING_LITERAL_DOESNT_MATCH = 17 │
│ CANNOT_INSERT_ELEMENT_INTO_CONSTANT_COLUMN = 18 │
│ SIZE_OF_FIXED_STRING_DOESNT_MATCH = 19 │
│ NUMBER_OF_COLUMNS_DOESNT_MATCH = 20 │
│ CANNOT_READ_ALL_DATA_FROM_TAB_SEPARATED_INPUT = 21 │
│ CANNOT_PARSE_ALL_VALUE_FROM_TAB_SEPARATED_INPUT = 22 │
│ CANNOT_READ_FROM_ISTREAM = 23 │
│ CANNOT_WRITE_TO_OSTREAM = 24 │
│ CANNOT_PARSE_ESCAPE_SEQUENCE = 25 │
│ CANNOT_PARSE_QUOTED_STRING = 26 │
│ CANNOT_PARSE_INPUT_ASSERTION_FAILED = 27 │
│ CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER = 28 │
│ CANNOT_PRINT_INTEGER = 29 │
│ CANNOT_READ_SIZE_OF_COMPRESSED_CHUNK = 30 │
│ CANNOT_READ_COMPRESSED_CHUNK = 31 │
│ ATTEMPT_TO_READ_AFTER_EOF = 32 │
│ CANNOT_READ_ALL_DATA = 33 │
│ TOO_MANY_ARGUMENTS_FOR_FUNCTION = 34 │
│ TOO_FEW_ARGUMENTS_FOR_FUNCTION = 35 │
│ BAD_ARGUMENTS = 36 │
│ UNKNOWN_ELEMENT_IN_AST = 37 │
│ CANNOT_PARSE_DATE = 38 │
│ TOO_LARGE_SIZE_COMPRESSED = 39 │
│ CHECKSUM_DOESNT_MATCH = 40 │
│ CANNOT_PARSE_DATETIME = 41 │
│ NUMBER_OF_ARGUMENTS_DOESNT_MATCH = 42 │
│ ILLEGAL_TYPE_OF_ARGUMENT = 43 │
│ ILLEGAL_COLUMN = 44 │
│ ILLEGAL_NUMBER_OF_RESULT_COLUMNS = 45 │
│ UNKNOWN_FUNCTION = 46 │
│ UNKNOWN_IDENTIFIER = 47 │
│ NOT_IMPLEMENTED = 48 │
│ LOGICAL_ERROR = 49 │
│ UNKNOWN_TYPE = 50 │
│ EMPTY_LIST_OF_COLUMNS_QUERIED = 51 │
│ COLUMN_QUERIED_MORE_THAN_ONCE = 52 │
│ TYPE_MISMATCH = 53 │
│ STORAGE_DOESNT_ALLOW_PARAMETERS = 54 │
│ STORAGE_REQUIRES_PARAMETER = 55 │
│ UNKNOWN_STORAGE = 56 │
│ TABLE_ALREADY_EXISTS = 57 │
│ TABLE_METADATA_ALREADY_EXISTS = 58 │
│ ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER = 59 │
│ UNKNOWN_TABLE = 60 │
│ ONLY_FILTER_COLUMN_IN_BLOCK = 61 │
│ SYNTAX_ERROR = 62 │
│ UNKNOWN_AGGREGATE_FUNCTION = 63 │
│ CANNOT_READ_AGGREGATE_FUNCTION_FROM_TEXT = 64 │
│ CANNOT_WRITE_AGGREGATE_FUNCTION_AS_TEXT = 65 │
│ NOT_A_COLUMN = 66 │
│ ILLEGAL_KEY_OF_AGGREGATION = 67 │
│ CANNOT_GET_SIZE_OF_FIELD = 68 │
│ ARGUMENT_OUT_OF_BOUND = 69 │
│ CANNOT_CONVERT_TYPE = 70 │
│ CANNOT_WRITE_AFTER_END_OF_BUFFER = 71 │
│ CANNOT_PARSE_NUMBER = 72 │
│ UNKNOWN_FORMAT = 73 │
│ CANNOT_READ_FROM_FILE_DESCRIPTOR = 74 │
│ CANNOT_WRITE_TO_FILE_DESCRIPTOR = 75 │
│ CANNOT_OPEN_FILE = 76 │
│ CANNOT_CLOSE_FILE = 77 │
│ UNKNOWN_TYPE_OF_QUERY = 78 │
│ INCORRECT_FILE_NAME = 79 │
│ INCORRECT_QUERY = 80 │
│ UNKNOWN_DATABASE = 81 │
│ DATABASE_ALREADY_EXISTS = 82 │
│ DIRECTORY_DOESNT_EXIST = 83 │
│ DIRECTORY_ALREADY_EXISTS = 84 │
│ FORMAT_IS_NOT_SUITABLE_FOR_INPUT = 85 │
│ RECEIVED_ERROR_FROM_REMOTE_IO_SERVER = 86 │
│ CANNOT_SEEK_THROUGH_FILE = 87 │
│ CANNOT_TRUNCATE_FILE = 88 │
│ UNKNOWN_COMPRESSION_METHOD = 89 │
│ EMPTY_LIST_OF_COLUMNS_PASSED = 90 │
│ SIZES_OF_MARKS_FILES_ARE_INCONSISTENT = 91 │
│ EMPTY_DATA_PASSED = 92 │
│ UNKNOWN_AGGREGATED_DATA_VARIANT = 93 │
│ CANNOT_MERGE_DIFFERENT_AGGREGATED_DATA_VARIANTS = 94 │
│ CANNOT_READ_FROM_SOCKET = 95 │
│ CANNOT_WRITE_TO_SOCKET = 96 │
│ CANNOT_READ_ALL_DATA_FROM_CHUNKED_INPUT = 97 │
│ CANNOT_WRITE_TO_EMPTY_BLOCK_OUTPUT_STREAM = 98 │
│ UNKNOWN_PACKET_FROM_CLIENT = 99 │
│ UNKNOWN_PACKET_FROM_SERVER = 100 │
│ UNEXPECTED_PACKET_FROM_CLIENT = 101 │
│ UNEXPECTED_PACKET_FROM_SERVER = 102 │
│ RECEIVED_DATA_FOR_WRONG_QUERY_ID = 103 │
│ TOO_SMALL_BUFFER_SIZE = 104 │
│ CANNOT_READ_HISTORY = 105 │
│ CANNOT_APPEND_HISTORY = 106 │
│ FILE_DOESNT_EXIST = 107 │
│ NO_DATA_TO_INSERT = 108 │
│ CANNOT_BLOCK_SIGNAL = 109 │
│ CANNOT_UNBLOCK_SIGNAL = 110 │
│ CANNOT_MANIPULATE_SIGSET = 111 │
│ CANNOT_WAIT_FOR_SIGNAL = 112 │
│ THERE_IS_NO_SESSION = 113 │
│ CANNOT_CLOCK_GETTIME = 114 │
│ UNKNOWN_SETTING = 115 │
│ THERE_IS_NO_DEFAULT_VALUE = 116 │
│ INCORRECT_DATA = 117 │
│ ENGINE_REQUIRED = 119 │
│ CANNOT_INSERT_VALUE_OF_DIFFERENT_SIZE_INTO_TUPLE = 120 │
│ UNSUPPORTED_JOIN_KEYS = 121 │
│ INCOMPATIBLE_COLUMNS = 122 │
│ UNKNOWN_TYPE_OF_AST_NODE = 123 │
│ INCORRECT_ELEMENT_OF_SET = 124 │
│ INCORRECT_RESULT_OF_SCALAR_SUBQUERY = 125 │
│ CANNOT_GET_RETURN_TYPE = 126 │
│ ILLEGAL_INDEX = 127 │
│ TOO_LARGE_ARRAY_SIZE = 128 │
│ FUNCTION_IS_SPECIAL = 129 │
│ CANNOT_READ_ARRAY_FROM_TEXT = 130 │
│ TOO_LARGE_STRING_SIZE = 131 │
│ AGGREGATE_FUNCTION_DOESNT_ALLOW_PARAMETERS = 133 │
│ PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS = 134 │
│ ZERO_ARRAY_OR_TUPLE_INDEX = 135 │
│ UNKNOWN_ELEMENT_IN_CONFIG = 137 │
│ EXCESSIVE_ELEMENT_IN_CONFIG = 138 │
│ NO_ELEMENTS_IN_CONFIG = 139 │
│ ALL_REQUESTED_COLUMNS_ARE_MISSING = 140 │
│ SAMPLING_NOT_SUPPORTED = 141 │
│ NOT_FOUND_NODE = 142 │
│ FOUND_MORE_THAN_ONE_NODE = 143 │
│ FIRST_DATE_IS_BIGGER_THAN_LAST_DATE = 144 │
│ UNKNOWN_OVERFLOW_MODE = 145 │
│ QUERY_SECTION_DOESNT_MAKE_SENSE = 146 │
│ NOT_FOUND_FUNCTION_ELEMENT_FOR_AGGREGATE = 147 │
│ NOT_FOUND_RELATION_ELEMENT_FOR_CONDITION = 148 │
│ NOT_FOUND_RHS_ELEMENT_FOR_CONDITION = 149 │
│ EMPTY_LIST_OF_ATTRIBUTES_PASSED = 150 │
│ INDEX_OF_COLUMN_IN_SORT_CLAUSE_IS_OUT_OF_RANGE = 151 │
│ UNKNOWN_DIRECTION_OF_SORTING = 152 │
│ ILLEGAL_DIVISION = 153 │
│ AGGREGATE_FUNCTION_NOT_APPLICABLE = 154 │
│ UNKNOWN_RELATION = 155 │
│ DICTIONARIES_WAS_NOT_LOADED = 156 │
│ ILLEGAL_OVERFLOW_MODE = 157 │
│ TOO_MANY_ROWS = 158 │
│ TIMEOUT_EXCEEDED = 159 │
│ TOO_SLOW = 160 │
│ TOO_MANY_COLUMNS = 161 │
│ TOO_DEEP_SUBQUERIES = 162 │
│ TOO_DEEP_PIPELINE = 163 │
│ READONLY = 164 │
│ TOO_MANY_TEMPORARY_COLUMNS = 165 │
│ TOO_MANY_TEMPORARY_NON_CONST_COLUMNS = 166 │
│ TOO_DEEP_AST = 167 │
│ TOO_BIG_AST = 168 │
│ BAD_TYPE_OF_FIELD = 169 │
│ BAD_GET = 170 │
│ CANNOT_CREATE_DIRECTORY = 172 │
│ CANNOT_ALLOCATE_MEMORY = 173 │
│ CYCLIC_ALIASES = 174 │
│ CHUNK_NOT_FOUND = 176 │
│ DUPLICATE_CHUNK_NAME = 177 │
│ MULTIPLE_ALIASES_FOR_EXPRESSION = 178 │
│ MULTIPLE_EXPRESSIONS_FOR_ALIAS = 179 │
│ THERE_IS_NO_PROFILE = 180 │
│ ILLEGAL_FINAL = 181 │
│ ILLEGAL_PREWHERE = 182 │
│ UNEXPECTED_EXPRESSION = 183 │
│ ILLEGAL_AGGREGATION = 184 │
│ UNSUPPORTED_MYISAM_BLOCK_TYPE = 185 │
│ UNSUPPORTED_COLLATION_LOCALE = 186 │
│ COLLATION_COMPARISON_FAILED = 187 │
│ UNKNOWN_ACTION = 188 │
│ TABLE_MUST_NOT_BE_CREATED_MANUALLY = 189 │
│ SIZES_OF_ARRAYS_DONT_MATCH = 190 │
│ SET_SIZE_LIMIT_EXCEEDED = 191 │
│ UNKNOWN_USER = 192 │
│ WRONG_PASSWORD = 193 │
│ REQUIRED_PASSWORD = 194 │
│ IP_ADDRESS_NOT_ALLOWED = 195 │
│ UNKNOWN_ADDRESS_PATTERN_TYPE = 196 │
│ SERVER_REVISION_IS_TOO_OLD = 197 │
│ DNS_ERROR = 198 │
│ UNKNOWN_QUOTA = 199 │
│ QUOTA_DOESNT_ALLOW_KEYS = 200 │
│ QUOTA_EXCEEDED = 201 │
│ TOO_MANY_SIMULTANEOUS_QUERIES = 202 │
│ NO_FREE_CONNECTION = 203 │
│ CANNOT_FSYNC = 204 │
│ NESTED_TYPE_TOO_DEEP = 205 │
│ ALIAS_REQUIRED = 206 │
│ AMBIGUOUS_IDENTIFIER = 207 │
│ EMPTY_NESTED_TABLE = 208 │
│ SOCKET_TIMEOUT = 209 │
│ NETWORK_ERROR = 210 │
│ EMPTY_QUERY = 211 │
│ UNKNOWN_LOAD_BALANCING = 212 │
│ UNKNOWN_TOTALS_MODE = 213 │
│ CANNOT_STATVFS = 214 │
│ NOT_AN_AGGREGATE = 215 │
│ QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING = 216 │
│ CLIENT_HAS_CONNECTED_TO_WRONG_PORT = 217 │
│ TABLE_IS_DROPPED = 218 │
│ DATABASE_NOT_EMPTY = 219 │
│ DUPLICATE_INTERSERVER_IO_ENDPOINT = 220 │
│ NO_SUCH_INTERSERVER_IO_ENDPOINT = 221 │
│ ADDING_REPLICA_TO_NON_EMPTY_TABLE = 222 │
│ UNEXPECTED_AST_STRUCTURE = 223 │
│ REPLICA_IS_ALREADY_ACTIVE = 224 │
│ NO_ZOOKEEPER = 225 │
│ NO_FILE_IN_DATA_PART = 226 │
│ UNEXPECTED_FILE_IN_DATA_PART = 227 │
│ BAD_SIZE_OF_FILE_IN_DATA_PART = 228 │
│ QUERY_IS_TOO_LARGE = 229 │
│ NOT_FOUND_EXPECTED_DATA_PART = 230 │
│ TOO_MANY_UNEXPECTED_DATA_PARTS = 231 │
│ NO_SUCH_DATA_PART = 232 │
│ BAD_DATA_PART_NAME = 233 │
│ NO_REPLICA_HAS_PART = 234 │
│ DUPLICATE_DATA_PART = 235 │
│ ABORTED = 236 │
│ NO_REPLICA_NAME_GIVEN = 237 │
│ FORMAT_VERSION_TOO_OLD = 238 │
│ CANNOT_MUNMAP = 239 │
│ CANNOT_MREMAP = 240 │
│ MEMORY_LIMIT_EXCEEDED = 241 │
│ TABLE_IS_READ_ONLY = 242 │
│ NOT_ENOUGH_SPACE = 243 │
│ UNEXPECTED_ZOOKEEPER_ERROR = 244 │
│ CORRUPTED_DATA = 246 │
│ INCORRECT_MARK = 247 │
│ INVALID_PARTITION_VALUE = 248 │
│ NOT_ENOUGH_BLOCK_NUMBERS = 250 │
│ NO_SUCH_REPLICA = 251 │
│ TOO_MANY_PARTS = 252 │
│ REPLICA_ALREADY_EXISTS = 253 │
│ NO_ACTIVE_REPLICAS = 254 │
│ TOO_MANY_RETRIES_TO_FETCH_PARTS = 255 │
│ PARTITION_ALREADY_EXISTS = 256 │
│ PARTITION_DOESNT_EXIST = 257 │
│ UNION_ALL_RESULT_STRUCTURES_MISMATCH = 258 │
│ CLIENT_OUTPUT_FORMAT_SPECIFIED = 260 │
│ UNKNOWN_BLOCK_INFO_FIELD = 261 │
│ BAD_COLLATION = 262 │
│ CANNOT_COMPILE_CODE = 263 │
│ INCOMPATIBLE_TYPE_OF_JOIN = 264 │
│ NO_AVAILABLE_REPLICA = 265 │
│ MISMATCH_REPLICAS_DATA_SOURCES = 266 │
│ STORAGE_DOESNT_SUPPORT_PARALLEL_REPLICAS = 267 │
│ CPUID_ERROR = 268 │
│ INFINITE_LOOP = 269 │
│ CANNOT_COMPRESS = 270 │
│ CANNOT_DECOMPRESS = 271 │
│ CANNOT_IO_SUBMIT = 272 │
│ CANNOT_IO_GETEVENTS = 273 │
│ AIO_READ_ERROR = 274 │
│ AIO_WRITE_ERROR = 275 │
│ INDEX_NOT_USED = 277 │
│ ALL_CONNECTION_TRIES_FAILED = 279 │
│ NO_AVAILABLE_DATA = 280 │
│ DICTIONARY_IS_EMPTY = 281 │
│ INCORRECT_INDEX = 282 │
│ UNKNOWN_DISTRIBUTED_PRODUCT_MODE = 283 │
│ WRONG_GLOBAL_SUBQUERY = 284 │
│ TOO_FEW_LIVE_REPLICAS = 285 │
│ UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE = 286 │
│ UNKNOWN_FORMAT_VERSION = 287 │
│ DISTRIBUTED_IN_JOIN_SUBQUERY_DENIED = 288 │
│ REPLICA_IS_NOT_IN_QUORUM = 289 │
│ LIMIT_EXCEEDED = 290 │
│ DATABASE_ACCESS_DENIED = 291 │
│ MONGODB_CANNOT_AUTHENTICATE = 293 │
│ INVALID_BLOCK_EXTRA_INFO = 294 │
│ RECEIVED_EMPTY_DATA = 295 │
│ NO_REMOTE_SHARD_FOUND = 296 │
│ SHARD_HAS_NO_CONNECTIONS = 297 │
│ CANNOT_PIPE = 298 │
│ CANNOT_FORK = 299 │
│ CANNOT_DLSYM = 300 │
│ CANNOT_CREATE_CHILD_PROCESS = 301 │
│ CHILD_WAS_NOT_EXITED_NORMALLY = 302 │
│ CANNOT_SELECT = 303 │
│ CANNOT_WAITPID = 304 │
│ TABLE_WAS_NOT_DROPPED = 305 │
│ TOO_DEEP_RECURSION = 306 │
│ TOO_MANY_BYTES = 307 │
│ UNEXPECTED_NODE_IN_ZOOKEEPER = 308 │
│ FUNCTION_CANNOT_HAVE_PARAMETERS = 309 │
│ INVALID_SHARD_WEIGHT = 317 │
│ INVALID_CONFIG_PARAMETER = 318 │
│ UNKNOWN_STATUS_OF_INSERT = 319 │
│ VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE = 321 │
│ BARRIER_TIMEOUT = 335 │
│ UNKNOWN_DATABASE_ENGINE = 336 │
│ DDL_GUARD_IS_ACTIVE = 337 │
│ UNFINISHED = 341 │
│ METADATA_MISMATCH = 342 │
│ SUPPORT_IS_DISABLED = 344 │
│ TABLE_DIFFERS_TOO_MUCH = 345 │
│ CANNOT_CONVERT_CHARSET = 346 │
│ CANNOT_LOAD_CONFIG = 347 │
│ CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN = 349 │
│ INCOMPATIBLE_SOURCE_TABLES = 350 │
│ AMBIGUOUS_TABLE_NAME = 351 │
│ AMBIGUOUS_COLUMN_NAME = 352 │
│ INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE = 353 │
│ ZLIB_INFLATE_FAILED = 354 │
│ ZLIB_DEFLATE_FAILED = 355 │
│ BAD_LAMBDA = 356 │
│ RESERVED_IDENTIFIER_NAME = 357 │
│ INTO_OUTFILE_NOT_ALLOWED = 358 │
│ TABLE_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT = 359 │
│ CANNOT_CREATE_CHARSET_CONVERTER = 360 │
│ SEEK_POSITION_OUT_OF_BOUND = 361 │
│ CURRENT_WRITE_BUFFER_IS_EXHAUSTED = 362 │
│ CANNOT_CREATE_IO_BUFFER = 363 │
│ RECEIVED_ERROR_TOO_MANY_REQUESTS = 364 │
│ SIZES_OF_NESTED_COLUMNS_ARE_INCONSISTENT = 366 │
│ TOO_MANY_FETCHES = 367 │
│ ALL_REPLICAS_ARE_STALE = 369 │
│ DATA_TYPE_CANNOT_BE_USED_IN_TABLES = 370 │
│ INCONSISTENT_CLUSTER_DEFINITION = 371 │
│ SESSION_NOT_FOUND = 372 │
│ SESSION_IS_LOCKED = 373 │
│ INVALID_SESSION_TIMEOUT = 374 │
│ CANNOT_DLOPEN = 375 │
│ CANNOT_PARSE_UUID = 376 │
│ ILLEGAL_SYNTAX_FOR_DATA_TYPE = 377 │
│ DATA_TYPE_CANNOT_HAVE_ARGUMENTS = 378 │
│ UNKNOWN_STATUS_OF_DISTRIBUTED_DDL_TASK = 379 │
│ CANNOT_KILL = 380 │
│ HTTP_LENGTH_REQUIRED = 381 │
│ CANNOT_LOAD_CATBOOST_MODEL = 382 │
│ CANNOT_APPLY_CATBOOST_MODEL = 383 │
│ PART_IS_TEMPORARILY_LOCKED = 384 │
│ MULTIPLE_STREAMS_REQUIRED = 385 │
│ NO_COMMON_TYPE = 386 │
│ DICTIONARY_ALREADY_EXISTS = 387 │
│ CANNOT_ASSIGN_OPTIMIZE = 388 │
│ INSERT_WAS_DEDUPLICATED = 389 │
│ CANNOT_GET_CREATE_TABLE_QUERY = 390 │
│ EXTERNAL_LIBRARY_ERROR = 391 │
│ QUERY_IS_PROHIBITED = 392 │
│ THERE_IS_NO_QUERY = 393 │
│ QUERY_WAS_CANCELLED = 394 │
│ FUNCTION_THROW_IF_VALUE_IS_NON_ZERO = 395 │
│ TOO_MANY_ROWS_OR_BYTES = 396 │
│ QUERY_IS_NOT_SUPPORTED_IN_MATERIALIZED_VIEW = 397 │
│ UNKNOWN_MUTATION_COMMAND = 398 │
│ FORMAT_IS_NOT_SUITABLE_FOR_OUTPUT = 399 │
│ CANNOT_STAT = 400 │
│ FEATURE_IS_NOT_ENABLED_AT_BUILD_TIME = 401 │
│ CANNOT_IOSETUP = 402 │
│ INVALID_JOIN_ON_EXPRESSION = 403 │
│ BAD_ODBC_CONNECTION_STRING = 404 │
│ PARTITION_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT = 405 │
│ TOP_AND_LIMIT_TOGETHER = 406 │
│ DECIMAL_OVERFLOW = 407 │
│ BAD_REQUEST_PARAMETER = 408 │
│ EXTERNAL_EXECUTABLE_NOT_FOUND = 409 │
│ EXTERNAL_SERVER_IS_NOT_RESPONDING = 410 │
│ PTHREAD_ERROR = 411 │
│ NETLINK_ERROR = 412 │
│ CANNOT_SET_SIGNAL_HANDLER = 413 │
│ ALL_REPLICAS_LOST = 415 │
│ REPLICA_STATUS_CHANGED = 416 │
│ EXPECTED_ALL_OR_ANY = 417 │
│ UNKNOWN_JOIN = 418 │
│ MULTIPLE_ASSIGNMENTS_TO_COLUMN = 419 │
│ CANNOT_UPDATE_COLUMN = 420 │
│ CANNOT_ADD_DIFFERENT_AGGREGATE_STATES = 421 │
│ UNSUPPORTED_URI_SCHEME = 422 │
│ CANNOT_GETTIMEOFDAY = 423 │
│ CANNOT_LINK = 424 │
│ SYSTEM_ERROR = 425 │
│ CANNOT_COMPILE_REGEXP = 427 │
│ UNKNOWN_LOG_LEVEL = 428 │
│ FAILED_TO_GETPWUID = 429 │
│ MISMATCHING_USERS_FOR_PROCESS_AND_DATA = 430 │
│ ILLEGAL_SYNTAX_FOR_CODEC_TYPE = 431 │
│ UNKNOWN_CODEC = 432 │
│ ILLEGAL_CODEC_PARAMETER = 433 │
│ CANNOT_PARSE_PROTOBUF_SCHEMA = 434 │
│ NO_COLUMN_SERIALIZED_TO_REQUIRED_PROTOBUF_FIELD = 435 │
│ PROTOBUF_BAD_CAST = 436 │
│ PROTOBUF_FIELD_NOT_REPEATED = 437 │
│ DATA_TYPE_CANNOT_BE_PROMOTED = 438 │
│ CANNOT_SCHEDULE_TASK = 439 │
│ INVALID_LIMIT_EXPRESSION = 440 │
│ CANNOT_PARSE_DOMAIN_VALUE_FROM_STRING = 441 │
│ BAD_DATABASE_FOR_TEMPORARY_TABLE = 442 │
│ NO_COLUMNS_SERIALIZED_TO_PROTOBUF_FIELDS = 443 │
│ UNKNOWN_PROTOBUF_FORMAT = 444 │
│ CANNOT_MPROTECT = 445 │
│ FUNCTION_NOT_ALLOWED = 446 │
│ HYPERSCAN_CANNOT_SCAN_TEXT = 447 │
│ BROTLI_READ_FAILED = 448 │
│ BROTLI_WRITE_FAILED = 449 │
│ BAD_TTL_EXPRESSION = 450 │
│ BAD_TTL_FILE = 451 │
│ SETTING_CONSTRAINT_VIOLATION = 452 │
│ MYSQL_CLIENT_INSUFFICIENT_CAPABILITIES = 453 │
│ OPENSSL_ERROR = 454 │
│ SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY = 455 │
│ UNKNOWN_QUERY_PARAMETER = 456 │
│ BAD_QUERY_PARAMETER = 457 │
│ CANNOT_UNLINK = 458 │
│ CANNOT_SET_THREAD_PRIORITY = 459 │
│ CANNOT_CREATE_TIMER = 460 │
│ CANNOT_SET_TIMER_PERIOD = 461 │
│ CANNOT_DELETE_TIMER = 462 │
│ CANNOT_FCNTL = 463 │
│ CANNOT_PARSE_ELF = 464 │
│ CANNOT_PARSE_DWARF = 465 │
│ INSECURE_PATH = 466 │
│ CANNOT_PARSE_BOOL = 467 │
│ CANNOT_PTHREAD_ATTR = 468 │
│ VIOLATED_CONSTRAINT = 469 │
│ QUERY_IS_NOT_SUPPORTED_IN_LIVE_VIEW = 470 │
│ INVALID_SETTING_VALUE = 471 │
│ READONLY_SETTING = 472 │
│ DEADLOCK_AVOIDED = 473 │
│ INVALID_TEMPLATE_FORMAT = 474 │
│ INVALID_WITH_FILL_EXPRESSION = 475 │
│ WITH_TIES_WITHOUT_ORDER_BY = 476 │
│ INVALID_USAGE_OF_INPUT = 477 │
│ UNKNOWN_POLICY = 478 │
│ UNKNOWN_DISK = 479 │
│ UNKNOWN_PROTOCOL = 480 │
│ PATH_ACCESS_DENIED = 481 │
│ DICTIONARY_ACCESS_DENIED = 482 │
│ TOO_MANY_REDIRECTS = 483 │
│ INTERNAL_REDIS_ERROR = 484 │
│ SCALAR_ALREADY_EXISTS = 485 │
│ CANNOT_GET_CREATE_DICTIONARY_QUERY = 487 │
│ UNKNOWN_DICTIONARY = 488 │
│ INCORRECT_DICTIONARY_DEFINITION = 489 │
│ CANNOT_FORMAT_DATETIME = 490 │
│ UNACCEPTABLE_URL = 491 │
│ ACCESS_ENTITY_NOT_FOUND = 492 │
│ ACCESS_ENTITY_ALREADY_EXISTS = 493 │
│ ACCESS_ENTITY_FOUND_DUPLICATES = 494 │
│ ACCESS_STORAGE_READONLY = 495 │
│ QUOTA_REQUIRES_CLIENT_KEY = 496 │
│ ACCESS_DENIED = 497 │
│ LIMIT_BY_WITH_TIES_IS_NOT_SUPPORTED = 498 │
│ S3_ERROR = 499 │
│ AZURE_BLOB_STORAGE_ERROR = 500 │
│ CANNOT_CREATE_DATABASE = 501 │
│ CANNOT_SIGQUEUE = 502 │
│ AGGREGATE_FUNCTION_THROW = 503 │
│ FILE_ALREADY_EXISTS = 504 │
│ CANNOT_DELETE_DIRECTORY = 505 │
│ UNEXPECTED_ERROR_CODE = 506 │
│ UNABLE_TO_SKIP_UNUSED_SHARDS = 507 │
│ UNKNOWN_ACCESS_TYPE = 508 │
│ INVALID_GRANT = 509 │
│ CACHE_DICTIONARY_UPDATE_FAIL = 510 │
│ UNKNOWN_ROLE = 511 │
│ SET_NON_GRANTED_ROLE = 512 │
│ UNKNOWN_PART_TYPE = 513 │
│ ACCESS_STORAGE_FOR_INSERTION_NOT_FOUND = 514 │
│ INCORRECT_ACCESS_ENTITY_DEFINITION = 515 │
│ AUTHENTICATION_FAILED = 516 │
│ CANNOT_ASSIGN_ALTER = 517 │
│ CANNOT_COMMIT_OFFSET = 518 │
│ NO_REMOTE_SHARD_AVAILABLE = 519 │
│ CANNOT_DETACH_DICTIONARY_AS_TABLE = 520 │
│ ATOMIC_RENAME_FAIL = 521 │
│ UNKNOWN_ROW_POLICY = 523 │
│ ALTER_OF_COLUMN_IS_FORBIDDEN = 524 │
│ INCORRECT_DISK_INDEX = 525 │
│ NO_SUITABLE_FUNCTION_IMPLEMENTATION = 527 │
│ CASSANDRA_INTERNAL_ERROR = 528 │
│ NOT_A_LEADER = 529 │
│ CANNOT_CONNECT_RABBITMQ = 530 │
│ CANNOT_FSTAT = 531 │
│ LDAP_ERROR = 532 │
│ INCONSISTENT_RESERVATIONS = 533 │
│ NO_RESERVATIONS_PROVIDED = 534 │
│ UNKNOWN_RAID_TYPE = 535 │
│ CANNOT_RESTORE_FROM_FIELD_DUMP = 536 │
│ ILLEGAL_MYSQL_VARIABLE = 537 │
│ MYSQL_SYNTAX_ERROR = 538 │
│ CANNOT_BIND_RABBITMQ_EXCHANGE = 539 │
│ CANNOT_DECLARE_RABBITMQ_EXCHANGE = 540 │
│ CANNOT_CREATE_RABBITMQ_QUEUE_BINDING = 541 │
│ CANNOT_REMOVE_RABBITMQ_EXCHANGE = 542 │
│ UNKNOWN_MYSQL_DATATYPES_SUPPORT_LEVEL = 543 │
│ ROW_AND_ROWS_TOGETHER = 544 │
│ FIRST_AND_NEXT_TOGETHER = 545 │
│ NO_ROW_DELIMITER = 546 │
│ INVALID_RAID_TYPE = 547 │
│ UNKNOWN_VOLUME = 548 │
│ DATA_TYPE_CANNOT_BE_USED_IN_KEY = 549 │
│ CONDITIONAL_TREE_PARENT_NOT_FOUND = 550 │
│ ILLEGAL_PROJECTION_MANIPULATOR = 551 │
│ UNRECOGNIZED_ARGUMENTS = 552 │
│ LZMA_STREAM_ENCODER_FAILED = 553 │
│ LZMA_STREAM_DECODER_FAILED = 554 │
│ ROCKSDB_ERROR = 555 │
│ SYNC_MYSQL_USER_ACCESS_ERROR = 556 │
│ UNKNOWN_UNION = 557 │
│ EXPECTED_ALL_OR_DISTINCT = 558 │
│ INVALID_GRPC_QUERY_INFO = 559 │
│ ZSTD_ENCODER_FAILED = 560 │
│ ZSTD_DECODER_FAILED = 561 │
│ TLD_LIST_NOT_FOUND = 562 │
│ CANNOT_READ_MAP_FROM_TEXT = 563 │
│ INTERSERVER_SCHEME_DOESNT_MATCH = 564 │
│ TOO_MANY_PARTITIONS = 565 │
│ CANNOT_RMDIR = 566 │
│ DUPLICATED_PART_UUIDS = 567 │
│ RAFT_ERROR = 568 │
│ MULTIPLE_COLUMNS_SERIALIZED_TO_SAME_PROTOBUF_FIELD = 569 │
│ DATA_TYPE_INCOMPATIBLE_WITH_PROTOBUF_FIELD = 570 │
│ DATABASE_REPLICATION_FAILED = 571 │
│ TOO_MANY_QUERY_PLAN_OPTIMIZATIONS = 572 │
│ EPOLL_ERROR = 573 │
│ DISTRIBUTED_TOO_MANY_PENDING_BYTES = 574 │
│ UNKNOWN_SNAPSHOT = 575 │
│ KERBEROS_ERROR = 576 │
│ INVALID_SHARD_ID = 577 │
│ INVALID_FORMAT_INSERT_QUERY_WITH_DATA = 578 │
│ INCORRECT_PART_TYPE = 579 │
│ CANNOT_SET_ROUNDING_MODE = 580 │
│ TOO_LARGE_DISTRIBUTED_DEPTH = 581 │
│ NO_SUCH_PROJECTION_IN_TABLE = 582 │
│ ILLEGAL_PROJECTION = 583 │
│ PROJECTION_NOT_USED = 584 │
│ CANNOT_PARSE_YAML = 585 │
│ CANNOT_CREATE_FILE = 586 │
│ CONCURRENT_ACCESS_NOT_SUPPORTED = 587 │
│ DISTRIBUTED_BROKEN_BATCH_INFO = 588 │
│ DISTRIBUTED_BROKEN_BATCH_FILES = 589 │
│ CANNOT_SYSCONF = 590 │
│ SQLITE_ENGINE_ERROR = 591 │
│ DATA_ENCRYPTION_ERROR = 592 │
│ ZERO_COPY_REPLICATION_ERROR = 593 │
│ BZIP2_STREAM_DECODER_FAILED = 594 │
│ BZIP2_STREAM_ENCODER_FAILED = 595 │
│ INTERSECT_OR_EXCEPT_RESULT_STRUCTURES_MISMATCH = 596 │
│ NO_SUCH_ERROR_CODE = 597 │
│ BACKUP_ALREADY_EXISTS = 598 │
│ BACKUP_NOT_FOUND = 599 │
│ BACKUP_VERSION_NOT_SUPPORTED = 600 │
│ BACKUP_DAMAGED = 601 │
│ NO_BASE_BACKUP = 602 │
│ WRONG_BASE_BACKUP = 603 │
│ BACKUP_ENTRY_ALREADY_EXISTS = 604 │
│ BACKUP_ENTRY_NOT_FOUND = 605 │
│ BACKUP_IS_EMPTY = 606 │
│ CANNOT_RESTORE_DATABASE = 607 │
│ CANNOT_RESTORE_TABLE = 608 │
│ FUNCTION_ALREADY_EXISTS = 609 │
│ CANNOT_DROP_FUNCTION = 610 │
│ CANNOT_CREATE_RECURSIVE_FUNCTION = 611 │
│ OBJECT_ALREADY_STORED_ON_DISK = 612 │
│ OBJECT_WAS_NOT_STORED_ON_DISK = 613 │
│ POSTGRESQL_CONNECTION_FAILURE = 614 │
│ CANNOT_ADVISE = 615 │
│ UNKNOWN_READ_METHOD = 616 │
│ LZ4_ENCODER_FAILED = 617 │
│ LZ4_DECODER_FAILED = 618 │
│ POSTGRESQL_REPLICATION_INTERNAL_ERROR = 619 │
│ QUERY_NOT_ALLOWED = 620 │
│ CANNOT_NORMALIZE_STRING = 621 │
│ CANNOT_PARSE_CAPN_PROTO_SCHEMA = 622 │
│ CAPN_PROTO_BAD_CAST = 623 │
│ BAD_FILE_TYPE = 624 │
│ IO_SETUP_ERROR = 625 │
│ CANNOT_SKIP_UNKNOWN_FIELD = 626 │
│ BACKUP_ENGINE_NOT_FOUND = 627 │
│ OFFSET_FETCH_WITHOUT_ORDER_BY = 628 │
│ HTTP_RANGE_NOT_SATISFIABLE = 629 │
│ HAVE_DEPENDENT_OBJECTS = 630 │
│ UNKNOWN_FILE_SIZE = 631 │
│ UNEXPECTED_DATA_AFTER_PARSED_VALUE = 632 │
│ QUERY_IS_NOT_SUPPORTED_IN_WINDOW_VIEW = 633 │
│ MONGODB_ERROR = 634 │
│ CANNOT_POLL = 635 │
│ CANNOT_EXTRACT_TABLE_STRUCTURE = 636 │
│ INVALID_TABLE_OVERRIDE = 637 │
│ SNAPPY_UNCOMPRESS_FAILED = 638 │
│ SNAPPY_COMPRESS_FAILED = 639 │
│ NO_HIVEMETASTORE = 640 │
│ CANNOT_APPEND_TO_FILE = 641 │
│ CANNOT_PACK_ARCHIVE = 642 │
│ CANNOT_UNPACK_ARCHIVE = 643 │
│ REMOTE_FS_OBJECT_CACHE_ERROR = 644 │
│ NUMBER_OF_DIMENSIONS_MISMATCHED = 645 │
│ CANNOT_BACKUP_DATABASE = 646 │
│ CANNOT_BACKUP_TABLE = 647 │
│ WRONG_DDL_RENAMING_SETTINGS = 648 │
│ INVALID_TRANSACTION = 649 │
│ SERIALIZATION_ERROR = 650 │
│ CAPN_PROTO_BAD_TYPE = 651 │
│ ONLY_NULLS_WHILE_READING_SCHEMA = 652 │
│ CANNOT_PARSE_BACKUP_SETTINGS = 653 │
│ WRONG_BACKUP_SETTINGS = 654 │
│ FAILED_TO_SYNC_BACKUP_OR_RESTORE = 655 │
│ MEILISEARCH_EXCEPTION = 656 │
│ UNSUPPORTED_MEILISEARCH_TYPE = 657 │
│ MEILISEARCH_MISSING_SOME_COLUMNS = 658 │
│ UNKNOWN_STATUS_OF_TRANSACTION = 659 │
│ HDFS_ERROR = 660 │
│ CANNOT_SEND_SIGNAL = 661 │
│ FS_METADATA_ERROR = 662 │
│ INCONSISTENT_METADATA_FOR_BACKUP = 663 │
│ ACCESS_STORAGE_DOESNT_ALLOW_BACKUP = 664 │
│ CANNOT_CONNECT_NATS = 665 │
│ CANNOT_USE_CACHE = 666 │
│ NOT_INITIALIZED = 667 │
│ INVALID_STATE = 668 │
│ NAMED_COLLECTION_DOESNT_EXIST = 669 │
│ NAMED_COLLECTION_ALREADY_EXISTS = 670 │
│ NAMED_COLLECTION_IS_IMMUTABLE = 671 │
│ INVALID_SCHEDULER_NODE = 672 │
│ RESOURCE_ACCESS_DENIED = 673 │
│ RESOURCE_NOT_FOUND = 674 │
│ CANNOT_PARSE_IPV4 = 675 │
│ CANNOT_PARSE_IPV6 = 676 │
│ THREAD_WAS_CANCELED = 677 │
│ IO_URING_INIT_FAILED = 678 │
│ IO_URING_SUBMIT_ERROR = 679 │
│ MIXED_ACCESS_PARAMETER_TYPES = 690 │
│ UNKNOWN_ELEMENT_OF_ENUM = 691 │
│ KEEPER_EXCEPTION = 999 │
│ POCO_EXCEPTION = 1000 │
│ STD_EXCEPTION = 1001 │
│ UNKNOWN_EXCEPTION = 1002 │
└────────────────────────────────────────────────────────────────┘
http请求测试
下面通过CURL进行测试。没有对应表:
curl --user default:passw02d -i 'http://localhost:8123?query=select+*+from+wtf'
HTTP/1.1 404 Not Found
Date: Fri, 16 Jun 2023 09:13:32 GMT
Connection: Keep-Alive
Content-Type: text/plain; charset=UTF-8
X-ClickHouse-Server-Display-Name: localhost
Transfer-Encoding: chunked
X-ClickHouse-Query-Id: a6eafbf4-3d0d-44a3-a762-df427759efb3
X-ClickHouse-Timezone: Asia/Shanghai
X-ClickHouse-Exception-Code: 60
Keep-Alive: timeout=3
X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0","result_rows":"0","result_bytes":"0"}
可以看到 X-ClickHouse-Exception-Code: 60
,对照上面的结果,60 表示查询不到对应表。
如果不提供用户和密码,结果如下:
curl -i 'http://localhost:8123?query=select+*+from+wtf'
HTTP/1.1 403 Forbidden
Date: Fri, 16 Jun 2023 08:57:42 GMT
Connection: Keep-Alive
Content-Type: text/plain; charset=UTF-8
X-ClickHouse-Server-Display-Name: localhost
Transfer-Encoding: chunked
X-ClickHouse-Exception-Code: 516
Code: 516. DB::Exception: default: Authentication failed: password is incorrect, or there is no user with such name.
If you have installed ClickHouse and forgot password you can reset it in the configuration file.
The password for default user is typically located at /etc/clickhouse-server/users.d/default-password.xml
and deleting this file will reset the password.
See also /etc/clickhouse-server/users.xml on the server where ClickHouse is installed.
. (AUTHENTICATION_FAILED) (version 23.3.2.37 (official build))
这回返回错误为:X-ClickHouse-Exception-Code: 516
, 对照上节错误代码表示未授权。
设置ClickHouse查询日志TTL
ClickHouse 可以在系统表 system.query_log
中显示查询日志,方便调试运行的查询。随着时间推移,特别在繁忙的集群环境,查询日志增长很快会占用大量磁盘空间。
对于这种情况可以会考虑使用MODIFY TTL对system.query_log
表设置TTL,但这种方式服务器重启后TTL 设置会丢失。为了持久应用TTL之system.query_log
表,必须修改 conf.xml 文件。
举例:
<query_views_log>
<database>system</database>
<table>query_views_log</table>
<partition_by>toStartOfWeek(event_date)</partition_by>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
<ttl>toStartOfWeek(event_date) + INTERVAL 3 MONTH</ttl>
</query_views_log>
<query_log>
<database>system</database>
<table>query_log</table>
<partition_by>toStartOfWeek(event_date)</partition_by>
<ttl>toStartOfWeek(event_date) + INTERVAL 3 MONTH</ttl>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</query_log>
修改完成后,必须重启 ClickHouse 服务器使得配置生效。
总结
本文介绍了ClickHouse Http查询错误编码,以及如何给存储查询日志的系统表设置TTL.