Skip to content

Commit

Permalink
Add some debug logging around ship log and mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Apr 3, 2024
1 parent cc56c51 commit a200db1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions libraries/state_history/include/eosio/state_history/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ struct locked_decompress_stream {
locked_decompress_stream(locked_decompress_stream&&) = default;

explicit locked_decompress_stream(std::unique_lock<std::mutex> l)
: lock(std::move(l)) {};
: lock(std::move(l)) {
dlog("locked");
};

~locked_decompress_stream() {
dlog("unlocking");
}

template <typename StateHistoryLog>
void init(StateHistoryLog&& log, fc::cfile& stream, uint64_t compressed_size) {
Expand Down Expand Up @@ -388,6 +394,7 @@ class state_history_log {
}

locked_decompress_stream create_locked_decompress_stream() {
dlog("locking");
return locked_decompress_stream{ std::unique_lock<std::mutex>( _mx ) };
}

Expand All @@ -412,7 +419,9 @@ class state_history_log {

template <typename F>
void pack_and_write_entry(state_history_log_header header, const chain::block_id_type& prev_id, F&& pack_to) {
dlog("locking"); {
std::lock_guard g(_mx);
dlog("locked");
write_entry(header, prev_id, [&, pack_to = std::forward<F>(pack_to)](auto& stream) {
size_t payload_pos = stream.tellp();

Expand Down Expand Up @@ -454,7 +463,9 @@ class state_history_log {
// make sure we reset the file position to end_payload_pos to preserve API behavior
stream.seek(end_payload_pos);
});
}
}
dlog("unlocked");
}

std::optional<chain::block_id_type> get_block_id(uint32_t block_num) {
std::lock_guard g(_mx);
Expand Down
2 changes: 2 additions & 0 deletions plugins/state_history_plugin/state_history_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,11 @@ struct state_history_plugin_impl : std::enable_shared_from_this<state_history_pl
update_current();

try {
dlog("writing to ship logs");
store_traces(block, id);
store_chain_state(id, block->previous, block->block_num());
store_finality_data(id, block->previous);
dlog("done writing to ship logs");
} catch (const fc::exception& e) {
fc_elog(_log, "fc::exception: ${details}", ("details", e.to_detail_string()));
// Both app().quit() and exception throwing are required. Without app().quit(),
Expand Down

0 comments on commit a200db1

Please sign in to comment.