Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSAN error for send_node_id_handshake test #2060

Merged
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -260,47 +260,50 @@ void nano::stat::update (uint32_t key_a, uint64_t value)
auto now (std::chrono::steady_clock::now ());

std::unique_lock<std::mutex> lock (stat_mutex);
auto entry (get_entry_impl (key_a, config.interval, config.capacity));

// Counters
auto old (entry->counter.get_value ());
entry->counter.add (value);
entry->count_observers.notify (old, entry->counter.get_value ());

std::chrono::duration<double, std::milli> duration = now - log_last_count_writeout;
if (config.log_interval_counters > 0 && duration.count () > config.log_interval_counters)
if (!stopped)
{
log_counters_impl (log_count);
log_last_count_writeout = now;
}
auto entry (get_entry_impl (key_a, config.interval, config.capacity));

// Samples
if (config.sampling_enabled && entry->sample_interval > 0)
{
entry->sample_current.add (value, false);
// Counters
auto old (entry->counter.get_value ());
entry->counter.add (value);
entry->count_observers.notify (old, entry->counter.get_value ());

std::chrono::duration<double, std::milli> duration = now - entry->sample_start_time;
if (duration.count () > entry->sample_interval)
std::chrono::duration<double, std::milli> duration = now - log_last_count_writeout;
if (config.log_interval_counters > 0 && duration.count () > config.log_interval_counters)
{
entry->sample_start_time = now;

// Make a snapshot of samples for thread safety and to get a stable container
entry->sample_current.set_timestamp (std::chrono::system_clock::now ());
entry->samples.push_back (entry->sample_current);
entry->sample_current.set_value (0);
log_counters_impl (log_count);
log_last_count_writeout = now;
}

if (!entry->sample_observers.observers.empty ())
{
auto snapshot (entry->samples);
entry->sample_observers.notify (snapshot);
}
// Samples
if (config.sampling_enabled && entry->sample_interval > 0)
{
entry->sample_current.add (value, false);

// Log sink
duration = now - log_last_sample_writeout;
if (config.log_interval_samples > 0 && duration.count () > config.log_interval_samples)
std::chrono::duration<double, std::milli> duration = now - entry->sample_start_time;
if (duration.count () > entry->sample_interval)
{
log_samples_impl (log_sample);
log_last_sample_writeout = now;
entry->sample_start_time = now;

// Make a snapshot of samples for thread safety and to get a stable container
entry->sample_current.set_timestamp (std::chrono::system_clock::now ());
entry->samples.push_back (entry->sample_current);
entry->sample_current.set_value (0);

if (!entry->sample_observers.observers.empty ())
{
auto snapshot (entry->samples);
entry->sample_observers.notify (snapshot);
}

// Log sink
duration = now - log_last_sample_writeout;
if (config.log_interval_samples > 0 && duration.count () > config.log_interval_samples)
{
log_samples_impl (log_sample);
log_last_sample_writeout = now;
}
}
}
}
@@ -313,6 +316,12 @@ std::chrono::seconds nano::stat::last_reset ()
return std::chrono::duration_cast<std::chrono::seconds> (now - timestamp);
}

void nano::stat::stop ()
{
std::lock_guard<std::mutex> guard (stat_mutex);
stopped = true;
}

void nano::stat::clear ()
{
std::unique_lock<std::mutex> lock (stat_mutex);
@@ -456,6 +456,9 @@ class stat final
/** Returns a new JSON log sink */
std::unique_ptr<stat_log_sink> log_sink_json () const;

/** Stop stats being output */
void stop ();

private:
static std::string type_to_string (uint32_t key);
static std::string detail_to_string (uint32_t key);
@@ -500,6 +503,9 @@ class stat final
std::chrono::steady_clock::time_point log_last_count_writeout{ std::chrono::steady_clock::now () };
std::chrono::steady_clock::time_point log_last_sample_writeout{ std::chrono::steady_clock::now () };

/** Whether stats should be output */
bool stopped{ false };

/** All access to stat is thread safe, including calls from observers on the same thread */
std::mutex stat_mutex;
};
@@ -197,6 +197,7 @@ node (init_a, io_ctx_a, application_path_a, alarm_a, nano::node_config (peering_
nano::node::node (nano::node_init & init_a, boost::asio::io_context & io_ctx_a, boost::filesystem::path const & application_path_a, nano::alarm & alarm_a, nano::node_config const & config_a, nano::work_pool & work_a, nano::node_flags flags_a, bool delay_frontier_confirmation_height_updating) :
io_ctx (io_ctx_a),
config (config_a),
stats (config.stat_config),
flags (flags_a),
alarm (alarm_a),
work (work_a),
@@ -222,7 +223,6 @@ block_processor_thread ([this]() {
this->block_processor.process_blocks ();
}),
online_reps (*this, config.online_weight_minimum.number ()),
stats (config.stat_config),
vote_uniquer (block_uniquer),
active (*this, delay_frontier_confirmation_height_updating),
confirmation_height_processor (pending_confirmation_height, store, ledger.stats, active, ledger.epoch_link, logger),
@@ -826,6 +826,7 @@ void nano::node::stop ()
port_mapping.stop ();
checker.stop ();
wallets.stop ();
stats.stop ();
}
}

@@ -210,6 +210,7 @@ class node final : public std::enable_shared_from_this<nano::node>
boost::latch node_initialized_latch;
nano::network_params network_params;
nano::node_config config;
nano::stat stats;
std::shared_ptr<nano::websocket::listener> websocket_server;
nano::node_flags flags;
nano::alarm & alarm;
@@ -236,7 +237,6 @@ class node final : public std::enable_shared_from_this<nano::node>
nano::block_arrival block_arrival;
nano::online_reps online_reps;
nano::votes_cache votes_cache;
nano::stat stats;
nano::keypair node_id;
nano::block_uniquer block_uniquer;
nano::vote_uniquer vote_uniquer;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.