@@ -2406,18 +2406,25 @@ bool DataStoreServiceClient::CopyBaseToArchive(
24062406 {
24072407 LOG (ERROR)
24082408 << " CopyBaseToArchive failed for read base table." ;
2409- return false ;
2409+ break ;
24102410 }
24112411 }
2412-
2413- // Wait the result all return .
2412+ // Wait the result all return before returning to avoid referencing
2413+ // invalid memory in callback .
24142414 {
24152415 std::unique_lock<bthread::Mutex> lk (mtx);
24162416 while (flying_cnt > 0 )
24172417 {
24182418 cv.wait (lk);
24192419 }
24202420 }
2421+
2422+ if (error_code != 0 )
2423+ {
2424+ LOG (ERROR) << " CopyBaseToArchive failed for read base table." ;
2425+ return false ;
2426+ }
2427+
24212428 // Process the results
24222429 for (size_t i = 0 ; i < base_vec.size (); i++)
24232430 {
@@ -4375,16 +4382,16 @@ void DataStoreServiceClient::UpsertTable(UpsertTableData *table_data)
43754382 if (alter_table_info)
43764383 {
43774384 auto *new_table_schema = table_data->new_table_schema_ ;
4378- ok = ok &&
4379- std::all_of (
4380- alter_table_info-> index_add_names_ . begin (),
4381- alter_table_info->index_add_names_ .end (),
4382- [ this , new_table_schema](
4383- const std::pair<txservice::TableName, std::string> &p)
4384- {
4385- return InitTableRanges (p.first ,
4386- new_table_schema->Version ());
4387- });
4385+ ok =
4386+ ok &&
4387+ std::all_of (
4388+ alter_table_info->index_add_names_ .begin (),
4389+ alter_table_info-> index_add_names_ . end (),
4390+ [ this , new_table_schema](
4391+ const std::pair<txservice::TableName, std::string> &p) {
4392+ return InitTableRanges (p.first ,
4393+ new_table_schema->Version ());
4394+ });
43884395 }
43894396
43904397 // 3- Delete table statistics
0 commit comments