streaming: Do send failed message for uninitialized session

The uninitialized session has no peer associated with it yet. There is
no point sending the failed message when abort the session. Sending the
failed message in this case will send to a peer with uninitialized
dst_cpu_id which will casue the receiver to pass a bogus shard id to
smp::submit_to which cases segfault.

In addition, to be safe, initialize the dst_cpu_id to zero. So that
uninitialized session will send message to shard zero instead of random
bogus shard id.

Fixes the segfault issue found by
repair_additional_test.py:RepairAdditionalTest.repair_abort_test

Fixes #3115
Message-Id: <9f0f7b44c7d6d8f5c60d6293ab2435dadc3496a9.1515380325.git.asias@scylladb.com>
This commit is contained in:
Asias He
2018-01-08 11:00:00 +08:00
committed by Pekka Enberg
parent 4610e994e1
commit 774307b3a7
2 changed files with 11 additions and 2 deletions

View File

@@ -266,7 +266,7 @@ void stream_session::received_failed_complete_message() {
}
void stream_session::abort() {
sslog.info("[Stream #{}] Aborted stream session, peer={}", plan_id(), peer);
sslog.info("[Stream #{}] Aborted stream session={}, peer={}, is_initialized={}", plan_id(), this, peer, is_initialized());
close_session(stream_session_state::FAILED);
}
@@ -366,6 +366,9 @@ void stream_session::transfer_task_completed_all() {
}
void stream_session::send_failed_complete_message() {
if (!is_initialized()) {
return;
}
auto plan_id = this->plan_id();
if (_received_failed_complete_message) {
sslog.debug("[Stream #{}] Skip sending failed message back to peer", plan_id);
@@ -525,6 +528,10 @@ void stream_session::start() {
});
}
bool stream_session::is_initialized() const {
return bool(_stream_result);
}
void stream_session::init(shared_ptr<stream_result_future> stream_result_) {
_stream_result = stream_result_;
_keep_alive.set_callback([this] {

View File

@@ -150,7 +150,7 @@ public:
* Each {@code StreamSession} is identified by this InetAddress which is broadcast address of the node streaming.
*/
inet_address peer;
unsigned dst_cpu_id;
unsigned dst_cpu_id = 0;
private:
// should not be null when session is started
shared_ptr<stream_result_future> _stream_result;
@@ -231,6 +231,8 @@ public:
void start();
bool is_initialized() const;
/**
* Request data fetch task to this session.
*