system.errors has one counter per error code, and a counter is incremented when the server raises an exception with that code. The table does not know whether the exception later failed a query or was caught and handled inside the server. A non-zero counter therefore does not mean that a query failed. To find queries that failed, use system.query_log.
Example: a skipped row
Theinput_format_allow_errors_num setting lets a query skip rows that cannot be parsed. The second row below has text where a number is expected:
system.errors counted it:
query_id column of system.errors holds the query that raised the last exception of each kind. Joining it with system.query_log shows that this query finished without an exception:
Example: format detection
Some features work by trying an operation and handling the failure. When you do not name the format of the data, ClickHouse detects the format by trying the candidates one after another. Each attempt that does not fit raises an exception inside the server:Where the errors come from
The counters are server-wide and cumulative since the server started. They include:- exceptions that the server raises and handles while a query succeeds, as in the examples above;
- exceptions of background operations, for example a mutation that fails and is retried, which happen outside of any query;
- failed queries of every user and application, including the ones that a client retried successfully;
- exceptions received from other servers during distributed queries, counted in separate rows with
remote = 1.
clickhouse-client it depends on the insert:
- Data that follows the query text (
INSERT ... FORMAT CSVwith the rows after it, orINSERT ... VALUES) is sent to the server as text when the insert is asynchronous (async_insert = 1, the default since ClickHouse 26.2) or when the client runs with--inline-insert-data. The server parses it and counts the parsing exceptions, and the client reports the error asReceived exception from server. - Data of a synchronous insert (
async_insert = 0), and data that the client reads from standard input or withFROM INFILE, is parsed by the client. These parsing errors are reported asError on processing queryand never reach the server.
Before ClickHouse 26.8, an ordinary
INSERT ... VALUES could increment parse error counters such as CANNOT_PARSE_INPUT_ASSERTION_FAILED: when the fast parser of the Values format could not read a value, the value was parsed again as an SQL expression, and the failed first attempt was counted although the insert succeeded. Starting with 26.8 these attempts are no longer counted.How to find real failures
Queries that failed are insystem.query_log with the type ExceptionBeforeStart or ExceptionWhileProcessing:
system.errors, and its history in system.error_log, as a hint that something happens on the server, and alert on a counter only if you know that the error code cannot be raised during normal operation. The reference page of system.errors gives the same advice.