Skip to content

Commit 55c5be5

Browse files
authored
[backport] CXXCBC-715: Hard Failover Intermittent Crash (#817)
Motivation =========== An HTTP workload can potentially use an invalid node index to access a node in the config in scenarios to where a node in the cluster has been failed over. Changes ======= * Upon updating the config w/in the HTTP Session manager, reset the next node index if its current value is greater than or equal to the number of nodes in the new config * Update analytics tool to only populate error context if the analytics operation has an error
1 parent d89ee04 commit 55c5be5

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

core/io/http_session_manager.hxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ public:
114114
void update_config(topology::configuration config) override
115115
{
116116
{
117-
std::scoped_lock config_lock(config_mutex_, sessions_mutex_);
117+
std::scoped_lock config_lock(config_mutex_, sessions_mutex_, next_index_mutex_);
118118
config_ = std::move(config);
119+
if (!config_.nodes.empty() && next_index_ >= config_.nodes.size()) {
120+
next_index_ = 0;
121+
}
119122
for (auto& [type, sessions] : idle_sessions_) {
120123
sessions.remove_if([&opts = options_, &cfg = config_](const auto& session) {
121124
return session && !cfg.has_node(opts.network,

tools/analytics.cxx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,14 @@ class analytics_app : public CLI::App
170170
: do_analytics(cluster, statement, analytics_options))
171171
.get();
172172

173+
auto ctx = error.ctx() && error.ctx().impl()
174+
? error.ctx().impl()->as<couchbase::core::error_context::analytics>()
175+
: couchbase::core::error_context::analytics{};
176+
173177
if (json_lines_) {
174-
print_result_json_line(scope_id,
175-
statement,
176-
error.ctx().impl()->as<couchbase::core::error_context::analytics>(),
177-
resp,
178-
analytics_options);
178+
print_result_json_line(scope_id, statement, ctx, resp, analytics_options);
179179
} else {
180-
print_result(scope_id,
181-
statement,
182-
error.ctx().impl()->as<couchbase::core::error_context::analytics>(),
183-
resp,
184-
analytics_options);
180+
print_result(scope_id, statement, ctx, resp, analytics_options);
185181
}
186182
}
187183

0 commit comments

Comments
 (0)