Skip to content

Commit 5fc1890

Browse files
authored
Fix 2 bugs (#137)
1. copybasetoarchive read err code is ignored 2. data store close didnot reset pointer to null
1 parent 7468860 commit 5fc1890

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

data_store_service_client.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

eloq_data_store_service/data_store_service.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,7 @@ bool DataStoreService::SwitchReadOnlyToClosed(uint32_t shard_id)
22922292
{
22932293
cluster_manager_.SwitchShardToClosed(shard_id, expected);
22942294
data_store_->Shutdown();
2295+
data_store_ = nullptr;
22952296
}
22962297
return true;
22972298
}

0 commit comments

Comments
 (0)