Skip to content

Commit

Permalink
Display warnings when request failed
Browse files Browse the repository at this point in the history
These warnings help us to investigate the cause
when something wrong happens.
  • Loading branch information
abicky committed Aug 25, 2021
1 parent 572dec0 commit 211396c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/cassandra/cluster/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ def execute_by_plan(promise,
unless pool
errors ||= {}
errors[host] = NOT_CONNECTED
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{errors[host].class.name}: #{errors[host]})")
return execute_by_plan(promise,
keyspace,
statement,
Expand Down Expand Up @@ -602,6 +603,7 @@ def execute_by_plan(promise,
(e.is_a?(Errors::TimeoutError) && statement.idempotent?)
errors ||= {}
errors[host] = e
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
execute_by_plan(promise,
keyspace,
statement,
Expand Down Expand Up @@ -635,6 +637,7 @@ def execute_by_plan(promise,
rescue => e
errors ||= {}
errors[host] = e
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
execute_by_plan(promise,
keyspace,
statement,
Expand Down Expand Up @@ -705,6 +708,7 @@ def prepare_and_send_request_by_plan(host,
(e.is_a?(Errors::TimeoutError) && statement.idempotent?)
errors ||= {}
errors[host] = e
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
execute_by_plan(promise,
keyspace,
statement,
Expand Down Expand Up @@ -749,6 +753,7 @@ def batch_by_plan(promise,
unless pool
errors ||= {}
errors[host] = NOT_CONNECTED
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{errors[host].class.name}: #{errors[host]})")
return batch_by_plan(promise,
keyspace,
statement,
Expand Down Expand Up @@ -785,6 +790,7 @@ def batch_by_plan(promise,
(e.is_a?(Errors::TimeoutError) && statement.idempotent?)
errors ||= {}
errors[host] = e
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
batch_by_plan(promise,
keyspace,
statement,
Expand Down Expand Up @@ -818,6 +824,7 @@ def batch_by_plan(promise,
rescue => e
errors ||= {}
errors[host] = e
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
batch_by_plan(promise,
keyspace,
statement,
Expand Down Expand Up @@ -914,6 +921,7 @@ def batch_and_send_request_by_plan(host,
(e.is_a?(Errors::TimeoutError) && batch_statement.idempotent?)
errors ||= {}
errors[host] = e
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
batch_by_plan(promise,
keyspace,
batch_statement,
Expand Down Expand Up @@ -956,6 +964,7 @@ def send_request_by_plan(promise,
unless pool
errors ||= {}
errors[host] = NOT_CONNECTED
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{errors[host].class.name}: #{errors[host]})")
return send_request_by_plan(promise,
keyspace,
statement,
Expand Down Expand Up @@ -992,6 +1001,7 @@ def send_request_by_plan(promise,
(e.is_a?(Errors::TimeoutError) && statement.idempotent?)
errors ||= {}
errors[host] = e
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
send_request_by_plan(promise,
keyspace,
statement,
Expand Down Expand Up @@ -1025,6 +1035,7 @@ def send_request_by_plan(promise,
rescue => e
errors ||= {}
errors[host] = e
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
send_request_by_plan(promise,
keyspace,
statement,
Expand Down Expand Up @@ -1147,6 +1158,7 @@ def handle_response(response_future,
if e.is_a?(Errors::HostError) ||
(e.is_a?(Errors::TimeoutError) && statement.idempotent?)
errors[host] = e
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{e.class.name}: #{e})")
execute_by_plan(promise,
keyspace,
statement,
Expand Down Expand Up @@ -1174,6 +1186,7 @@ def handle_response(response_future,
if error.is_a?(Errors::HostError) ||
(error.is_a?(Errors::TimeoutError) && statement.idempotent?)
errors[host] = error
@logger.warn("Failed to send a request to #{host.ip} on #{retries + 1}th try (#{error.class.name}: #{error})")

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

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

0 comments on commit 211396c

Please sign in to comment.