db,view: avoid ignoring failed future in background view updates

The code for handling background view updates used to propagate
exceptions unconditionally, which leads to "exceptional future
ignored" warnings if the update was put to background.
From now on, the exception is only propagated if its future
is actually waited on.

Fixes #6187

Tested manually, the warning was not observed after the patch

Closes #9179
This commit is contained in:
Piotr Sarna
2021-08-10 15:11:01 +02:00
committed by Nadav Har'El
parent ea0e0c924d
commit 58196e8ea6

View File

@@ -1356,7 +1356,7 @@ future<> mutate_MV(
schema_ptr s = mut.s; schema_ptr s = mut.s;
future<> view_update = apply_to_remote_endpoints(*target_endpoint, std::move(remote_endpoints), std::move(mut), base_token, view_token, allow_hints, tr_state).then_wrapped( future<> view_update = apply_to_remote_endpoints(*target_endpoint, std::move(remote_endpoints), std::move(mut), base_token, view_token, allow_hints, tr_state).then_wrapped(
[s = std::move(s), &stats, &cf_stats, tr_state, base_token, view_token, target_endpoint, updates_pushed_remote, [s = std::move(s), &stats, &cf_stats, tr_state, base_token, view_token, target_endpoint, updates_pushed_remote,
units = sem_units.split(sem_units.count())] (future<>&& f) mutable { units = sem_units.split(sem_units.count()), wait_for_all] (future<>&& f) mutable {
if (f.failed()) { if (f.failed()) {
stats.view_updates_failed_remote += updates_pushed_remote; stats.view_updates_failed_remote += updates_pushed_remote;
cf_stats.total_view_updates_failed_remote += updates_pushed_remote; cf_stats.total_view_updates_failed_remote += updates_pushed_remote;
@@ -1365,7 +1365,7 @@ future<> mutate_MV(
*target_endpoint, updates_pushed_remote); *target_endpoint, updates_pushed_remote);
vlogger.error("Error applying view update to {} (view: {}.{}, base token: {}, view token: {}): {}", vlogger.error("Error applying view update to {} (view: {}.{}, base token: {}, view token: {}): {}",
*target_endpoint, s->ks_name(), s->cf_name(), base_token, view_token, ep); *target_endpoint, s->ks_name(), s->cf_name(), base_token, view_token, ep);
return make_exception_future<>(std::move(ep)); return wait_for_all ? make_exception_future<>(std::move(ep)) : make_ready_future<>();
} }
tracing::trace(tr_state, "Successfully applied view update for {} and {} remote endpoints", tracing::trace(tr_state, "Successfully applied view update for {} and {} remote endpoints",
*target_endpoint, updates_pushed_remote); *target_endpoint, updates_pushed_remote);