]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Improve logging for REDIS_REPLY_ERROR
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 21 Apr 2021 11:35:04 +0000 (12:35 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 21 Apr 2021 11:35:22 +0000 (12:35 +0100)
src/libserver/fuzzy_backend/fuzzy_backend_redis.c
src/libstat/backends/redis_backend.c
src/libstat/learn_cache/redis_cache.c

index d1e3e75329383649bbcc30c0102d4f5900d62a27..f16040d8fe5821b65b1695d987f50237c54b0a36 100644 (file)
@@ -446,6 +446,10 @@ rspamd_fuzzy_redis_shingles_callback (redisAsyncContext *c, gpointer r,
                                }
                        }
                }
+               else if (reply->type == REDIS_REPLY_ERROR) {
+                       msg_err_redis_session ("fuzzy backend redis error: \"%s\"",
+                                       reply->str);
+               }
 
                if (session->callback.cb_check) {
                        session->callback.cb_check (&rep, session->cbdata);
@@ -572,6 +576,10 @@ rspamd_fuzzy_redis_check_callback (redisAsyncContext *c, gpointer r,
                                }
                        }
                }
+               else if (reply->type == REDIS_REPLY_ERROR) {
+                       msg_err_redis_session ("fuzzy backend redis error: \"%s\"",
+                                       reply->str);
+               }
 
                if (found_elts < 2) {
                        if (session->cmd->shingles_count > 0 && !session->shingles_checked) {
@@ -738,6 +746,10 @@ rspamd_fuzzy_redis_count_callback (redisAsyncContext *c, gpointer r,
                        }
                }
                else {
+                       if (reply->type == REDIS_REPLY_ERROR) {
+                               msg_err_redis_session ("fuzzy backend redis error: \"%s\"",
+                                               reply->str);
+                       }
                        if (session->callback.cb_count) {
                                session->callback.cb_count (0, session->cbdata);
                        }
@@ -872,6 +884,10 @@ rspamd_fuzzy_redis_version_callback (redisAsyncContext *c, gpointer r,
                        }
                }
                else {
+                       if (reply->type == REDIS_REPLY_ERROR) {
+                               msg_err_redis_session ("fuzzy backend redis error: \"%s\"",
+                                               reply->str);
+                       }
                        if (session->callback.cb_version) {
                                session->callback.cb_version (0, session->cbdata);
                        }
@@ -1373,6 +1389,10 @@ rspamd_fuzzy_redis_update_callback (redisAsyncContext *c, gpointer r,
                        }
                }
                else {
+                       if (reply->type == REDIS_REPLY_ERROR) {
+                               msg_err_redis_session ("fuzzy backend redis error: \"%s\"",
+                                               reply->str);
+                       }
                        if (session->callback.cb_update) {
                                session->callback.cb_update (FALSE, 0, 0, 0, 0, session->cbdata);
                        }
index 392f1704ef007b71c8cab7a7e0c995c6408c57be..4136ab092cf40933286e0f25654dd6407e26e5ce 100644 (file)
@@ -1212,8 +1212,14 @@ rspamd_redis_processed (redisAsyncContext *c, gpointer r, gpointer priv)
                                }
                        }
                        else {
-                               msg_err_task_check ("got invalid reply from redis: %s, array expected",
-                                               rspamd_redis_type_to_string (reply->type));
+                               if (reply->type == REDIS_REPLY_ERROR) {
+                                       msg_err_task_check ("cannot learn %s: redis error: \"%s\"",
+                                                       rt->stcf->symbol, reply->str);
+                               }
+                               else {
+                                       msg_err_task_check ("got invalid reply from redis: %s, array expected",
+                                                       rspamd_redis_type_to_string(reply->type));
+                               }
                        }
 
                        msg_debug_stat_redis ("received tokens for %s: %d processed, %d found",
@@ -1264,9 +1270,15 @@ rspamd_redis_connected (redisAsyncContext *c, gpointer r, gpointer priv)
                        }
                        else {
                                if (reply->type != REDIS_REPLY_NIL) {
-                                       msg_err_task ("bad learned type for %s: %s, nil expected",
-                                               rt->stcf->symbol,
-                                               rspamd_redis_type_to_string (reply->type));
+                                       if (reply->type == REDIS_REPLY_ERROR) {
+                                               msg_err_task ("cannot learn %s: redis error: \"%s\"",
+                                                               rt->stcf->symbol, reply->str);
+                                       }
+                                       else {
+                                               msg_err_task ("bad learned type for %s: %s, nil expected",
+                                                               rt->stcf->symbol,
+                                                               rspamd_redis_type_to_string(reply->type));
+                                       }
                                }
 
                                val = 0;
index 73a72a6141c5063056c5bb5185cc5692a4e4bca4..570f3f6a2d62490046176afad771bfd07f4e5068 100644 (file)
@@ -141,7 +141,11 @@ rspamd_stat_cache_redis_get (redisAsyncContext *c, gpointer r, gpointer priv)
                                rspamd_strtol (reply->str, reply->len, &val);
                        }
                        else {
-                               if (reply->type != REDIS_REPLY_NIL) {
+                               if (reply->type == REDIS_REPLY_ERROR) {
+                                       msg_err_task ("cannot learn %s: redis error: \"%s\"",
+                                                       rt->ctx->stcf->symbol, reply->str);
+                               }
+                               else if (reply->type != REDIS_REPLY_NIL) {
                                        msg_err_task ("bad learned type for %s: %d",
                                                        rt->ctx->stcf->symbol, reply->type);
                                }