17
17
#include " server/journal/streamer.h"
18
18
#include " server/server_family.h"
19
19
20
- ABSL_FLAG (int , source_connect_timeout_ms, 20000 ,
21
- " Timeout for establishing connection to a source node" );
20
+ ABSL_FLAG (int , slot_migration_connection_timeout_ms, 2000 , " Timeout for network operations" );
22
21
23
22
using namespace std ;
24
23
using namespace facade ;
@@ -37,7 +36,8 @@ class OutgoingMigration::SliceSlotMigration : private ProtocolClient {
37
36
}
38
37
39
38
std::error_code Start (const std::string& node_id, uint32_t shard_id) {
40
- RETURN_ON_ERR (ConnectAndAuth (absl::GetFlag (FLAGS_source_connect_timeout_ms) * 1ms, &cntx_));
39
+ RETURN_ON_ERR (
40
+ ConnectAndAuth (absl::GetFlag (FLAGS_slot_migration_connection_timeout_ms) * 1ms, &cntx_));
41
41
ResetParser (/* server_mode=*/ false );
42
42
43
43
std::string cmd = absl::StrCat (" DFLYMIGRATE FLOW " , node_id, " " , shard_id);
@@ -86,6 +86,7 @@ MigrationState OutgoingMigration::GetState() const {
86
86
}
87
87
88
88
void OutgoingMigration::SyncFb () {
89
+ state_.store (MigrationState::C_SYNC);
89
90
auto start_cb = [this ](util::ProactorBase* pb) {
90
91
if (auto * shard = EngineShard::tlocal (); shard) {
91
92
server_family_->journal ()->StartInThread ();
@@ -146,10 +147,10 @@ bool OutgoingMigration::FinishMigration(long attempt) {
146
147
LOG_IF (WARNING, err) << err;
147
148
148
149
if (!err) {
149
- long attempt_res = - 1 ;
150
+ long attempt_res = kInvalidAttempt ;
150
151
do { // we can have response from previos time so we need to read until get response for the
151
152
// last attempt
152
- auto resp = ReadRespReply (absl::GetFlag (FLAGS_source_connect_timeout_ms ));
153
+ auto resp = ReadRespReply (absl::GetFlag (FLAGS_slot_migration_connection_timeout_ms ));
153
154
154
155
if (!resp) {
155
156
LOG (WARNING) << resp.error ();
@@ -163,6 +164,9 @@ bool OutgoingMigration::FinishMigration(long attempt) {
163
164
return false ;
164
165
}
165
166
attempt_res = get<int64_t >(LastResponseArgs ().front ().u );
167
+ if (attempt_res == kInvalidAttempt ) {
168
+ return false ;
169
+ }
166
170
} while (attempt_res != attempt);
167
171
168
172
shard_set->pool ()->AwaitFiberOnAll ([this ](util::ProactorBase* pb) {
@@ -172,6 +176,7 @@ bool OutgoingMigration::FinishMigration(long attempt) {
172
176
173
177
state_.store (MigrationState::C_FINISHED);
174
178
cf_->UpdateConfig (migration_info_.slot_ranges , false );
179
+ VLOG (1 ) << " Config is updated for " << cf_->MyID ();
175
180
return true ;
176
181
} else {
177
182
// TODO implement connection issue error processing
@@ -196,7 +201,7 @@ std::error_code OutgoingMigration::Start(ConnectionContext* cntx) {
196
201
RETURN_ON_ERR (check_connection_error (ec, " could not resolve host dns" ));
197
202
198
203
VLOG (1 ) << " Connecting to source" ;
199
- ec = ConnectAndAuth (absl::GetFlag (FLAGS_source_connect_timeout_ms ) * 1ms, &cntx_);
204
+ ec = ConnectAndAuth (absl::GetFlag (FLAGS_slot_migration_connection_timeout_ms ) * 1ms, &cntx_);
200
205
RETURN_ON_ERR (check_connection_error (ec, " couldn't connect to source" ));
201
206
202
207
VLOG (1 ) << " Migration initiating" ;
0 commit comments