@@ -37,8 +37,7 @@ class OutgoingMigration::SliceSlotMigration : private ProtocolClient {
37
37
SliceSlotMigration (DbSlice* slice, ServerContext server_context, SlotSet slots,
38
38
journal::Journal* journal, OutgoingMigration* om)
39
39
: ProtocolClient(server_context), streamer_(slice, std::move(slots), journal, &exec_st_) {
40
- exec_st_.SwitchErrorHandler (
41
- [om](auto ge) { om->Finish (MigrationState::C_ERROR, std::move (ge)); });
40
+ exec_st_.SwitchErrorHandler ([om](auto ge) { om->Finish (std::move (ge)); });
42
41
}
43
42
44
43
~SliceSlotMigration () {
@@ -143,8 +142,15 @@ void OutgoingMigration::OnAllShards(
143
142
});
144
143
}
145
144
146
- void OutgoingMigration::Finish (MigrationState next_state, GenericError error) {
145
+ void OutgoingMigration::Finish (GenericError error) {
146
+ auto next_state = MigrationState::C_FINISHED;
147
147
if (error) {
148
+ // If OOM error move to FATAL, non-recoverable state
149
+ if (error == errc::not_enough_memory) {
150
+ next_state = MigrationState::C_FATAL;
151
+ } else {
152
+ next_state = MigrationState::C_ERROR;
153
+ }
148
154
LOG (WARNING) << " Finish outgoing migration for " << cf_->MyID () << " : "
149
155
<< migration_info_.node_info .id << " with error: " << error.Format ();
150
156
exec_st_.ReportError (std::move (error));
@@ -380,7 +386,8 @@ bool OutgoingMigration::FinalizeMigration(long attempt) {
380
386
381
387
// Check OOM from incoming slot migration on ACK request
382
388
if (CheckRespSimpleError (kIncomingMigrationOOM )) {
383
- Finish (MigrationState::C_FATAL, std::string (kIncomingMigrationOOM ));
389
+ Finish (GenericError{std::make_error_code (errc::not_enough_memory),
390
+ std::string (kIncomingMigrationOOM )});
384
391
return false ;
385
392
}
386
393
@@ -400,7 +407,7 @@ bool OutgoingMigration::FinalizeMigration(long attempt) {
400
407
}
401
408
402
409
if (!exec_st_.GetError ()) {
403
- Finish (MigrationState::C_FINISHED );
410
+ Finish ();
404
411
keys_number_ = cluster::GetKeyCount (migration_info_.slot_ranges );
405
412
cf_->ApplyMigrationSlotRangeToConfig (migration_info_.node_info .id , migration_info_.slot_ranges ,
406
413
false );
0 commit comments