Skip to content

Commit

Permalink
[BugFix] Fix sync publish failed after BE restart (backport #51045) (#…
Browse files Browse the repository at this point in the history
…51179)

Co-authored-by: zhangqiang <[email protected]>
  • Loading branch information
mergify[bot] and sevev authored Sep 23, 2024
1 parent d3d8438 commit a489f1e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion be/src/agent/publish_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,16 @@ void run_publish_version_task(ThreadPoolToken* token, const TPublishVersionReque
tablet_info.tablet_id, partition_version.version, transaction_id);
} else {
const int64_t max_continuous_version =
enable_sync_publish ? tablet->max_continuous_version() : tablet->max_readable_version();
enable_sync_publish ? tablet->max_readable_version() : tablet->max_continuous_version();
if (max_continuous_version > 0) {
auto& pair = tablet_versions.emplace_back();
pair.__set_tablet_id(tablet_info.tablet_id);
pair.__set_version(max_continuous_version);
}

if (enable_sync_publish && tablet_tasks.empty() && max_continuous_version < partition_version.version) {
error_tablet_ids.push_back(tablet_info.tablet_id);
}
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions be/test/storage/publish_version_task_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,21 @@ TEST_F(PublishVersionTaskTest, test_publish_version) {
->new_token(ThreadPool::ExecutionMode::CONCURRENT);
std::unordered_set<DataDir*> affected_dirs;
std::vector<TFinishTaskRequest> finish_task_requests;
{
auto& finish_task_request = finish_task_requests.emplace_back();
TPublishVersionRequest publish_version_req;
publish_version_req.transaction_id = 3333;
TPartitionVersionInfo pvinfo;
pvinfo.partition_id = 10;
pvinfo.version = 10;
publish_version_req.partition_version_infos.push_back(pvinfo);
publish_version_req.enable_sync_publish = true;
std::vector<TabletInfo> tablet_infos;
StorageEngine::instance()->tablet_manager()->get_tablets_by_partition(10, tablet_infos);
ASSERT_TRUE(tablet_infos.size() > 0);
run_publish_version_task(token.get(), publish_version_req, finish_task_request, affected_dirs, 0);
ASSERT_EQ(1, finish_task_request.error_tablet_ids.size());
}
auto& finish_task_request = finish_task_requests.emplace_back();
// create req
TPublishVersionRequest publish_version_req;
Expand Down

0 comments on commit a489f1e

Please sign in to comment.