Skip to content

Commit

Permalink
change log module
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 committed Jun 13, 2024
1 parent 37fa2bc commit 8e21034
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 64 deletions.
3 changes: 1 addition & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "6.4.15"

version = "6.4.16"
homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
topics = ("ebay", "nublox")
Expand Down
110 changes: 57 additions & 53 deletions src/include/homestore/btree/detail/simple_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,63 +225,67 @@ class SimpleNode : public VariantNode< K, V > {
}

std::string to_string_keys(bool print_friendly = false) const override {
std::string delimiter = print_friendly ? "\n" : "\t";
std::string snext = this->next_bnode() == empty_bnodeid ? "" : fmt::format("next_node={}", this->next_bnode());
auto str = fmt::format("{}{}.{} level:{} nEntries={} {} {} node_gen={} ",
print_friendly ? "------------------------------------------------------------\n" : "",
this->node_id(), this->link_version(), this->level(), this->total_entries(),
(this->is_leaf() ? "LEAF" : "INTERIOR"), snext, this->node_gen());
if (!this->is_leaf() && (this->has_valid_edge())) {
fmt::format_to(std::back_inserter(str), "edge_id={}.{}", this->edge_info().m_bnodeid,
this->edge_info().m_link_version);
}
if (this->total_entries() == 0) {
fmt::format_to(std::back_inserter(str), " [EMPTY] ");
return str;
}
if (!this->is_leaf()) {
fmt::format_to(std::back_inserter(str), " [");
for (uint32_t i{0}; i < this->total_entries(); ++i) {
uint32_t cur_key = BtreeNode::get_nth_key< K >(i, false).key();
BtreeLinkInfo child_info;
get_nth_value(i, &child_info, false /* copy */);
fmt::format_to(std::back_inserter(str), "{}.{} {}", cur_key, child_info.link_version(),
i == this->total_entries() - 1 ? "" : ", ");
// FIXME: Implement this, key may not be a unit32_t
return "";
#if 0
std::string delimiter = print_friendly ? "\n" : "\t";
std::string snext = this->next_bnode() == empty_bnodeid ? "" : fmt::format("next_node={}", this->next_bnode());
auto str = fmt::format("{}{}.{} level:{} nEntries={} {} {} node_gen={} ",
print_friendly ? "------------------------------------------------------------\n" : "",
this->node_id(), this->link_version(), this->level(), this->total_entries(),
(this->is_leaf() ? "LEAF" : "INTERIOR"), snext, this->node_gen());
if (!this->is_leaf() && (this->has_valid_edge())) {
fmt::format_to(std::back_inserter(str), "edge_id={}.{}", this->edge_info().m_bnodeid,
this->edge_info().m_link_version);
}
fmt::format_to(std::back_inserter(str), "]");
return str;
}
uint32_t prev_key = BtreeNode::get_nth_key< K >(0, false).key();
uint32_t cur_key = prev_key;
uint32_t last_key = BtreeNode::get_nth_key< K >(this->total_entries() - 1, false).key();
if (last_key - prev_key == this->total_entries() - 1) {
if (this->total_entries() == 1)
fmt::format_to(std::back_inserter(str), "{}[{}]", delimiter, prev_key);
else
fmt::format_to(std::back_inserter(str), "{}[{}-{}]", delimiter, prev_key, last_key);
return str;
}
fmt::format_to(std::back_inserter(str), "{}0 - [{}", delimiter, prev_key);
uint32_t start_interval_key = prev_key;
for (uint32_t i{1}; i < this->total_entries(); ++i) {
cur_key = BtreeNode::get_nth_key< K >(i, false).key();
if (cur_key != prev_key + 1) {
if (start_interval_key == prev_key) {
fmt::format_to(std::back_inserter(str), "-{}]{}{}- [{}", prev_key, delimiter, i, cur_key);
} else {
fmt::format_to(std::back_inserter(str), "]{}{}- [{}", delimiter, i, cur_key);
if (this->total_entries() == 0) {
fmt::format_to(std::back_inserter(str), " [EMPTY] ");
return str;
}
if (!this->is_leaf()) {
fmt::format_to(std::back_inserter(str), " [");
for (uint32_t i{0}; i < this->total_entries(); ++i) {
uint32_t cur_key = BtreeNode::get_nth_key< K >(i, false).key();
BtreeLinkInfo child_info;
get_nth_value(i, &child_info, false /* copy */);
fmt::format_to(std::back_inserter(str), "{}.{} {}", cur_key, child_info.link_version(),
i == this->total_entries() - 1 ? "" : ", ");
}
start_interval_key = cur_key;
fmt::format_to(std::back_inserter(str), "]");
return str;
}
uint32_t prev_key = BtreeNode::get_nth_key< K >(0, false).key();
uint32_t cur_key = prev_key;
uint32_t last_key = BtreeNode::get_nth_key< K >(this->total_entries() - 1, false).key();
if (last_key - prev_key == this->total_entries() - 1) {
if (this->total_entries() == 1)
fmt::format_to(std::back_inserter(str), "{}[{}]", delimiter, prev_key);
else
fmt::format_to(std::back_inserter(str), "{}[{}-{}]", delimiter, prev_key, last_key);
return str;
}
fmt::format_to(std::back_inserter(str), "{}0 - [{}", delimiter, prev_key);
uint32_t start_interval_key = prev_key;
for (uint32_t i{1}; i < this->total_entries(); ++i) {
cur_key = BtreeNode::get_nth_key< K >(i, false).key();
if (cur_key != prev_key + 1) {
if (start_interval_key == prev_key) {
fmt::format_to(std::back_inserter(str), "-{}]{}{}- [{}", prev_key, delimiter, i, cur_key);
} else {
fmt::format_to(std::back_inserter(str), "]{}{}- [{}", delimiter, i, cur_key);
}
start_interval_key = cur_key;
}
prev_key = cur_key;
}
prev_key = cur_key;
}

if (start_interval_key == prev_key) {
fmt::format_to(std::back_inserter(str), "]");
} else {
fmt::format_to(std::back_inserter(str), "-{}]", cur_key);
}
return str;
if (start_interval_key == prev_key) {
fmt::format_to(std::back_inserter(str), "]");
} else {
fmt::format_to(std::back_inserter(str), "-{}]", cur_key);
}
return str;
#endif
}

#ifndef NDEBUG
Expand Down
15 changes: 8 additions & 7 deletions src/include/homestore/index/index_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <homestore/index_service.hpp>
#include <homestore/checkpoint/cp_mgr.hpp>
#include <homestore/index/wb_cache_base.hpp>
#include <homestore/btree/detail/btree_internal.hpp>
#include <iomgr/iomgr_flip.hpp>

SISL_LOGGING_DECL(wbcache)
Expand Down Expand Up @@ -127,12 +128,12 @@ class IndexTable : public IndexTableBase, public Btree< K, V > {
auto prev_state = idx_node->m_idx_buf->m_state.exchange(index_buf_state_t::DIRTY);
if (prev_state == index_buf_state_t::CLEAN) {
// It was clean before, dirtying it first time, add it to the wb_cache list to flush
HS_DBG_ASSERT_EQ(idx_node->m_idx_buf->m_dirtied_cp_id, cp_ctx->id(),
BT_DBG_ASSERT_EQ(idx_node->m_idx_buf->m_dirtied_cp_id, cp_ctx->id(),
"Writing a node which was not acquired by this cp");
wb_cache().write_buf(node, idx_node->m_idx_buf, cp_ctx);
LOGTRACEMOD(wbcache, "add to dirty list cp {} {}", cp_ctx->id(), idx_node->m_idx_buf->to_string());
} else {
HS_DBG_ASSERT_NE(
BT_DBG_ASSERT_NE(
(int)prev_state, (int)index_buf_state_t::FLUSHING,
"Writing on a node buffer which was currently in flushing state on cur_cp={} buffer_cp_id={}",
cp_ctx->id(), idx_node->m_idx_buf->m_dirtied_cp_id)
Expand Down Expand Up @@ -211,7 +212,7 @@ class IndexTable : public IndexTableBase, public Btree< K, V > {
auto const last_parent_key = parent_node->get_last_key< K >();
auto const is_parent_edge_node = parent_node->has_valid_edge();
if ((parent_node->total_entries() == 0) && !is_parent_edge_node) {
HS_LOG_ASSERT(false, "Parent node={} is empty and not an edge node but was asked to repair",
BT_LOG_ASSERT(false, "Parent node={} is empty and not an edge node but was asked to repair",
parent_node->node_id());
return btree_status_t::not_found;
}
Expand All @@ -222,7 +223,7 @@ class IndexTable : public IndexTableBase, public Btree< K, V > {
auto ret = this->get_child_and_lock_node(parent_node, 0, child_info, child_node, locktype_t::READ,
locktype_t::READ, cp_ctx);
if (ret != btree_status_t::success) {
HS_LOG_ASSERT(false, "Parent node={} repair failed, because first child_node get has failed with ret={}",
BT_LOG_ASSERT(false, "Parent node={} repair failed, because first child_node get has failed with ret={}",
parent_node->node_id(), enum_name(ret));
return ret;
}
Expand All @@ -239,7 +240,7 @@ class IndexTable : public IndexTableBase, public Btree< K, V > {
BtreeNodeList new_parent_nodes;
do {
if (child_node->has_valid_edge()) {
HS_DBG_ASSERT(!is_parent_edge_node,
BT_DBG_ASSERT(!is_parent_edge_node,
"Child node={} is an edge node but parent_node={} is not an edge node",
child_node->node_id(), parent_node->node_id());
cur_parent->set_edge_value(BtreeLinkInfo{child_node->node_id(), child_node->link_version()});
Expand Down Expand Up @@ -277,7 +278,7 @@ class IndexTable : public IndexTableBase, public Btree< K, V > {
// Move to the next child node
auto const next_node_id = child_node->next_bnode();
if (next_node_id == empty_bnodeid) {
HS_LOG_ASSERT(
BT_LOG_ASSERT(
false,
"Child node={} next_node_id is empty, while its not a edge node, parent_node={} repair is partial",
child_node->node_id(), parent_node->node_id());
Expand All @@ -287,7 +288,7 @@ class IndexTable : public IndexTableBase, public Btree< K, V > {

ret = this->read_and_lock_node(next_node_id, child_node, locktype_t::READ, locktype_t::READ, cp_ctx);
if (ret != btree_status_t::success) {
HS_LOG_ASSERT(false, "Parent node={} repair is partial, because child_node get has failed with ret={}",
BT_LOG_ASSERT(false, "Parent node={} repair is partial, because child_node get has failed with ret={}",
parent_node->node_id(), enum_name(ret));
break;
}
Expand Down
6 changes: 4 additions & 2 deletions src/lib/device/device_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ shared< VirtualDev > DeviceManager::create_vdev(vdev_parameters&& vparam) {
auto total_type_size =
std::accumulate(pdevs.begin(), pdevs.end(), 0u, [](int r, const PhysicalDev* a) { return r + a->data_size(); });

LOGINFO("total size of type {} in this homestore is {}", vparam.dev_type, total_type_size)

uint32_t total_created_chunks{0};

for (auto& pdev : pdevs) {
Expand All @@ -321,8 +323,8 @@ shared< VirtualDev > DeviceManager::create_vdev(vdev_parameters&& vparam) {
auto total_chunk_num_in_pdev =
static_cast< uint32_t >(vparam.num_chunks * (pdev->data_size() / static_cast< float >(total_type_size)));

LOGINFO("{} chunks is created on pdev {} for vdev {}", total_chunk_num_in_pdev, pdev->get_devname(),
vparam.vdev_name)
LOGINFO("{} chunks is created on pdev {} for vdev {}, pdev data size is {}", total_chunk_num_in_pdev,
pdev->get_devname(), vparam.vdev_name, pdev->data_size());

// Create chunk ids for all chunks in each of these pdevs
for (uint32_t c{0}; c < total_chunk_num_in_pdev; ++c) {
Expand Down

0 comments on commit 8e21034

Please sign in to comment.