Skip to content

Commit 211396c

Browse files
committed
Display warnings when request failed
These warnings help us to investigate the cause when something wrong happens.
1 parent 572dec0 commit 211396c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/cassandra/cluster/client.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ def execute_by_plan(promise,
566566
unless pool
567567
errors ||= {}
568568
errors[host] = NOT_CONNECTED
569+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{errors[host].class.name}: #{errors[host]})")
569570
return execute_by_plan(promise,
570571
keyspace,
571572
statement,
@@ -602,6 +603,7 @@ def execute_by_plan(promise,
602603
(e.is_a?(Errors::TimeoutError) && statement.idempotent?)
603604
errors ||= {}
604605
errors[host] = e
606+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
605607
execute_by_plan(promise,
606608
keyspace,
607609
statement,
@@ -635,6 +637,7 @@ def execute_by_plan(promise,
635637
rescue => e
636638
errors ||= {}
637639
errors[host] = e
640+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
638641
execute_by_plan(promise,
639642
keyspace,
640643
statement,
@@ -705,6 +708,7 @@ def prepare_and_send_request_by_plan(host,
705708
(e.is_a?(Errors::TimeoutError) && statement.idempotent?)
706709
errors ||= {}
707710
errors[host] = e
711+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
708712
execute_by_plan(promise,
709713
keyspace,
710714
statement,
@@ -749,6 +753,7 @@ def batch_by_plan(promise,
749753
unless pool
750754
errors ||= {}
751755
errors[host] = NOT_CONNECTED
756+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{errors[host].class.name}: #{errors[host]})")
752757
return batch_by_plan(promise,
753758
keyspace,
754759
statement,
@@ -785,6 +790,7 @@ def batch_by_plan(promise,
785790
(e.is_a?(Errors::TimeoutError) && statement.idempotent?)
786791
errors ||= {}
787792
errors[host] = e
793+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
788794
batch_by_plan(promise,
789795
keyspace,
790796
statement,
@@ -818,6 +824,7 @@ def batch_by_plan(promise,
818824
rescue => e
819825
errors ||= {}
820826
errors[host] = e
827+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
821828
batch_by_plan(promise,
822829
keyspace,
823830
statement,
@@ -914,6 +921,7 @@ def batch_and_send_request_by_plan(host,
914921
(e.is_a?(Errors::TimeoutError) && batch_statement.idempotent?)
915922
errors ||= {}
916923
errors[host] = e
924+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
917925
batch_by_plan(promise,
918926
keyspace,
919927
batch_statement,
@@ -956,6 +964,7 @@ def send_request_by_plan(promise,
956964
unless pool
957965
errors ||= {}
958966
errors[host] = NOT_CONNECTED
967+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{errors[host].class.name}: #{errors[host]})")
959968
return send_request_by_plan(promise,
960969
keyspace,
961970
statement,
@@ -992,6 +1001,7 @@ def send_request_by_plan(promise,
9921001
(e.is_a?(Errors::TimeoutError) && statement.idempotent?)
9931002
errors ||= {}
9941003
errors[host] = e
1004+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
9951005
send_request_by_plan(promise,
9961006
keyspace,
9971007
statement,
@@ -1025,6 +1035,7 @@ def send_request_by_plan(promise,
10251035
rescue => e
10261036
errors ||= {}
10271037
errors[host] = e
1038+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
10281039
send_request_by_plan(promise,
10291040
keyspace,
10301041
statement,
@@ -1147,6 +1158,7 @@ def handle_response(response_future,
11471158
if e.is_a?(Errors::HostError) ||
11481159
(e.is_a?(Errors::TimeoutError) && statement.idempotent?)
11491160
errors[host] = e
1161+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
11501162
execute_by_plan(promise,
11511163
keyspace,
11521164
statement,
@@ -1174,6 +1186,7 @@ def handle_response(response_future,
11741186
if error.is_a?(Errors::HostError) ||
11751187
(error.is_a?(Errors::TimeoutError) && statement.idempotent?)
11761188
errors[host] = error
1189+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{error.class.name}: #{error})")
11771190

11781191
case request
11791192
when Protocol::QueryRequest, Protocol::PrepareRequest
@@ -1355,6 +1368,7 @@ def handle_response(response_future,
13551368
hosts,
13561369
request.consistency,
13571370
retries)
1371+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{errors[host].class.name}: #{errors[host]})")
13581372
case request
13591373
when Protocol::QueryRequest, Protocol::PrepareRequest
13601374
send_request_by_plan(promise,
@@ -1435,6 +1449,7 @@ def handle_response(response_future,
14351449
(ex.is_a?(Errors::TimeoutError) && statement.idempotent?)
14361450

14371451
errors[host] = ex
1452+
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{ex.class.name}: #{ex})")
14381453
case request
14391454
when Protocol::QueryRequest, Protocol::PrepareRequest
14401455
send_request_by_plan(promise,

0 commit comments

Comments
 (0)