You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2025/04/08 21:31:03 UTC
(kudu) branch branch-1.18.x updated (850f0abfc -> 215b5ccba)
This is an automated email from the ASF dual-hosted git repository.
alexey pushed a change to branch branch-1.18.x
in repository https://gitbox.apache.org/repos/asf/kudu.git
from 850f0abfc [integration-tests] fix result status handling
new a7462ec35 [benchmarks] fix result status handling
new 9e0c2e539 [consensus] fix result status handling
new 5df4e06df [master] fix result status handling
new 82ab0ba37 [fs] fix result status handling
new 215b5ccba [cfile] fix result status handling
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/kudu/benchmarks/tpch/rpc_line_item_dao.cc | 2 +-
src/kudu/cfile/binary_dict_block.cc | 2 +-
src/kudu/cfile/index_block.cc | 2 +-
src/kudu/clock/builtin_ntp.cc | 2 +-
src/kudu/clock/logical_clock-test.cc | 9 ++--
src/kudu/codegen/codegen-test.cc | 4 +-
src/kudu/consensus/consensus_peers-test.cc | 14 +++---
src/kudu/consensus/consensus_peers.cc | 14 +++---
src/kudu/consensus/consensus_queue-test.cc | 10 ++--
src/kudu/consensus/consensus_queue.cc | 5 +-
src/kudu/consensus/consensus_queue.h | 2 +-
src/kudu/consensus/log-test.cc | 24 ++++-----
src/kudu/consensus/log.cc | 5 +-
src/kudu/consensus/log_anchor_registry.cc | 5 +-
src/kudu/consensus/log_anchor_registry.h | 2 +-
src/kudu/consensus/log_cache-test.cc | 24 ++++-----
src/kudu/consensus/peer_manager.cc | 19 ++++---
src/kudu/consensus/pending_rounds.cc | 11 +++-
src/kudu/consensus/raft_consensus.cc | 12 +++--
src/kudu/consensus/raft_consensus_quorum-test.cc | 6 +--
src/kudu/consensus/time_manager-test.cc | 4 +-
src/kudu/fs/block_manager-test.cc | 4 +-
src/kudu/fs/default_key_provider.h | 2 +-
src/kudu/fs/file_block_manager.cc | 2 +-
src/kudu/fs/fs_manager-test.cc | 11 ++--
src/kudu/fs/log_block_manager-test.cc | 16 +++---
src/kudu/integration-tests/ts_recovery-itest.cc | 8 ++-
src/kudu/master/auto_leader_rebalancer-test.cc | 64 +++++++++++++-----------
src/kudu/master/auto_leader_rebalancer.cc | 3 +-
src/kudu/master/auto_rebalancer.cc | 2 +-
src/kudu/master/catalog_manager.cc | 10 ++--
src/kudu/master/master-test.cc | 3 +-
src/kudu/master/sys_catalog-test.cc | 2 +-
33 files changed, 171 insertions(+), 134 deletions(-)
(kudu) 03/05: [master] fix result status handling
Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch branch-1.18.x
in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 5df4e06dfdb5861aec9545818572c3294088df6a
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Mon Mar 31 14:37:47 2025 -0700
[master] fix result status handling
This patch addresses sloppy result handling of functions/methods
that return Status under the src/kudu/master directory.
Change-Id: Id6c165b6db7ddfb8a838d5c92a029349a6bb21be
Reviewed-on: http://gerrit.cloudera.org:8080/22717
Tested-by: Kudu Jenkins
Reviewed-by: Zoltan Chovan <zc...@cloudera.com>
Reviewed-by: Marton Greber <gr...@gmail.com>
(cherry picked from commit 97df171f849a10ecbc3613962440f5d84b18314a)
Reviewed-on: http://gerrit.cloudera.org:8080/22759
Reviewed-by: Abhishek Chennaka <ac...@cloudera.com>
Tested-by: Alexey Serbin <al...@apache.org>
---
src/kudu/master/auto_leader_rebalancer-test.cc | 64 ++++++++++++++------------
src/kudu/master/auto_leader_rebalancer.cc | 3 +-
src/kudu/master/auto_rebalancer.cc | 2 +-
src/kudu/master/catalog_manager.cc | 10 ++--
src/kudu/master/master-test.cc | 3 +-
src/kudu/master/sys_catalog-test.cc | 2 +-
6 files changed, 45 insertions(+), 39 deletions(-)
diff --git a/src/kudu/master/auto_leader_rebalancer-test.cc b/src/kudu/master/auto_leader_rebalancer-test.cc
index d9f5949c0..dd59c612a 100644
--- a/src/kudu/master/auto_leader_rebalancer-test.cc
+++ b/src/kudu/master/auto_leader_rebalancer-test.cc
@@ -36,6 +36,7 @@
#include "kudu/consensus/consensus.pb.h"
#include "kudu/consensus/metadata.pb.h"
#include "kudu/gutil/ref_counted.h"
+#include "kudu/gutil/strings/substitute.h"
#include "kudu/integration-tests/test_workload.h"
#include "kudu/master/catalog_manager.h"
#include "kudu/master/master.h"
@@ -143,23 +144,23 @@ class LeaderRebalancerTest : public KuduTest {
}
// Get the leader numbers of each tablet server.
- void GetLeaderDistribution(std::map<string, int32_t>* leader_map,
+ Status GetLeaderDistribution(std::map<string, int32_t>* leader_map,
const string& table_name) {
leader_map->clear();
shared_ptr<KuduTable> table;
- workload_->client()->OpenTable(table_name, &table);
+ RETURN_NOT_OK(workload_->client()->OpenTable(table_name, &table));
scoped_refptr<TableInfo> table_info;
master::Master* master = cluster_->mini_master()->master();
master::CatalogManager* catalog_manager = master->catalog_manager();
{
CatalogManager::ScopedLeaderSharedLock leaderlock(catalog_manager);
- catalog_manager->GetTableInfo(table->id(), &table_info);
+ RETURN_NOT_OK(catalog_manager->GetTableInfo(table->id(), &table_info));
}
std::vector<string> leader_list;
for (const auto& tablet : table_info->tablet_map()) {
client::KuduTablet* ptr;
- workload_->client()->GetTablet(tablet.second->id(), &ptr);
+ RETURN_NOT_OK(workload_->client()->GetTablet(tablet.second->id(), &ptr));
unique_ptr<client::KuduTablet> tablet_ptr(ptr);
for (const auto* replica : tablet_ptr->replicas()) {
if (replica->is_leader()) {
@@ -176,6 +177,8 @@ class LeaderRebalancerTest : public KuduTest {
leader_map->emplace(e->permanent_uuid(), count(
leader_list.begin(), leader_list.end(), e->permanent_uuid()));
}
+
+ return Status::OK();
}
// Make the leader distribution as the vector passed in.
@@ -214,7 +217,7 @@ class LeaderRebalancerTest : public KuduTest {
unique_ptr<client::KuduTablet> tablet_copy;
{
client::KuduTablet* ptr;
- workload_->client()->GetTablet(tablet.second->id(), &ptr);
+ RETURN_NOT_OK(workload_->client()->GetTablet(tablet.second->id(), &ptr));
tablet_copy.reset(ptr);
}
for (const auto* replica: tablet_copy->replicas()) {
@@ -261,11 +264,11 @@ TEST_F(LeaderRebalancerTest, FunctionalTestForDivided) {
// Simulate the leader distribution.
std::vector<int32_t> leader_distribution = {4, 4, 1};
- MakeLeaderDistribution(leader_distribution, table_name());
+ ASSERT_OK(MakeLeaderDistribution(leader_distribution, table_name()));
SleepFor(MonoDelta::FromMilliseconds(3000));
std::map<string, int32_t> leader_map;
- GetLeaderDistribution(&leader_map, table_name());
+ ASSERT_OK(GetLeaderDistribution(&leader_map, table_name()));
LOG(INFO) << "The leader distribution is " << '\n';
for (const auto& leader : leader_map) {
std::cout << leader.first << " " << leader.second << '\n';
@@ -277,14 +280,14 @@ TEST_F(LeaderRebalancerTest, FunctionalTestForDivided) {
master::AutoLeaderRebalancerTask* leader_rebalancer =
master->catalog_manager()->auto_leader_rebalancer();
for (int i = 0; i < retries; i++) {
- leader_rebalancer->RunLeaderRebalancer();
+ ASSERT_OK(leader_rebalancer->RunLeaderRebalancer());
SleepFor(MonoDelta::FromMilliseconds(FLAGS_heartbeat_interval_ms));
}
// Check the leader numbers of each tablet server. It should always be floor(avg)
// or ceil(avg), where the parameter avg is (tablet num) / (tablet server num).
double expected_leader_num = static_cast<double>(kNumTablets) / 3;
- GetLeaderDistribution(&leader_map, table_name());
+ ASSERT_OK(GetLeaderDistribution(&leader_map, table_name()));
LOG(INFO) << "The leader distribution is " << '\n';
for (const auto& leader : leader_map) {
std::cout << leader.first << " " << leader.second << '\n';
@@ -296,21 +299,22 @@ TEST_F(LeaderRebalancerTest, FunctionalTestForDivided) {
// Try different leader distribution.
std::vector<int32_t> leader_distribution2 = {0, 8, 1};
- MakeLeaderDistribution(leader_distribution2, table_name());
+ ASSERT_OK(MakeLeaderDistribution(leader_distribution2, table_name()));
SleepFor(MonoDelta::FromMilliseconds(3000));
- GetLeaderDistribution(&leader_map, table_name());
+ ASSERT_OK(GetLeaderDistribution(&leader_map, table_name()));
LOG(INFO) << "The leader distribution is " << '\n';
for (const auto& leader : leader_map) {
std::cout << leader.first << " " << leader.second << '\n';
}
for (int i = 0; i < retries; i++) {
- leader_rebalancer->RunLeaderRebalancer();
+ SCOPED_TRACE(strings::Substitute("try $0", i));
+ ASSERT_OK(leader_rebalancer->RunLeaderRebalancer());
SleepFor(MonoDelta::FromMilliseconds(FLAGS_heartbeat_interval_ms));
}
- GetLeaderDistribution(&leader_map, table_name());
+ ASSERT_OK(GetLeaderDistribution(&leader_map, table_name()));
LOG(INFO) << "The leader distribution is " << '\n';
for (const auto& leader : leader_map) {
std::cout << leader.first << " " << leader.second << '\n';
@@ -331,11 +335,11 @@ TEST_F(LeaderRebalancerTest, FunctionalTestForNotDivided) {
// Simulate the leader distribution.
std::vector<int32_t> leader_distribution = {5, 4, 1};
- MakeLeaderDistribution(leader_distribution, table_name());
+ ASSERT_OK(MakeLeaderDistribution(leader_distribution, table_name()));
SleepFor(MonoDelta::FromMilliseconds(3000));
std::map<string, int32_t> leader_map;
- GetLeaderDistribution(&leader_map, table_name());
+ ASSERT_OK(GetLeaderDistribution(&leader_map, table_name()));
LOG(INFO) << "The leader distribution is " << '\n';
for (const auto& leader : leader_map) {
std::cout << leader.first << " " << leader.second << '\n';
@@ -347,14 +351,14 @@ TEST_F(LeaderRebalancerTest, FunctionalTestForNotDivided) {
master::AutoLeaderRebalancerTask* leader_rebalancer =
master->catalog_manager()->auto_leader_rebalancer();
for (int i = 0; i < retries; i++) {
- leader_rebalancer->RunLeaderRebalancer();
+ ASSERT_OK(leader_rebalancer->RunLeaderRebalancer());
SleepFor(MonoDelta::FromMilliseconds(FLAGS_heartbeat_interval_ms));
}
// Check the leader numbers of each tablet server. It should always be floor(avg)
// or ceil(avg), where the parameter avg is (tablet num) / (tablet server num).
double expected_leader_num = static_cast<double>(kNumTablets) / 3;
- GetLeaderDistribution(&leader_map, table_name());
+ ASSERT_OK(GetLeaderDistribution(&leader_map, table_name()));
LOG(INFO) << "The leader distribution is " << '\n';
for (const auto& leader : leader_map) {
std::cout << leader.first << " " << leader.second << '\n';
@@ -366,21 +370,21 @@ TEST_F(LeaderRebalancerTest, FunctionalTestForNotDivided) {
// Try different leader distribution.
std::vector<int32_t> leader_distribution2 = {8, 1, 1};
- MakeLeaderDistribution(leader_distribution2, table_name());
+ ASSERT_OK(MakeLeaderDistribution(leader_distribution2, table_name()));
SleepFor(MonoDelta::FromMilliseconds(3000));
- GetLeaderDistribution(&leader_map, table_name());
+ ASSERT_OK(GetLeaderDistribution(&leader_map, table_name()));
LOG(INFO) << "The leader distribution is " << '\n';
for (const auto& leader : leader_map) {
std::cout << leader.first << " " << leader.second << '\n';
}
for (int i = 0; i < retries; i++) {
- leader_rebalancer->RunLeaderRebalancer();
+ ASSERT_OK(leader_rebalancer->RunLeaderRebalancer());
SleepFor(MonoDelta::FromMilliseconds(FLAGS_heartbeat_interval_ms));
}
- GetLeaderDistribution(&leader_map, table_name());
+ ASSERT_OK(GetLeaderDistribution(&leader_map, table_name()));
LOG(INFO) << "The leader distribution is " << '\n';
for (const auto& leader : leader_map) {
std::cout << leader.first << " " << leader.second << '\n';
@@ -425,7 +429,7 @@ TEST_F(LeaderRebalancerTest, AddTserver) {
SleepFor(MonoDelta::FromSeconds(20 * FLAGS_auto_rebalancing_interval_seconds));
constexpr const int32_t retries = 40;
for (int i = 0; i < retries; i++) {
- leader_rebalancer->RunLeaderRebalancer();
+ ASSERT_OK(leader_rebalancer->RunLeaderRebalancer());
if (CheckLeaderBalance().ok()) {
break;
}
@@ -453,12 +457,12 @@ TEST_F(LeaderRebalancerTest, RestartTserver) {
ASSERT_NE(replica_rebalancer, nullptr);
ASSERT_NE(leader_rebalancer, nullptr);
- cluster_->mini_tablet_server(0)->Restart();
+ ASSERT_OK(cluster_->mini_tablet_server(0)->Restart());
// To wait replica_rebalancer execute some runs and reach balanced.
SleepFor(MonoDelta::FromSeconds(10 * FLAGS_auto_rebalancing_interval_seconds));
constexpr const int32_t retries = 20;
for (int i = 0; i < retries; i++) {
- leader_rebalancer->RunLeaderRebalancer();
+ ASSERT_OK(leader_rebalancer->RunLeaderRebalancer());
if (CheckLeaderBalance().ok()) {
break;
}
@@ -553,7 +557,7 @@ TEST_P(FilterSoftDeletedTableTest, TestFilterSofteDeletedTable) {
// Simulate the leader distribution.
std::vector<int32_t> leader_distribution = {4, 4, 1};
- MakeLeaderDistribution(leader_distribution, table_name());
+ ASSERT_OK(MakeLeaderDistribution(leader_distribution, table_name()));
SleepFor(MonoDelta::FromMilliseconds(3000));
string first_table = table_name();
@@ -566,11 +570,11 @@ TEST_P(FilterSoftDeletedTableTest, TestFilterSofteDeletedTable) {
workload_->Setup();
// Simulate the leader distribution.
- MakeLeaderDistribution(leader_distribution, soft_deleted_table);
+ ASSERT_OK(MakeLeaderDistribution(leader_distribution, soft_deleted_table));
SleepFor(MonoDelta::FromMilliseconds(3000));
// Delete the table 'soft_deleted_table'.
- workload_->client()->SoftDeleteTable(soft_deleted_table, 3600);
+ ASSERT_OK(workload_->client()->SoftDeleteTable(soft_deleted_table, 3600));
// Try to run leader rebalance for 10 times.
int32_t retries = 10;
@@ -578,18 +582,18 @@ TEST_P(FilterSoftDeletedTableTest, TestFilterSofteDeletedTable) {
master::AutoLeaderRebalancerTask* leader_rebalancer =
master->catalog_manager()->auto_leader_rebalancer();
for (int i = 0; i < retries; i++) {
- leader_rebalancer->RunLeaderRebalancer();
+ ASSERT_OK(leader_rebalancer->RunLeaderRebalancer());
SleepFor(MonoDelta::FromMilliseconds(FLAGS_heartbeat_interval_ms));
}
std::map<string, int32_t> leader_map;
// The first table is leader rebalanced.
- GetLeaderDistribution(&leader_map, first_table);
+ ASSERT_OK(GetLeaderDistribution(&leader_map, first_table));
for (const auto& leader: leader_map) {
ASSERT_EQ(leader.second, 3);
}
- GetLeaderDistribution(&leader_map, soft_deleted_table);
+ ASSERT_OK(GetLeaderDistribution(&leader_map, soft_deleted_table));
// The soft deleted table is not leader rebalanced.
if (FLAGS_leader_rebalancing_ignore_soft_deleted_tables) {
for (const auto& leader: leader_map) {
diff --git a/src/kudu/master/auto_leader_rebalancer.cc b/src/kudu/master/auto_leader_rebalancer.cc
index 6d2c6091f..0398b7574 100644
--- a/src/kudu/master/auto_leader_rebalancer.cc
+++ b/src/kudu/master/auto_leader_rebalancer.cc
@@ -443,7 +443,8 @@ Status AutoLeaderRebalancerTask::RunLeaderRebalancer() {
}
}
for (const auto& table_info : table_infos) {
- RunLeaderRebalanceForTable(table_info, tserver_uuids, exclude_dest_uuids);
+ RETURN_NOT_OK(RunLeaderRebalanceForTable(
+ table_info, tserver_uuids, exclude_dest_uuids));
}
// @TODO(duyuqi)
// Enrich the log and add metrics for leader rebalancer.
diff --git a/src/kudu/master/auto_rebalancer.cc b/src/kudu/master/auto_rebalancer.cc
index 518c3831e..39807905b 100644
--- a/src/kudu/master/auto_rebalancer.cc
+++ b/src/kudu/master/auto_rebalancer.cc
@@ -317,7 +317,7 @@ Status AutoRebalancerTask::GetMoves(
for (const auto& elem : ts_id_by_location) {
const auto& location = elem.first;
ClusterRawInfo location_raw_info;
- BuildClusterRawInfo(location, &location_raw_info);
+ RETURN_NOT_OK(BuildClusterRawInfo(location, &location_raw_info));
RETURN_NOT_OK(GetMovesUsingRebalancingAlgo(
location_raw_info, &algo, CrossLocations::NO, &rep_moves));
}
diff --git a/src/kudu/master/catalog_manager.cc b/src/kudu/master/catalog_manager.cc
index ef9f3827a..1a2d15438 100644
--- a/src/kudu/master/catalog_manager.cc
+++ b/src/kudu/master/catalog_manager.cc
@@ -921,10 +921,10 @@ void CheckIfNoLongerLeaderAndSetupError(const Status& s, RespClass* resp) {
// that is no longer the leader, this suffices until we
// distinguish this cause of write failure more explicitly.
if (s.IsIllegalState() || s.IsAborted()) {
- SetupError(Status::ServiceUnavailable(
- "operation requested can only be executed on a leader master, but this"
- " master is no longer the leader", s.ToString()),
- resp, MasterErrorPB::NOT_THE_LEADER);
+ ignore_result(SetupError(Status::ServiceUnavailable(
+ "operation requested can only be executed on a leader master, "
+ "but this master is no longer the leader", s.ToString()),
+ resp, MasterErrorPB::NOT_THE_LEADER));
}
}
@@ -3163,7 +3163,7 @@ Status CatalogManager::ApplyAlterPartitioningSteps(
RETURN_NOT_OK(partition_schema.DropRange(
range_bound.first, range_bound.second, schema));
PartitionSchemaPB ps_pb;
- partition_schema.ToPB(schema, &ps_pb);
+ RETURN_NOT_OK(partition_schema.ToPB(schema, &ps_pb));
// Make sure exactly one range is gone.
DCHECK_EQ(ps_pb.custom_hash_schema_ranges_size() + 1,
l->data().pb.partition_schema().custom_hash_schema_ranges_size());
diff --git a/src/kudu/master/master-test.cc b/src/kudu/master/master-test.cc
index a87dbc6e9..28f162a80 100644
--- a/src/kudu/master/master-test.cc
+++ b/src/kudu/master/master-test.cc
@@ -54,6 +54,7 @@
#include "kudu/consensus/consensus.pb.h"
#include "kudu/consensus/replica_management.pb.h"
#include "kudu/generated/version_defines.h"
+#include "kudu/gutil/basictypes.h"
#include "kudu/gutil/dynamic_annotations.h"
#include "kudu/gutil/integral_types.h"
#include "kudu/gutil/map-util.h"
@@ -2203,7 +2204,7 @@ TEST_F(MasterTest, TestGetTableLocationsDuringRepeatedTableVisit) {
// Call ElectedAsLeaderCb() repeatedly. If these spurious calls aren't
// ignored, the concurrent GetTableLocations() calls may crash the master.
for (int i = 0; i < 100; i++) {
- master_->catalog_manager()->ElectedAsLeaderCb();
+ ignore_result(master_->catalog_manager()->ElectedAsLeaderCb());
}
done.Store(true);
t.join();
diff --git a/src/kudu/master/sys_catalog-test.cc b/src/kudu/master/sys_catalog-test.cc
index 8a0a940f2..35e150305 100644
--- a/src/kudu/master/sys_catalog-test.cc
+++ b/src/kudu/master/sys_catalog-test.cc
@@ -471,7 +471,7 @@ TEST_F(SysCatalogTest, LoadClusterID) {
// Restart the master and ensure the generated cluster ID is the same.
mini_master_->Shutdown();
- mini_master_->Restart();
+ ASSERT_OK(mini_master_->Restart());
ASSERT_OK(mini_master_->master()->catalog_manager()->sys_catalog()->
GetClusterIdEntry(&cluster_id_entry));
ASSERT_EQ(init_id, cluster_id_entry.cluster_id());
(kudu) 01/05: [benchmarks] fix result status handling
Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch branch-1.18.x
in repository https://gitbox.apache.org/repos/asf/kudu.git
commit a7462ec35082ae959172a9ad12b3df282cd03cd5
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Thu Feb 27 18:25:48 2025 -0800
[benchmarks] fix result status handling
This patch addresses sloppy result handling of functions/methods
that return Status in the following directories
* src/kudu/benchmarks
* src/kudu/clock
* src/kudu/codegen
Change-Id: I3d9868da085d3448db876ca93e1ffbbb69a7ef31
Reviewed-on: http://gerrit.cloudera.org:8080/22647
Tested-by: Alexey Serbin <al...@apache.org>
Reviewed-by: Abhishek Chennaka <ac...@cloudera.com>
(cherry picked from commit e3c9f6b88f486af48ba1a0853e52eaf01bcb6ec6)
Reviewed-on: http://gerrit.cloudera.org:8080/22750
---
src/kudu/benchmarks/tpch/rpc_line_item_dao.cc | 2 +-
src/kudu/clock/builtin_ntp.cc | 2 +-
src/kudu/clock/logical_clock-test.cc | 9 ++++++---
src/kudu/codegen/codegen-test.cc | 4 ++--
4 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/kudu/benchmarks/tpch/rpc_line_item_dao.cc b/src/kudu/benchmarks/tpch/rpc_line_item_dao.cc
index a0c87ace1..a99e9a879 100644
--- a/src/kudu/benchmarks/tpch/rpc_line_item_dao.cc
+++ b/src/kudu/benchmarks/tpch/rpc_line_item_dao.cc
@@ -224,7 +224,7 @@ void RpcLineItemDAO::OpenScannerImpl(const vector<string>& columns,
unique_ptr<Scanner>* out_scanner) {
unique_ptr<Scanner> ret(new Scanner);
ret->scanner_.reset(new KuduScanner(client_table_.get()));
- ret->scanner_->SetCacheBlocks(FLAGS_tpch_cache_blocks_when_scanning);
+ CHECK_OK(ret->scanner_->SetCacheBlocks(FLAGS_tpch_cache_blocks_when_scanning));
CHECK_OK(ret->scanner_->SetProjectedColumnNames(columns));
for (KuduPredicate* pred : preds) {
CHECK_OK(ret->scanner_->AddConjunctPredicate(pred));
diff --git a/src/kudu/clock/builtin_ntp.cc b/src/kudu/clock/builtin_ntp.cc
index 1bfd026fc..8ec7940f7 100644
--- a/src/kudu/clock/builtin_ntp.cc
+++ b/src/kudu/clock/builtin_ntp.cc
@@ -686,7 +686,7 @@ void BuiltInNtp::Shutdown() {
if (socket_.GetFd() >= 0) {
// Shutting down the socket without closing it ensures that any attempt
// to call sendmsg() will get EPIPE.
- socket_.Shutdown(true, true);
+ WARN_NOT_OK(socket_.Shutdown(true, true), "coult not shutdown socket");
}
if (thread_) {
thread_->Join();
diff --git a/src/kudu/clock/logical_clock-test.cc b/src/kudu/clock/logical_clock-test.cc
index 7ee06b94e..5ba026da2 100644
--- a/src/kudu/clock/logical_clock-test.cc
+++ b/src/kudu/clock/logical_clock-test.cc
@@ -15,9 +15,12 @@
// specific language governing permissions and limitations
// under the License.
+#include "kudu/clock/logical_clock.h"
+
+#include <string>
+
#include <gtest/gtest.h>
-#include "kudu/clock/logical_clock.h"
#include "kudu/common/timestamp.h"
#include "kudu/util/monotime.h"
#include "kudu/util/status.h"
@@ -48,7 +51,7 @@ TEST_F(LogicalClockTest, NowValuesIncreaseMonotonically) {
TEST_F(LogicalClockTest, UpdateLogicalValueIncreasesByAmount) {
Timestamp initial = clock_.Now();
Timestamp future(initial.value() + 10);
- clock_.Update(future);
+ ASSERT_OK(clock_.Update(future));
Timestamp now = clock_.Now();
// now should be 1 after future
ASSERT_EQ(initial.value() + 11, now.value());
@@ -58,7 +61,7 @@ TEST_F(LogicalClockTest, UpdateLogicalValueIncreasesByAmount) {
TEST_F(LogicalClockTest, UpdateLogicalValueDoesNotIncrease) {
Timestamp ts(1);
// update the clock to 1, the initial value, should do nothing
- clock_.Update(ts);
+ ASSERT_OK(clock_.Update(ts));
Timestamp now = clock_.Now();
ASSERT_EQ(2, now.value());
}
diff --git a/src/kudu/codegen/codegen-test.cc b/src/kudu/codegen/codegen-test.cc
index dfde2297f..0caa04128 100644
--- a/src/kudu/codegen/codegen-test.cc
+++ b/src/kudu/codegen/codegen-test.cc
@@ -77,7 +77,7 @@ class CodegenTest : public KuduTest {
ColumnSchema("str32 ", STRING, false),
ColumnSchema("str32-null-val", STRING, true),
ColumnSchema("str32-null ", STRING, true) };
- base_.Reset(cols, 1);
+ CHECK_OK(base_.Reset(cols, 1));
base_ = SchemaBuilder(base_).Build(); // add IDs
// Create an extended default schema
@@ -85,7 +85,7 @@ class CodegenTest : public KuduTest {
cols.emplace_back("int32-RW", INT32, false, false, false, kI32R, kI32W);
cols.emplace_back("str32-R ", STRING, false, false, false, kStrR, nullptr);
cols.emplace_back("str32-RW", STRING, false, false, false, kStrR, kStrW);
- defaults_.Reset(cols, 1);
+ CHECK_OK(defaults_.Reset(cols, 1));
defaults_ = SchemaBuilder(defaults_).Build(); // add IDs
test_rows_arena_.reset(new Arena(2 * 1024));
(kudu) 05/05: [cfile] fix result status handling
Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch branch-1.18.x
in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 215b5ccba45f4227905b968476d44be486656958
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Thu Feb 27 18:22:24 2025 -0800
[cfile] fix result status handling
This patch addresses sloppy result handling of functions/methods
that return Status under the src/kudu/cfile directory.
Change-Id: I2bbfc65ef4d2312ee5af04741d8cf179f2de2b9b
Reviewed-on: http://gerrit.cloudera.org:8080/22641
Tested-by: Alexey Serbin <al...@apache.org>
Reviewed-by: Abhishek Chennaka <ac...@cloudera.com>
(cherry picked from commit 197005b5ec7fa535dce896d7b1ff12f8c3c66157)
Reviewed-on: http://gerrit.cloudera.org:8080/22751
---
src/kudu/cfile/binary_dict_block.cc | 2 +-
src/kudu/cfile/index_block.cc | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kudu/cfile/binary_dict_block.cc b/src/kudu/cfile/binary_dict_block.cc
index 74ca863ae..c860ef468 100644
--- a/src/kudu/cfile/binary_dict_block.cc
+++ b/src/kudu/cfile/binary_dict_block.cc
@@ -299,7 +299,7 @@ Status BinaryDictBlockDecoder::CopyNextAndEval(size_t* n,
// Load the rows' codeword values into a buffer for scanning.
BShufBlockDecoder<UINT32>* d_bptr = down_cast<BShufBlockDecoder<UINT32>*>(data_decoder_.get());
codeword_buf_.resize(*n * sizeof(uint32_t));
- d_bptr->CopyNextValuesToArray(n, codeword_buf_.data());
+ RETURN_NOT_OK(d_bptr->CopyNextValuesToArray(n, codeword_buf_.data()));
Slice* out = reinterpret_cast<Slice*>(dst->data());
for (size_t i = 0; i < *n; i++, out++) {
// Check with the SelectionVectorView to see whether the data has already
diff --git a/src/kudu/cfile/index_block.cc b/src/kudu/cfile/index_block.cc
index c003d1e3e..6f2fab1dc 100644
--- a/src/kudu/cfile/index_block.cc
+++ b/src/kudu/cfile/index_block.cc
@@ -245,7 +245,7 @@ Status IndexBlockReader::ReadEntry(size_t idx,
const uint8_t* ptr = nullptr;
const uint8_t* limit = nullptr;
- GetKeyPointer(idx, &ptr, &limit);
+ RETURN_NOT_OK(GetKeyPointer(idx, &ptr, &limit));
ptr = SliceDecode(ptr, limit, key);
if (PREDICT_FALSE(!ptr)) {
(kudu) 02/05: [consensus] fix result status handling
Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch branch-1.18.x
in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 9e0c2e5390ebd88f87702ccba4a9992357d0bb2b
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Thu Feb 27 18:19:12 2025 -0800
[consensus] fix result status handling
This patch addresses sloppy result handling of functions/methods
that return Status under the src/kudu/consensus directory.
In addition, this patch introduces a new unsafe runtime flag
--raft_allow_committed_pending_index_gap that's now used by the
TsRecoveryITestDeathTest.RecoverFromOpIdOverflow test scenario only.
The test scenario was reliant on the sloppy result status handling
of the call to PendingRounds::SetInitialCommittedOpId() in
RaftConsensus::Start() that's been addressed in this patch. It's
the path of least resistance compared with updating test scaffolding
and the test scenario itself, but it also has a benefit of providing
a flag to enable the former result status handling approach in
RaftConsensus::Start() when setting last committed OpId for a tablet's
Raft consensus implementation. Frankly, I don't think anybody will ever
need to re-enable the original bogus behavior of ignoring non-OK result
status, but it doesn't hurt to have such an option just in case
if I'm missing something here.
Change-Id: I6db113c58c6b453bf3cd290ee0dfdd184b63b999
Reviewed-on: http://gerrit.cloudera.org:8080/22646
Reviewed-by: Abhishek Chennaka <ac...@cloudera.com>
Tested-by: Alexey Serbin <al...@apache.org>
(cherry picked from commit bde9cbad115deb1cd689eb583a1c7a8d3440b156)
Reviewed-on: http://gerrit.cloudera.org:8080/22752
---
src/kudu/consensus/consensus_peers-test.cc | 14 +++++++-------
src/kudu/consensus/consensus_peers.cc | 14 +++++++-------
src/kudu/consensus/consensus_queue-test.cc | 10 +++++-----
src/kudu/consensus/consensus_queue.cc | 5 ++---
src/kudu/consensus/consensus_queue.h | 2 +-
src/kudu/consensus/log-test.cc | 24 ++++++++++++------------
src/kudu/consensus/log.cc | 5 ++---
src/kudu/consensus/log_anchor_registry.cc | 5 +++--
src/kudu/consensus/log_anchor_registry.h | 2 +-
src/kudu/consensus/log_cache-test.cc | 24 ++++++++++++------------
src/kudu/consensus/peer_manager.cc | 19 ++++++++++++-------
src/kudu/consensus/pending_rounds.cc | 11 ++++++++++-
src/kudu/consensus/raft_consensus.cc | 12 ++++++++----
src/kudu/consensus/raft_consensus_quorum-test.cc | 6 +++---
src/kudu/consensus/time_manager-test.cc | 4 ++--
src/kudu/integration-tests/ts_recovery-itest.cc | 8 +++++++-
16 files changed, 94 insertions(+), 71 deletions(-)
diff --git a/src/kudu/consensus/consensus_peers-test.cc b/src/kudu/consensus/consensus_peers-test.cc
index 02e2ec89c..236f730f9 100644
--- a/src/kudu/consensus/consensus_peers-test.cc
+++ b/src/kudu/consensus/consensus_peers-test.cc
@@ -208,7 +208,7 @@ TEST_F(ConsensusPeersTest, TestRemotePeer) {
AppendReplicateMessagesToQueue(message_queue_.get(), clock_.get(), 1, 20);
// signal the peer there are requests pending.
- remote_peer->SignalRequest();
+ ASSERT_OK(remote_peer->SignalRequest());
// now wait on the status of the last operation
// this will complete once the peer has logged all
// requests.
@@ -240,8 +240,8 @@ TEST_F(ConsensusPeersTest, TestRemotePeers) {
OpId first = MakeOpId(0, 1);
- remote_peer1->SignalRequest();
- remote_peer2->SignalRequest();
+ ASSERT_OK(remote_peer1->SignalRequest());
+ ASSERT_OK(remote_peer2->SignalRequest());
// Now wait for the message to be replicated, this should succeed since
// majority = 2 and only one peer was delayed. The majority is made up
@@ -268,7 +268,7 @@ TEST_F(ConsensusPeersTest, TestRemotePeers) {
ASSERT_LT(message_queue_->GetCommittedIndex(), 2);
// Signal one of the two remote peers.
- remote_peer1->SignalRequest();
+ ASSERT_OK(remote_peer1->SignalRequest());
// We should now be able to wait for it to replicate, since two peers (a majority)
// have replicated the message.
WaitForCommitIndex(2);
@@ -308,7 +308,7 @@ TEST_F(ConsensusPeersTest, TestCloseWhenRemotePeerDoesntMakeProgress) {
// Add an op to the queue and start sending requests to the peer.
AppendReplicateMessagesToQueue(message_queue_.get(), clock_.get(), 1, 1);
- peer->SignalRequest(true);
+ ASSERT_OK(peer->SignalRequest(true));
// We should be able to close the peer even though it has more data pending.
peer->Close();
@@ -346,7 +346,7 @@ TEST_F(ConsensusPeersTest, TestDontSendOneRpcPerWriteWhenPeerIsDown) {
mock_proxy->set_update_response(initial_resp);
AppendReplicateMessagesToQueue(message_queue_.get(), clock_.get(), 1, 1);
- peer->SignalRequest(true);
+ ASSERT_OK(peer->SignalRequest(true));
// Now wait for the message to be replicated, this should succeed since
// the local (leader) peer always acks and the follower also acked this time.
@@ -361,7 +361,7 @@ TEST_F(ConsensusPeersTest, TestDontSendOneRpcPerWriteWhenPeerIsDown) {
// Add a bunch of messages to the queue.
for (int i = 2; i <= 100; i++) {
AppendReplicateMessagesToQueue(message_queue_.get(), clock_.get(), i, 1);
- peer->SignalRequest(false);
+ ASSERT_OK(peer->SignalRequest(false));
SleepFor(MonoDelta::FromMilliseconds(2));
}
diff --git a/src/kudu/consensus/consensus_peers.cc b/src/kudu/consensus/consensus_peers.cc
index 349a34ced..469c229d7 100644
--- a/src/kudu/consensus/consensus_peers.cc
+++ b/src/kudu/consensus/consensus_peers.cc
@@ -151,12 +151,12 @@ void Peer::Init() {
// Capture a weak_ptr reference into the functor so it can safely handle
// outliving the peer.
- weak_ptr<Peer> w = shared_from_this();
+ weak_ptr<Peer> w_this = shared_from_this();
heartbeater_ = PeriodicTimer::Create(
messenger_,
- [w]() {
- if (auto p = w.lock()) {
- p->SignalRequest(true);
+ [w_this = std::move(w_this)]() {
+ if (auto p = w_this.lock()) {
+ WARN_NOT_OK(p->SignalRequest(true), "SignalRequest failed");
}
},
MonoDelta::FromMilliseconds(FLAGS_raft_heartbeat_interval_ms));
@@ -170,7 +170,7 @@ Status Peer::SignalRequest(bool even_if_queue_empty) {
// the implementation of SendNextRequest() checks for 'closed_' and
// 'request_pending_' on its own.
if (PREDICT_FALSE(closed_)) {
- return Status::IllegalState("Peer was closed.");
+ return Status::IllegalState("peer closed");
}
// Only allow one request at a time. No sense waking up the
@@ -181,8 +181,8 @@ Status Peer::SignalRequest(bool even_if_queue_empty) {
// Capture a weak_ptr reference into the submitted functor so that we can
// safely handle the functor outliving its peer.
- weak_ptr<Peer> w_this = shared_from_this();
- return raft_pool_token_->Submit([even_if_queue_empty, w_this]() {
+ weak_ptr<Peer> w_this(shared_from_this());
+ return raft_pool_token_->Submit([even_if_queue_empty, w_this = std::move(w_this)]() {
if (auto p = w_this.lock()) {
p->SendNextRequest(even_if_queue_empty);
}
diff --git a/src/kudu/consensus/consensus_queue-test.cc b/src/kudu/consensus/consensus_queue-test.cc
index 0a64c1df1..56d6cb511 100644
--- a/src/kudu/consensus/consensus_queue-test.cc
+++ b/src/kudu/consensus/consensus_queue-test.cc
@@ -131,7 +131,7 @@ class ConsensusQueueTest : public KuduTest {
}
void TearDown() override {
- log_->WaitUntilAllFlushed();
+ ASSERT_OK(log_->WaitUntilAllFlushed());
queue_->Close();
}
@@ -910,7 +910,7 @@ TEST_F(ConsensusQueueTest, TestQueueMovesWatermarksBackward) {
// Append a bunch of messages and update as if they were also appeneded to the leader.
queue_->UpdateLastIndexAppendedToLeader(10);
AppendReplicateMessagesToQueue(queue_.get(), clock_.get(), 1, 10);
- log_->WaitUntilAllFlushed();
+ ASSERT_OK(log_->WaitUntilAllFlushed());
// Now rewrite some of the operations and wait for the log to append.
Synchronizer synch;
@@ -995,14 +995,14 @@ TEST_F(ConsensusQueueTest, TestOnlyAdvancesWatermarkWhenPeerHasAPrefixOfOurLog)
for (int i = 31; i <= 53; i++) {
if (i <= 45) {
- AppendReplicateMsg(72, i, 1024);
+ ASSERT_OK(AppendReplicateMsg(72, i, 1024));
continue;
}
if (i <= 51) {
- AppendReplicateMsg(73, i, 1024);
+ ASSERT_OK(AppendReplicateMsg(73, i, 1024));
continue;
}
- AppendReplicateMsg(76, i, 1024);
+ ASSERT_OK(AppendReplicateMsg(76, i, 1024));
}
WaitForLocalPeerToAckIndex(53);
diff --git a/src/kudu/consensus/consensus_queue.cc b/src/kudu/consensus/consensus_queue.cc
index c3d546989..c4551ea6a 100644
--- a/src/kudu/consensus/consensus_queue.cc
+++ b/src/kudu/consensus/consensus_queue.cc
@@ -1467,14 +1467,13 @@ void PeerMessageQueue::RegisterObserver(PeerMessageQueueObserver* observer) {
}
}
-Status PeerMessageQueue::UnRegisterObserver(PeerMessageQueueObserver* observer) {
+void PeerMessageQueue::UnRegisterObserver(PeerMessageQueueObserver* observer) {
std::lock_guard lock(queue_lock_);
auto iter = std::find(observers_.begin(), observers_.end(), observer);
if (iter == observers_.end()) {
- return Status::NotFound("Can't find observer.");
+ return;
}
observers_.erase(iter);
- return Status::OK();
}
bool PeerMessageQueue::IsOpInLog(const OpId& desired_op) const {
diff --git a/src/kudu/consensus/consensus_queue.h b/src/kudu/consensus/consensus_queue.h
index e25e5958f..16d1f7ed3 100644
--- a/src/kudu/consensus/consensus_queue.h
+++ b/src/kudu/consensus/consensus_queue.h
@@ -346,7 +346,7 @@ class PeerMessageQueue {
void RegisterObserver(PeerMessageQueueObserver* observer);
- Status UnRegisterObserver(PeerMessageQueueObserver* observer);
+ void UnRegisterObserver(PeerMessageQueueObserver* observer);
struct Metrics {
// Keeps track of the number of ops. that are completed by a majority but still need
diff --git a/src/kudu/consensus/log-test.cc b/src/kudu/consensus/log-test.cc
index 4ea6e0bc8..61852d88c 100644
--- a/src/kudu/consensus/log-test.cc
+++ b/src/kudu/consensus/log-test.cc
@@ -137,7 +137,7 @@ class LogTest : public LogTestBase {
LogSegmentHeaderPB header;
header.set_sequence_number(sequence_number);
header.set_tablet_id(kTestTablet);
- SchemaToPB(GetSimpleTestSchema(), header.mutable_schema());
+ RETURN_NOT_OK(SchemaToPB(GetSimpleTestSchema(), header.mutable_schema()));
LogSegmentFooterPB footer;
footer.set_num_entries(10);
@@ -189,7 +189,7 @@ TEST_P(LogTestOptionalCompression, TestMultipleEntriesInABatch) {
opid.set_term(1);
opid.set_index(1);
- AppendNoOpsToLogSync(clock_.get(), log_.get(), &opid, 2);
+ ASSERT_OK(AppendNoOpsToLogSync(clock_.get(), log_.get(), &opid, 2));
// RollOver() the batch so that we have a properly formed footer.
ASSERT_OK(log_->AllocateSegmentAndRollOverForTests());
@@ -245,7 +245,7 @@ TEST_P(LogTestOptionalCompression, TestFsync) {
opid.set_term(0);
opid.set_index(1);
- AppendNoOp(&opid);
+ ASSERT_OK(AppendNoOp(&opid));
ASSERT_OK(log_->Close());
}
@@ -258,14 +258,14 @@ TEST_P(LogTestOptionalCompression, TestSizeIsMaintained) {
ASSERT_OK(BuildLog());
OpId opid = MakeOpId(0, 1);
- AppendNoOp(&opid);
+ ASSERT_OK(AppendNoOp(&opid));
SegmentSequence segments;
log_->reader()->GetSegmentsSnapshot(&segments);
int64_t orig_size = segments[0]->file_size();
ASSERT_GT(orig_size, 0);
- AppendNoOp(&opid);
+ ASSERT_OK(AppendNoOp(&opid));
log_->reader()->GetSegmentsSnapshot(&segments);
int64_t new_size = segments[0]->file_size();
@@ -283,7 +283,7 @@ TEST_P(LogTestOptionalCompression, TestLogNotTrimmed) {
opid.set_term(0);
opid.set_index(1);
- AppendNoOp(&opid);
+ ASSERT_OK(AppendNoOp(&opid));
SegmentSequence segments;
log_->reader()->GetSegmentsSnapshot(&segments);
@@ -1153,12 +1153,12 @@ TEST_F(LogTest, TestAutoStopIdleAppendThread) {
// after the append long enough for the append thread to shut itself down
// again.
ASSERT_EVENTUALLY([&]() {
- AppendNoOpsToLogSync(clock_.get(), log_.get(), &opid, 2);
- ASSERT_TRUE(log_->append_thread_active_for_tests());
- debug::ScopedTSANIgnoreReadsAndWrites ignore_tsan;
- ASSERT_GT(log_->segment_allocator_.active_segment_->compress_buf_.capacity(),
- faststring::kInitialCapacity);
- });
+ ASSERT_OK(AppendNoOpsToLogSync(clock_.get(), log_.get(), &opid, 2));
+ ASSERT_TRUE(log_->append_thread_active_for_tests());
+ debug::ScopedTSANIgnoreReadsAndWrites ignore_tsan;
+ ASSERT_GT(log_->segment_allocator_.active_segment_->compress_buf_.capacity(),
+ faststring::kInitialCapacity);
+ });
// After some time, the append thread should shut itself down.
ASSERT_EVENTUALLY([&]() {
ASSERT_FALSE(log_->append_thread_active_for_tests());
diff --git a/src/kudu/consensus/log.cc b/src/kudu/consensus/log.cc
index 8ae2c174c..eced64a26 100644
--- a/src/kudu/consensus/log.cc
+++ b/src/kudu/consensus/log.cc
@@ -889,8 +889,7 @@ Status Log::AsyncAppendCommit(const consensus::CommitMsg& commit_msg,
unique_ptr<LogEntryBatch> entry_batch = CreateBatchFromPB(
COMMIT, batch_pb, std::move(callback));
entry->unsafe_arena_release_commit();
- AsyncAppend(std::move(entry_batch));
- return Status::OK();
+ return AsyncAppend(std::move(entry_batch));
}
Status Log::WriteBatch(LogEntryBatch* entry_batch) {
@@ -1034,7 +1033,7 @@ Status Log::WaitUntilAllFlushed() {
Synchronizer s;
unique_ptr<LogEntryBatch> reserved_entry_batch =
CreateBatchFromPB(FLUSH_MARKER, entry_batch, s.AsStatusCallback());
- AsyncAppend(std::move(reserved_entry_batch));
+ RETURN_NOT_OK(AsyncAppend(std::move(reserved_entry_batch)));
return s.Wait();
}
diff --git a/src/kudu/consensus/log_anchor_registry.cc b/src/kudu/consensus/log_anchor_registry.cc
index 0a9ebfd6c..782c5a601 100644
--- a/src/kudu/consensus/log_anchor_registry.cc
+++ b/src/kudu/consensus/log_anchor_registry.cc
@@ -155,13 +155,14 @@ MinLogIndexAnchorer::~MinLogIndexAnchorer() {
CHECK_OK(ReleaseAnchor());
}
-void MinLogIndexAnchorer::AnchorIfMinimum(int64_t log_index) {
+Status MinLogIndexAnchorer::AnchorIfMinimum(int64_t log_index) {
std::lock_guard l(lock_);
if (log_index < minimum_log_index_ ||
PREDICT_FALSE(minimum_log_index_ == kInvalidOpIdIndex)) {
minimum_log_index_ = log_index;
- registry_->RegisterOrUpdate(minimum_log_index_, owner_, &anchor_);
+ return registry_->RegisterOrUpdate(minimum_log_index_, owner_, &anchor_);
}
+ return Status::OK();
}
Status MinLogIndexAnchorer::ReleaseAnchor() {
diff --git a/src/kudu/consensus/log_anchor_registry.h b/src/kudu/consensus/log_anchor_registry.h
index 6ccb40f1c..46e337767 100644
--- a/src/kudu/consensus/log_anchor_registry.h
+++ b/src/kudu/consensus/log_anchor_registry.h
@@ -135,7 +135,7 @@ class MinLogIndexAnchorer {
// If op_id is less than the minimum index registered so far, or if no indexes
// are currently registered, anchor on 'log_index'.
- void AnchorIfMinimum(int64_t log_index);
+ Status AnchorIfMinimum(int64_t log_index);
// Un-anchors the earliest index (which is the only one tracked).
// If no minimum is known (no anchor registered), returns OK.
diff --git a/src/kudu/consensus/log_cache-test.cc b/src/kudu/consensus/log_cache-test.cc
index 1292591a6..b0220dd62 100644
--- a/src/kudu/consensus/log_cache-test.cc
+++ b/src/kudu/consensus/log_cache-test.cc
@@ -105,7 +105,7 @@ class LogCacheTest : public KuduTest {
}
void TearDown() override {
- log_->WaitUntilAllFlushed();
+ ASSERT_OK(log_->WaitUntilAllFlushed());
}
void CloseAndReopenCache(const OpId& preceding_id) {
@@ -153,7 +153,7 @@ TEST_F(LogCacheTest, TestAppendAndGetMessages) {
ASSERT_OK(AppendReplicateMessagesToCache(1, 100));
ASSERT_EQ(100, cache_->metrics_.log_cache_num_ops->value());
ASSERT_GE(cache_->metrics_.log_cache_size->value(), 500);
- log_->WaitUntilAllFlushed();
+ ASSERT_OK(log_->WaitUntilAllFlushed());
vector<ReplicateRefPtr> messages;
OpId preceding;
@@ -197,7 +197,7 @@ TEST_F(LogCacheTest, TestAlwaysYieldsAtLeastOneMessage) {
// Append several large ops to the cache
ASSERT_OK(AppendReplicateMessagesToCache(1, 4, kPayloadSize));
- log_->WaitUntilAllFlushed();
+ ASSERT_OK(log_->WaitUntilAllFlushed());
// We should get one of them, even though we only ask for 100 bytes
vector<ReplicateRefPtr> messages;
@@ -218,7 +218,7 @@ TEST_F(LogCacheTest, TestAlwaysYieldsAtLeastOneMessage) {
TEST_F(LogCacheTest, TestCacheEdgeCases) {
// Append 1 message to the cache
ASSERT_OK(AppendReplicateMessagesToCache(1, 1));
- log_->WaitUntilAllFlushed();
+ ASSERT_OK(log_->WaitUntilAllFlushed());
std::vector<ReplicateRefPtr> messages;
OpId preceding;
@@ -263,7 +263,7 @@ TEST_F(LogCacheTest, TestMemoryLimit) {
const int kPayloadSize = 400 * 1024;
// Limit should not be violated.
ASSERT_OK(AppendReplicateMessagesToCache(1, 1, kPayloadSize));
- log_->WaitUntilAllFlushed();
+ ASSERT_OK(log_->WaitUntilAllFlushed());
ASSERT_EQ(1, cache_->num_cached_ops());
// Verify the size is right. It's not exactly kPayloadSize because of in-memory
@@ -274,7 +274,7 @@ TEST_F(LogCacheTest, TestMemoryLimit) {
// Add another operation which fits under the 1MB limit.
ASSERT_OK(AppendReplicateMessagesToCache(2, 1, kPayloadSize));
- log_->WaitUntilAllFlushed();
+ ASSERT_OK(log_->WaitUntilAllFlushed());
ASSERT_EQ(2, cache_->num_cached_ops());
int size_with_two_msgs = cache_->BytesUsed();
@@ -287,7 +287,7 @@ TEST_F(LogCacheTest, TestMemoryLimit) {
// Verify that we have trimmed by appending a message that would
// otherwise be rejected, since the cache max size limit is 2MB.
ASSERT_OK(AppendReplicateMessagesToCache(3, 1, kPayloadSize));
- log_->WaitUntilAllFlushed();
+ ASSERT_OK(log_->WaitUntilAllFlushed());
ASSERT_EQ(2, cache_->num_cached_ops());
ASSERT_EQ(size_with_two_msgs, cache_->BytesUsed());
@@ -318,7 +318,7 @@ TEST_F(LogCacheTest, TestGlobalMemoryLimit) {
// Should succeed, but only end up caching one of the two ops because of the global limit.
ASSERT_OK(AppendReplicateMessagesToCache(1, 2, kPayloadSize));
- log_->WaitUntilAllFlushed();
+ ASSERT_OK(log_->WaitUntilAllFlushed());
ASSERT_EQ(1, cache_->num_cached_ops());
ASSERT_LE(cache_->BytesUsed(), 1024 * 1024);
@@ -339,7 +339,7 @@ TEST_F(LogCacheTest, TestReplaceMessages) {
ASSERT_OK(AppendReplicateMessagesToCache(1, 1, kPayloadSize));
}
- log_->WaitUntilAllFlushed();
+ ASSERT_OK(log_->WaitUntilAllFlushed());
EXPECT_EQ(size_with_one_msg, tracker->consumption());
EXPECT_EQ(Substitute("Pinned index: 2, LogCacheStats(num_ops=1, bytes=$0)",
@@ -356,17 +356,17 @@ TEST_F(LogCacheTest, TestTruncation) {
};
// Append 1 through 3.
- AppendReplicateMessagesToCache(1, 3, 100);
+ ASSERT_OK(AppendReplicateMessagesToCache(1, 3, 100));
for (auto mode : {TRUNCATE_BY_APPEND, TRUNCATE_EXPLICITLY}) {
SCOPED_TRACE(mode == TRUNCATE_BY_APPEND ? "by append" : "explicitly");
// Append messages 4 through 10.
- AppendReplicateMessagesToCache(4, 7, 100);
+ ASSERT_OK(AppendReplicateMessagesToCache(4, 7, 100));
ASSERT_EQ(10, cache_->metrics_.log_cache_num_ops->value());
switch (mode) {
case TRUNCATE_BY_APPEND:
- AppendReplicateMessagesToCache(3, 1, 100);
+ ASSERT_OK(AppendReplicateMessagesToCache(3, 1, 100));
break;
case TRUNCATE_EXPLICITLY:
cache_->TruncateOpsAfter(3);
diff --git a/src/kudu/consensus/peer_manager.cc b/src/kudu/consensus/peer_manager.cc
index f09eb443d..be43243a9 100644
--- a/src/kudu/consensus/peer_manager.cc
+++ b/src/kudu/consensus/peer_manager.cc
@@ -89,14 +89,19 @@ void PeerManager::UpdateRaftConfig(const RaftConfigPB& config) {
void PeerManager::SignalRequest(bool force_if_queue_empty) {
std::lock_guard lock(lock_);
for (auto iter = peers_.begin(); iter != peers_.end();) {
- Status s = (*iter).second->SignalRequest(force_if_queue_empty);
- if (PREDICT_FALSE(!s.ok())) {
- LOG(WARNING) << GetLogPrefix()
- << "Peer was closed, removing from peers. Peer: "
- << SecureShortDebugString((*iter).second->peer_pb());
- peers_.erase(iter++);
- } else {
+ const auto s = iter->second->SignalRequest(force_if_queue_empty);
+ if (PREDICT_TRUE(s.ok())) {
++iter;
+ continue;
+ }
+ const auto& peer_info = SecureShortDebugString(iter->second->peer_pb());
+ if (!s.IsIllegalState()) {
+ WARN_NOT_OK(s, Substitute("$0: SignalRequest failed at peer $1",
+ GetLogPrefix(), peer_info));
+ } else {
+ WARN_NOT_OK(s, Substitute("$0: SignalRequest failed, removing peer $1",
+ GetLogPrefix(), peer_info));
+ peers_.erase(iter++);
}
}
}
diff --git a/src/kudu/consensus/pending_rounds.cc b/src/kudu/consensus/pending_rounds.cc
index 3e1c25302..984495550 100644
--- a/src/kudu/consensus/pending_rounds.cc
+++ b/src/kudu/consensus/pending_rounds.cc
@@ -21,6 +21,7 @@
#include <ostream>
#include <utility>
+#include <gflags/gflags.h>
#include <glog/logging.h>
#include "kudu/consensus/consensus.pb.h"
@@ -31,11 +32,18 @@
#include "kudu/gutil/port.h"
#include "kudu/gutil/strings/substitute.h"
#include "kudu/util/debug-util.h"
+#include "kudu/util/flag_tags.h"
#include "kudu/util/logging.h"
#include "kudu/util/pb_util.h"
#include "kudu/util/status.h"
#include "kudu/util/thread_restrictions.h"
+DEFINE_bool(raft_allow_committed_pending_index_gap, false,
+ "Allow a gap between last committed and first pending operation "
+ "in the queue when starting Raft consensus. For testing only!");
+TAG_FLAG(raft_allow_committed_pending_index_gap, runtime);
+TAG_FLAG(raft_allow_committed_pending_index_gap, unsafe);
+
using kudu::pb_util::SecureShortDebugString;
using std::string;
using strings::Substitute;
@@ -195,7 +203,8 @@ Status PendingRounds::SetInitialCommittedOpId(const OpId& committed_op) {
if (!pending_ops_.empty()) {
int64_t first_pending_index = pending_ops_.begin()->first;
if (committed_op.index() < first_pending_index) {
- if (committed_op.index() != first_pending_index - 1) {
+ if (PREDICT_TRUE(!FLAGS_raft_allow_committed_pending_index_gap) &&
+ committed_op.index() != first_pending_index - 1) {
return Status::Corruption(Substitute(
"pending operations should start at first operation "
"after the committed operation (committed=$0, first pending=$1)",
diff --git a/src/kudu/consensus/raft_consensus.cc b/src/kudu/consensus/raft_consensus.cc
index 5ec7aea89..0b65d2121 100644
--- a/src/kudu/consensus/raft_consensus.cc
+++ b/src/kudu/consensus/raft_consensus.cc
@@ -365,7 +365,7 @@ Status RaftConsensus::Start(const ConsensusBootstrapInfo& info,
// Set the initial committed opid for the PendingRounds only after
// appending any uncommitted replicate messages to the queue.
- pending_->SetInitialCommittedOpId(info.last_committed_id);
+ RETURN_NOT_OK(pending_->SetInitialCommittedOpId(info.last_committed_id));
// If this is the first term expire the FD immediately so that we have a
// fast first election, otherwise we just let the timer expire normally.
@@ -748,8 +748,11 @@ Status RaftConsensus::BecomeReplicaUnlocked(optional<MonoDelta> fd_delta) {
// Deregister ourselves from the queue. We no longer need to track what gets
// replicated since we're stepping down.
+ //
+ // NOTE: if observer isn't registered at this point yet, that's OK because
+ // in one of use cases Start() also invokes BecomeReplicaUnlocked()
queue_->UnRegisterObserver(this);
- bool was_leader = queue_->IsInLeaderMode();
+ const bool was_leader = queue_->IsInLeaderMode();
queue_->SetNonLeaderMode(cmeta_->ActiveConfig());
if (was_leader && server_ctx_.num_leaders) {
server_ctx_.num_leaders->IncrementBy(-1);
@@ -908,7 +911,7 @@ void RaftConsensus::NotifyCommitIndex(int64_t commit_index) {
return;
}
- pending_->AdvanceCommittedIndex(commit_index);
+ CHECK_OK(pending_->AdvanceCommittedIndex(commit_index));
if (cmeta_->active_role() == RaftPeerPB::LEADER) {
peer_manager_->SignalRequest(false);
@@ -2737,7 +2740,8 @@ void RaftConsensus::DoElectionCallback(ElectionReason reason, const ElectionResu
// will bump to term 2 when it gets the vote rejection, such that its
// next pre-election (for term 3) would succeed.
if (result.highest_voter_term > CurrentTermUnlocked()) {
- HandleTermAdvanceUnlocked(result.highest_voter_term);
+ WARN_NOT_OK(HandleTermAdvanceUnlocked(result.highest_voter_term),
+ "error while handling term advanced beyond the current one");
}
LOG_WITH_PREFIX_UNLOCKED(INFO)
diff --git a/src/kudu/consensus/raft_consensus_quorum-test.cc b/src/kudu/consensus/raft_consensus_quorum-test.cc
index ee613e1fd..14cdeb455 100644
--- a/src/kudu/consensus/raft_consensus_quorum-test.cc
+++ b/src/kudu/consensus/raft_consensus_quorum-test.cc
@@ -422,7 +422,7 @@ class RaftConsensusQuorumTest : public KuduTest {
ASSERT_OK(WaitForReplicate(round.get()));
last_op_id->CopyFrom(round->id());
if (commit_mode == COMMIT_ONE_BY_ONE) {
- CommitDummyMessage(leader_idx, round.get(), commit_sync);
+ ASSERT_OK(CommitDummyMessage(leader_idx, round.get(), commit_sync));
}
rounds->push_back(round);
}
@@ -445,7 +445,7 @@ class RaftConsensusQuorumTest : public KuduTest {
void GatherLogEntries(int idx, const scoped_refptr<Log>& log,
LogEntries* entries) {
ASSERT_OK(log->WaitUntilAllFlushed());
- log->Close();
+ ASSERT_OK(log->Close());
shared_ptr<LogReader> log_reader;
ASSERT_OK(log::LogReader::Open(fs_managers_[idx].get(),
/*index*/nullptr,
@@ -757,7 +757,7 @@ TEST_F(RaftConsensusQuorumTest, TestConsensusStopsIfAMajorityFallsBehind) {
// After we release the locks the operation should replicate to all replicas
// and we commit.
ASSERT_OK(WaitForReplicate(round.get()));
- CommitDummyMessage(kLeaderIdx, round.get());
+ ASSERT_OK(CommitDummyMessage(kLeaderIdx, round.get()));
// Assert that everything was ok
WaitForReplicateIfNotAlreadyPresent(last_op_id, kFollower0Idx);
diff --git a/src/kudu/consensus/time_manager-test.cc b/src/kudu/consensus/time_manager-test.cc
index da37c83c2..33c39b6bf 100644
--- a/src/kudu/consensus/time_manager-test.cc
+++ b/src/kudu/consensus/time_manager-test.cc
@@ -171,8 +171,8 @@ TEST_F(TimeManagerTest, TestTimeManagerLeaderMode) {
// In leader mode calling MessageReceivedFromLeader() should cause a CHECK failure.
EXPECT_DEATH({
- time_manager_->MessageReceivedFromLeader(message);
- }, "Cannot receive messages from a leader in leader mode.");
+ ASSERT_OK(time_manager_->MessageReceivedFromLeader(message));
+ }, "Cannot receive messages from a leader in leader mode.");
// .. as should AdvanceSafeTime()
EXPECT_DEATH({
diff --git a/src/kudu/integration-tests/ts_recovery-itest.cc b/src/kudu/integration-tests/ts_recovery-itest.cc
index 4f61cf391..51cd66880 100644
--- a/src/kudu/integration-tests/ts_recovery-itest.cc
+++ b/src/kudu/integration-tests/ts_recovery-itest.cc
@@ -571,7 +571,13 @@ INSTANTIATE_TEST_SUITE_P(BlockManagerType, TsRecoveryITestDeathTest,
TEST_P(TsRecoveryITestDeathTest, RecoverFromOpIdOverflow) {
// Create the initial tablet files on disk, then shut down the cluster so we
// can meddle with the WAL.
- NO_FATALS(StartClusterOneTs());
+ NO_FATALS(StartClusterOneTs(
+ // To simplify test scaffolding, this scenario relies on lenient handling
+ // of operation indices read from the tablet's WAL upon bootstrapping.
+ // With regular guards in place, an inconsistency would be detected when
+ // setting committed OpId for PendingRounds by RaftConsensus::Start().
+ { "--raft_allow_committed_pending_index_gap" }
+ ));
TestWorkload workload(cluster_.get());
workload.set_num_replicas(1);
workload.Setup();
(kudu) 04/05: [fs] fix result status handling
Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch branch-1.18.x
in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 82ab0ba37e5680003012849e6ff7800df82429c3
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Thu Feb 27 18:36:02 2025 -0800
[fs] fix result status handling
This patch addresses sloppy result handling of functions/methods
that return Status under the src/kudu/fs directory.
Change-Id: Ib2033dee550c144b57a2e97d74427b86bb45ebfe
Reviewed-on: http://gerrit.cloudera.org:8080/22663
Tested-by: Alexey Serbin <al...@apache.org>
Reviewed-by: Yifan Zhang <ch...@163.com>
(cherry picked from commit 7241bfb2532d80e66d61930e3da3306b5172cbe6)
Reviewed-on: http://gerrit.cloudera.org:8080/22754
Reviewed-by: Abhishek Chennaka <ac...@cloudera.com>
---
src/kudu/fs/block_manager-test.cc | 4 ++--
src/kudu/fs/default_key_provider.h | 2 +-
src/kudu/fs/file_block_manager.cc | 2 +-
src/kudu/fs/fs_manager-test.cc | 11 ++++++++---
src/kudu/fs/log_block_manager-test.cc | 16 ++++++++--------
5 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/src/kudu/fs/block_manager-test.cc b/src/kudu/fs/block_manager-test.cc
index c4968ff64..b01fe4a6e 100644
--- a/src/kudu/fs/block_manager-test.cc
+++ b/src/kudu/fs/block_manager-test.cc
@@ -657,8 +657,8 @@ TYPED_TEST(BlockManagerTest, CloseManyBlocksTest) {
for (int i = 0; i < sizeof(data); i += sizeof(uint32_t)) {
data[i] = rand.Next();
}
- written_block->Append(Slice(data, sizeof(data)));
- written_block->Finalize();
+ ASSERT_OK(written_block->Append(Slice(data, sizeof(data))));
+ ASSERT_OK(written_block->Finalize());
creation_transaction->AddCreatedBlock(std::move(written_block));
}
}
diff --git a/src/kudu/fs/default_key_provider.h b/src/kudu/fs/default_key_provider.h
index 807ede669..043403ce1 100644
--- a/src/kudu/fs/default_key_provider.h
+++ b/src/kudu/fs/default_key_provider.h
@@ -63,7 +63,7 @@ public:
OPENSSL_RET_NOT_OK(RAND_bytes(iv_bytes, num_bytes),
"Failed to generate random key");
strings::b2a_hex(iv_bytes, iv, num_bytes);
- DecryptEncryptionKey(dek, *iv, *key_version, encryption_key);
+ RETURN_NOT_OK(DecryptEncryptionKey(dek, *iv, *key_version, encryption_key));
*key_version = "encryptionkey@0";
return Status::OK();
}
diff --git a/src/kudu/fs/file_block_manager.cc b/src/kudu/fs/file_block_manager.cc
index f15bc716b..a6f30ed57 100644
--- a/src/kudu/fs/file_block_manager.cc
+++ b/src/kudu/fs/file_block_manager.cc
@@ -372,7 +372,7 @@ Status FileWritableBlock::Finalize() {
VLOG(3) << "Finalizing block " << id();
if (state_ == DIRTY &&
FLAGS_block_manager_preflush_control == "finalize") {
- FlushDataAsync();
+ RETURN_NOT_OK(FlushDataAsync());
}
state_ = FINALIZED;
return Status::OK();
diff --git a/src/kudu/fs/fs_manager-test.cc b/src/kudu/fs/fs_manager-test.cc
index b3c0cba71..277dcb14e 100644
--- a/src/kudu/fs/fs_manager-test.cc
+++ b/src/kudu/fs/fs_manager-test.cc
@@ -19,6 +19,7 @@
#include <sys/stat.h>
#include <unistd.h>
+// IWYU pragma: no_include <bits/struct_stat.h>
#include <cstdint>
#include <functional>
@@ -275,8 +276,12 @@ TEST_P(FsManagerTestBase, TestTenantAccountOperation) {
ASSERT_FALSE(fs_manager()->is_tenants_exist());
// Add tenant is not allowed.
- ASSERT_DEATH(fs_manager()->AddTenant(non_exist_tenant_name, non_exist_tenant,
- nullopt, nullopt, nullopt), "");
+ ASSERT_DEATH({ ASSERT_OK(fs_manager()->AddTenant(
+ non_exist_tenant_name,
+ non_exist_tenant,
+ nullopt,
+ nullopt,
+ nullopt)); }, "");
ASSERT_FALSE(fs_manager()->VertifyTenant(non_exist_tenant));
ASSERT_TRUE(fs_manager()->VertifyTenant(default_tenant_id));
ASSERT_EQ(0, fs_manager()->GetDataRootDirs(non_exist_tenant).size());
@@ -615,7 +620,7 @@ TEST_P(FsManagerTestBase, TestCreateWithFailedDirs) {
// Create some top-level paths to place roots in.
vector<string> data_paths = { GetTestPath("data1"), GetTestPath("data2"), GetTestPath("data3") };
for (const string& path : data_paths) {
- GetEnv()->CreateDir(path);
+ ASSERT_OK(GetEnv()->CreateDir(path));
}
// Initialize the FS layout with roots in subdirectories of data_paths. When
// we canonicalize paths, we canonicalize the dirname of each path (e.g.
diff --git a/src/kudu/fs/log_block_manager-test.cc b/src/kudu/fs/log_block_manager-test.cc
index a4ee00928..4b2e72b7f 100644
--- a/src/kudu/fs/log_block_manager-test.cc
+++ b/src/kudu/fs/log_block_manager-test.cc
@@ -475,7 +475,7 @@ TEST_P(LogBlockManagerTest, MetricsTest) {
for (int j = 0; j < sizeof(data); j += sizeof(uint32_t)) {
data[j] = rand.Next();
}
- b->Append(Slice(data, sizeof(data)));
+ ASSERT_OK(b->Append(Slice(data, sizeof(data))));
ASSERT_OK(b->Finalize());
transaction->AddCreatedBlock(std::move(b));
}
@@ -550,7 +550,7 @@ TEST_P(LogBlockManagerTest, MetricsTest) {
unique_ptr<WritableBlock> b;
ASSERT_OK(bm_->CreateBlock(test_block_opts_, &b));
blocks.emplace_back(b->id());
- b->Append("test data");
+ ASSERT_OK(b->Append("test data"));
ASSERT_OK(b->Finalize());
transaction->AddCreatedBlock(std::move(b));
}
@@ -2062,7 +2062,7 @@ TEST_P(LogBlockManagerTest, TestLIFOContainerSelection) {
for (int i = 0; i < 4; i++) {
unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(test_block_opts_, &writer));
- writer->Append("test data");
+ ASSERT_OK(writer->Append("test data"));
blocks.emplace_back(std::move(writer));
}
for (const auto& block : blocks) {
@@ -2078,7 +2078,7 @@ TEST_P(LogBlockManagerTest, TestLIFOContainerSelection) {
for (int i = 0; i < 4; i++) {
unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(test_block_opts_, &writer));
- writer->Append("test data");
+ ASSERT_OK(writer->Append("test data"));
ASSERT_OK(writer->Finalize());
// After finalizing the written block, the used container will be
// available again and can be reused for the following created block.
@@ -2207,7 +2207,7 @@ TEST_P(LogBlockManagerTest, TestDeleteDeadContainersByDeletionTransaction) {
{0, &METRIC_log_block_manager_dead_containers_deleted} }));
// After the reader is closed, the container is actually deleted.
- reader->Close();
+ ASSERT_OK(reader->Close());
NO_FATALS(CheckLogMetrics(entity,
{ {0, &METRIC_log_block_manager_bytes_under_management},
{0, &METRIC_log_block_manager_blocks_under_management},
@@ -2322,7 +2322,7 @@ TEST_P(LogBlockManagerNativeMetaTest, TestHalfPresentContainer) {
opts.is_sensitive = true;
ASSERT_OK(env_->NewWritableFile(opts, metadata_file_name, &metadata_file_writer));
ASSERT_OK(metadata_file_writer->Append(Slice("a")));
- metadata_file_writer->Close();
+ ASSERT_OK(metadata_file_writer->Close());
};
const auto CreateDataFile = [&] () {
@@ -2334,7 +2334,7 @@ TEST_P(LogBlockManagerNativeMetaTest, TestHalfPresentContainer) {
WritableFileOptions opts;
opts.is_sensitive = true;
ASSERT_OK(env_->NewWritableFile(opts, data_file_name, &data_file_writer));
- data_file_writer->Close();
+ ASSERT_OK(data_file_writer->Close());
};
const auto DeleteBlock = [&] () {
@@ -2597,7 +2597,7 @@ TEST_P(LogBlockManagerRdbMetaTest, TestHalfPresentContainer) {
WritableFileOptions opts;
opts.is_sensitive = true;
ASSERT_OK(env_->NewWritableFile(opts, data_file_name, &data_file_writer));
- data_file_writer->Close();
+ ASSERT_OK(data_file_writer->Close());
};
const auto DeleteBlock = [&] () {