Skip to content

Commit

Permalink
KUDU-745 / KUDU-1463 tablet's table id attribute is empty string
Browse files Browse the repository at this point in the history
This fixes the issue where the table_id attribute of a tablet
in /metrics was an empty string.

As part of this patch, I also ended up picking a couple of magic
table_id's. The significant one is that the table_id of sys.catalog
is "sys.catalog.id".

Change-Id: I1795a176312f6c2a55c34b7b684ee408f1cf8732
Reviewed-on: http://gerrit.cloudera.org:8080/3183
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <[email protected]>
  • Loading branch information
wdberkeley authored and toddlipcon committed May 25, 2016
1 parent 57c4b47 commit c11b8cf
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/kudu/consensus/log-test-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ using tablet::OperationResultPB;
using tablet::MemStoreTargetPB;

const char* kTestTable = "test-log-table";
const char* kTestTableId = "test-log-table-id";
const char* kTestTablet = "test-log-tablet";
const bool APPEND_SYNC = true;
const bool APPEND_ASYNC = false;
Expand Down
1 change: 1 addition & 0 deletions src/kudu/master/sys_catalog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ Status SysCatalogTable::CreateNew(FsManager *fs_manager) {
RETURN_NOT_OK(tablet::TabletMetadata::CreateNew(fs_manager,
kSysCatalogTabletId,
table_name(),
table_id(),
schema, partition_schema,
partitions[0],
tablet::TABLET_DATA_READY,
Expand Down
1 change: 1 addition & 0 deletions src/kudu/master/sys_catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class SysCatalogTable {
friend class CatalogManager;

const char *table_name() const { return "sys.catalog"; }
const char *table_id() const { return "sys.catalog.id"; }

// Return the schema of the table.
// NOTE: This is the "server-side" schema, so it must have the column IDs.
Expand Down
1 change: 1 addition & 0 deletions src/kudu/tablet/tablet-harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class TabletHarness {
RETURN_NOT_OK(TabletMetadata::LoadOrCreate(fs_manager_.get(),
options_.tablet_id,
"KuduTableTest",
"KuduTableTestId",
schema_,
partition.first,
partition.second,
Expand Down
1 change: 1 addition & 0 deletions src/kudu/tablet/tablet_bootstrap-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class BootstrapTest : public LogTestBase {
RETURN_NOT_OK(TabletMetadata::LoadOrCreate(fs_manager_.get(),
log::kTestTablet,
log::kTestTable,
log::kTestTableId,
schema,
partition.first,
partition.second,
Expand Down
10 changes: 7 additions & 3 deletions src/kudu/tablet/tablet_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const int64 kNoDurableMemStore = -1;
Status TabletMetadata::CreateNew(FsManager* fs_manager,
const string& tablet_id,
const string& table_name,
const string& table_id,
const Schema& schema,
const PartitionSchema& partition_schema,
const Partition& partition,
Expand All @@ -83,6 +84,7 @@ Status TabletMetadata::CreateNew(FsManager* fs_manager,
scoped_refptr<TabletMetadata> ret(new TabletMetadata(fs_manager,
tablet_id,
table_name,
table_id,
schema,
partition_schema,
partition,
Expand All @@ -104,6 +106,7 @@ Status TabletMetadata::Load(FsManager* fs_manager,
Status TabletMetadata::LoadOrCreate(FsManager* fs_manager,
const string& tablet_id,
const string& table_name,
const string& table_id,
const Schema& schema,
const PartitionSchema& partition_schema,
const Partition& partition,
Expand All @@ -118,7 +121,7 @@ Status TabletMetadata::LoadOrCreate(FsManager* fs_manager,
}
return Status::OK();
} else if (s.IsNotFound()) {
return CreateNew(fs_manager, tablet_id, table_name, schema,
return CreateNew(fs_manager, tablet_id, table_name, table_id, schema,
partition_schema, partition, initial_tablet_data_state,
metadata);
} else {
Expand Down Expand Up @@ -207,8 +210,8 @@ Status TabletMetadata::DeleteSuperBlock() {
}

TabletMetadata::TabletMetadata(FsManager* fs_manager, string tablet_id,
string table_name, const Schema& schema,
PartitionSchema partition_schema,
string table_name, string table_id,
const Schema& schema, PartitionSchema partition_schema,
Partition partition,
const TabletDataState& tablet_data_state)
: state_(kNotWrittenYet),
Expand All @@ -219,6 +222,7 @@ TabletMetadata::TabletMetadata(FsManager* fs_manager, string tablet_id,
last_durable_mrs_id_(kNoDurableMemStore),
schema_(new Schema(schema)),
schema_version_(0),
table_id_(std::move(table_id)),
table_name_(std::move(table_name)),
partition_schema_(std::move(partition_schema)),
tablet_data_state_(tablet_data_state),
Expand Down
7 changes: 5 additions & 2 deletions src/kudu/tablet/tablet_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class TabletMetadata : public RefCountedThreadSafe<TabletMetadata> {
static Status CreateNew(FsManager* fs_manager,
const std::string& tablet_id,
const std::string& table_name,
const std::string& table_id,
const Schema& schema,
const PartitionSchema& partition_schema,
const Partition& partition,
Expand All @@ -84,6 +85,7 @@ class TabletMetadata : public RefCountedThreadSafe<TabletMetadata> {
static Status LoadOrCreate(FsManager* fs_manager,
const std::string& tablet_id,
const std::string& table_name,
const std::string& table_id,
const Schema& schema,
const PartitionSchema& partition_schema,
const Partition& partition,
Expand Down Expand Up @@ -233,8 +235,9 @@ class TabletMetadata : public RefCountedThreadSafe<TabletMetadata> {
// TODO: get rid of this many-arg constructor in favor of just passing in a
// SuperBlock, which already contains all of these fields.
TabletMetadata(FsManager* fs_manager, std::string tablet_id,
std::string table_name, const Schema& schema,
PartitionSchema partition_schema, Partition partition,
std::string table_name, std::string table_id,
const Schema& schema, PartitionSchema partition_schema,
Partition partition,
const TabletDataState& tablet_data_state);

// Constructor for loading an existing tablet.
Expand Down
1 change: 1 addition & 0 deletions src/kudu/tserver/remote_bootstrap_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ Status RemoteBootstrapClient::Start(const string& bootstrap_peer_uuid,
// Create the superblock on disk.
RETURN_NOT_OK(TabletMetadata::CreateNew(fs_manager_, tablet_id_,
superblock_->table_name(),
superblock_->table_id(),
schema,
partition_schema,
partition,
Expand Down
1 change: 1 addition & 0 deletions src/kudu/tserver/tablet_server-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ TEST_F(TabletServerTest, TestWebPages) {

// Check entity attributes.
ASSERT_STR_CONTAINS(buf.ToString(), "\"table_name\": \"TestTable\"");
ASSERT_STR_CONTAINS(buf.ToString(), "\"table_id\": \"TestTable\"");

// Check for the existence of some particular metrics for which we've had early-retirement
// bugs in the past.
Expand Down
1 change: 1 addition & 0 deletions src/kudu/tserver/ts_tablet_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ Status TSTabletManager::CreateNewTablet(const string& table_id,
TabletMetadata::CreateNew(fs_manager_,
tablet_id,
table_name,
table_id,
schema,
partition_schema,
partition,
Expand Down

0 comments on commit c11b8cf

Please sign in to comment.