diff --git a/be/src/agent/publish_version.cpp b/be/src/agent/publish_version.cpp index c1a30f88216ff..d1c3508537216 100644 --- a/be/src/agent/publish_version.cpp +++ b/be/src/agent/publish_version.cpp @@ -224,12 +224,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); + } } } } diff --git a/be/test/storage/publish_version_task_test.cpp b/be/test/storage/publish_version_task_test.cpp index b6963998c1f67..efe0ff409cabf 100644 --- a/be/test/storage/publish_version_task_test.cpp +++ b/be/test/storage/publish_version_task_test.cpp @@ -266,6 +266,21 @@ TEST_F(PublishVersionTaskTest, test_publish_version) { ->new_token(ThreadPool::ExecutionMode::CONCURRENT); std::unordered_set affected_dirs; std::vector 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 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;