This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 8a6acff5c [master] fix mistake in status message for SOFT_DELETED
tables
8a6acff5c is described below
commit 8a6acff5cb63971eb803283ac33ec042055593a7
Author: Alexey Serbin <[email protected]>
AuthorDate: Fri Sep 22 10:59:52 2023 -0700
[master] fix mistake in status message for SOFT_DELETED tables
This fixes a mistake in generating status messages for tables
transitioning into the SOFT_DELETED state. The issue was pointed at
by the compiler with the following warnings:
src/kudu/master/catalog_manager.cc:6049:52: warning: adding 'bool' to a
string does not append to the string [-Wstring-plus-int]
string deletion_msg = "Table soft deleted at " +
~~~~~~~~~~~~~~~~~~~~~~~~~^
src/kudu/master/catalog_manager.cc:6050:71: warning: operator '?:' has
lower precedence than '+'; '+' will be evaluated first [-Wparentheses]
l.mutable_data()->pb.has_delete_timestamp() ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
I also took the liberty of brushing up the corresponding code, comments,
and messages a little bit.
Change-Id: If68032a6750f40698b64a00aea52e3b9ad389d85
Reviewed-on: http://gerrit.cloudera.org:8080/20502
Tested-by: Alexey Serbin <[email protected]>
Reviewed-by: Yingchun Lai <[email protected]>
---
src/kudu/master/catalog_manager.cc | 40 +++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/src/kudu/master/catalog_manager.cc
b/src/kudu/master/catalog_manager.cc
index 53007c7ef..ef0b3444f 100644
--- a/src/kudu/master/catalog_manager.cc
+++ b/src/kudu/master/catalog_manager.cc
@@ -2583,10 +2583,10 @@ Status CatalogManager::SoftDeleteTable(const
DeleteTableRequestPB& req,
resp, MasterErrorPB::TABLE_NOT_FOUND);
}
- TRACE("Soft delete modifying in-memory table state");
- string deletion_msg = "Table soft deleted at " + LocalTimeAsString();
+ TRACE("Modifying in-memory table state");
+ const auto state_msg = Substitute("table soft-deleted at $0",
LocalTimeAsString());
// soft delete state change
- l.mutable_data()->set_state(SysTablesEntryPB::SOFT_DELETED, deletion_msg);
+ l.mutable_data()->set_state(SysTablesEntryPB::SOFT_DELETED, state_msg);
l.mutable_data()->set_delete_timestamp(WallTime_Now());
uint32_t reserve_seconds = req.reserve_seconds() == 0 ?
FLAGS_default_deleted_table_reserve_seconds : req.reserve_seconds();
@@ -2603,7 +2603,7 @@ Status CatalogManager::SoftDeleteTable(const
DeleteTableRequestPB& req,
for (const auto& t : tablets) {
t->mutable_metadata()->mutable_dirty()->set_state(
- SysTabletsEntryPB::SOFT_DELETED, deletion_msg);
+ SysTabletsEntryPB::SOFT_DELETED, state_msg);
}
// 3. Update sys-catalog with the removed table and tablet state.
@@ -6038,22 +6038,26 @@ void CatalogManager::HandleTabletSchemaVersionReport(
// Update the state from altering and remove the last fully applied
// schema (if it exists).
+ //
// The final state depends on the state before the alteration. If the
- // alteration is for a soft-deleted table, the state will change to
- // 'SOFT_DELETED'. If the alteration is for a normal table, the state
- // will change to 'RUNNING'.
- l.mutable_data()->pb.clear_fully_applied_schema();
- // 'soft_deleted_reserved_seconds' is only exist for 'SOFT_DELETED' state.
- if (l.mutable_data()->pb.has_soft_deleted_reserved_seconds() &&
- l.mutable_data()->pb.soft_deleted_reserved_seconds() != UINT32_MAX) {
- string deletion_msg = "Table soft deleted at " +
- l.mutable_data()->pb.has_delete_timestamp() ?
-
std::to_string(l.mutable_data()->pb.delete_timestamp()) :
- LocalTimeAsString();
- l.mutable_data()->set_state(SysTablesEntryPB::SOFT_DELETED, deletion_msg);
+ // alteration is for a soft-deleted table, the state changes to
+ // 'SOFT_DELETED'. If the alteration is for a regular table, the state
changes
+ // to 'RUNNING'.
+ auto* st = l.mutable_data();
+ auto& pb = st->pb;
+ pb.clear_fully_applied_schema();
+ // The 'soft_deleted_reserved_seconds' field is present only for tables
+ // in the 'SOFT_DELETED' state.
+ if (pb.has_soft_deleted_reserved_seconds() &&
+ pb.soft_deleted_reserved_seconds() != UINT32_MAX) {
+ st->set_state(SysTablesEntryPB::SOFT_DELETED,
+ Substitute("table soft-deleted at $0",
+ pb.has_delete_timestamp()
+ ? std::to_string(pb.delete_timestamp())
+ : LocalTimeAsString()));
} else {
- l.mutable_data()->set_state(SysTablesEntryPB::RUNNING,
- Substitute("Current schema version=$0",
current_version));
+ st->set_state(SysTablesEntryPB::RUNNING,
+ Substitute("current schema version=$0", current_version));
}
{