From 1182e0dc16cf05c976b633d81cfc58e8bc936dcd Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 20 Mar 2018 15:26:13 +0000 Subject: [PATCH] [Minor] Improve error reporting when uploading data to CH --- src/plugins/lua/clickhouse.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index 2735f2ade..e77adb221 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -116,7 +116,7 @@ CREATE TABLE IF NOT EXISTS ${urls_table} ( CREATE TABLE IF NOT EXISTS ${emails_table} ( Date Date, Digest FixedString(32), - `Emails` Array(String), + Emails Array(String) ) ENGINE = MergeTree(Date, Digest, 8192) ]], @@ -704,17 +704,18 @@ if opts then for _,up in ipairs(upstreams) do local ip_addr = up:get_addr():to_string(true) - local function http_cb(err_message, code, _, _) - if code ~= 200 or err_message then - rspamd_logger.errx(rspamd_config, "cannot create table in clickhouse server %s: %s", - ip_addr, err_message) - up:fail() - else - up:ok() + local function send_req(elt, sql) + local function http_cb(err_message, code, data, _) + if code ~= 200 or err_message then + if not err_message then err_message = data end + rspamd_logger.errx(rspamd_config, "cannot create table %s in clickhouse server %s: %s", + elt, ip_addr, err_message) + up:fail() + else + up:ok() + end end - end - local function send_req(elt, sql) if not rspamd_http.request({ ev_base = ev_base, config = cfg, -- 2.39.5