Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

feat(update_replication_factor#7): replace cluster-level max_replicas_in_group with max_replica_count of each replica #1109

Merged
Merged
Changes from 1 commit
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
Next Next commit
feat(update_replication_factor#7): replace cluster-level max_replicas…
…_in_group with max_replica_count of each replica
  • Loading branch information
empiredan committed May 20, 2022
commit cbeb9111da648ca9260df39e6bc0e821ed4f4ed5
10 changes: 9 additions & 1 deletion src/meta/meta_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,19 @@

#include <dsn/dist/fmt_logging.h>
#include <dsn/service_api_cpp.h>
#include <dsn/utility/flags.h>

#include "meta_data.h"

namespace dsn {
namespace replication {

DSN_DEFINE_uint32("meta_server",
max_reserved_number_of_dropped_replicas,
1,
"max reserved number allowed for dropped replicas");
DSN_TAG_VARIABLE(max_reserved_number_of_dropped_replicas, FT_MUTABLE);

void when_update_replicas(config_type::type t, const std::function<void(bool)> &func)
{
switch (t) {
Expand Down Expand Up @@ -301,7 +308,8 @@ void config_context::check_size()
{
// when add learner, it is possible that replica_count > max_replica_count, so we
// need to remove things from dropped only when it's not empty.
while (replica_count(*config_owner) + dropped.size() > MAX_REPLICA_COUNT_IN_GRROUP &&
while (replica_count(*config_owner) + dropped.size() >
config_owner->max_replica_count + FLAGS_max_reserved_number_of_dropped_replicas &&
!dropped.empty()) {
dropped.erase(dropped.begin());
prefered_dropped = (int)dropped.size() - 1;
Expand Down