Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/replica/duplication/replica_duplicator_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,14 @@ replica_duplicator_manager::get_duplication_confirms_to_update() const

void replica_duplicator_manager::sync_duplication(const duplication_entry &ent)
{
zauto_lock l(_lock);
auto it = ent.progress.find(get_gpid().get_partition_index());
if (it == ent.progress.end()) {
// Inconsistent with the meta server.
_duplications.erase(ent.dupid);
return;
}

zauto_lock l(_lock);

dupid_t dupid = ent.dupid;
duplication_status::type next_status = ent.status;

Expand Down Expand Up @@ -183,7 +182,6 @@ void replica_duplicator_manager::update_confirmed_decree_if_secondary(decree con
return;
}

zauto_lock l(_lock);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does _primary_confirmed_decree below no longer need protection by _lock?

remove_all_duplications();
if (confirmed >= 0) { // duplication ongoing
// confirmed decree never decreases
Expand All @@ -197,7 +195,8 @@ void replica_duplicator_manager::update_confirmed_decree_if_secondary(decree con

void replica_duplicator_manager::METRIC_FUNC_NAME_SET(dup_pending_mutations)()
{
int64_t total = 0;
zauto_lock l(_lock);
uint64_t total = 0;
for (const auto &dup : _duplications) {
total += dup.second->get_pending_mutations_count();
}
Expand Down Expand Up @@ -227,6 +226,7 @@ replica_duplicator_manager::get_dup_states() const

void replica_duplicator_manager::remove_all_duplications()
{
zauto_lock l(_lock);
// fast path
if (_duplications.empty()) {
return;
Expand Down
15 changes: 12 additions & 3 deletions src/task/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "utils/fmt_logging.h"
#include "utils/join_point.h"
#include "utils/ports.h"
#include "utils/synchronize.h"
#include "utils/utils.h"

namespace dsn {
Expand Down Expand Up @@ -329,6 +330,11 @@ class raw_task : public task
: task(code, hash, node), _cb(std::move(cb))
{
}
~raw_task() override
{
::dsn::utils::auto_lock<::dsn::utils::ex_lock_nr> l(_lock);
_cb = nullptr;
}

void exec() override
{
Expand All @@ -338,10 +344,13 @@ class raw_task : public task
}

protected:
void clear_non_trivial_on_task_end() override { _cb = nullptr; }

protected:
void clear_non_trivial_on_task_end() override
{
::dsn::utils::auto_lock<::dsn::utils::ex_lock_nr> l(_lock);
_cb = nullptr;
}
task_handler _cb;
::dsn::utils::ex_lock_nr _lock;
};

//----------------- timer task -------------------------------------------------------
Expand Down
Loading