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

refactor: move max_allowed_write_size to replication_common.h #417

Closed
Closed
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
9 changes: 9 additions & 0 deletions src/dist/replication/common/replication_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ replication_options::replication_options()
learn_app_max_concurrent_count = 5;

max_concurrent_uploading_file_count = 10;

max_allowed_write_size = 1 << 20;
}

replication_options::~replication_options() {}
Expand Down Expand Up @@ -512,6 +514,13 @@ void replication_options::initialize()
max_concurrent_uploading_file_count,
"concurrent uploading file count");

max_allowed_write_size = dsn_config_get_value_uint64("replication",
"max_allowed_write_size",
max_allowed_write_size,
"write operation exceed this "
"threshold will be logged and reject, "
"default is 1MB, 0 means no check");

replica_helper::load_meta_servers(meta_servers);

sanity_check();
Expand Down
4 changes: 4 additions & 0 deletions src/dist/replication/common/replication_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ class replication_options
std::string cold_backup_root;
int32_t max_concurrent_uploading_file_count;

// write body size exceed this threshold will be logged and reject, 0 means no check, default
// 1MB
uint64_t max_allowed_write_size;

public:
replication_options();
void initialize();
Expand Down
6 changes: 3 additions & 3 deletions src/dist/replication/lib/replica_2pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ void replica::on_client_write(dsn::message_ex *request, bool ignore_throttling)
return;
}

if (dsn_unlikely(_stub->_max_allowed_write_size &&
request->body_size() > _stub->_max_allowed_write_size)) {
if (dsn_unlikely(_options->max_allowed_write_size &&
request->body_size() > _options->max_allowed_write_size)) {
dwarn_replica("client from {} write request body size exceed threshold, request_body_size "
"= {}, max_allowed_write_size = {}, it will be rejected!",
request->header->from_address.to_string(),
request->body_size(),
_stub->_max_allowed_write_size);
_options->max_allowed_write_size);
_stub->_counter_recent_write_size_exceed_threshold_count->increment();
response_client_write(request, ERR_INVALID_DATA);
return;
Expand Down
7 changes: 0 additions & 7 deletions src/dist/replication/lib/replica_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ replica_stub::replica_stub(replica_state_subscriber subscriber /*= nullptr*/,
_log = nullptr;
_primary_address_str[0] = '\0';
install_perf_counters();

_max_allowed_write_size = dsn_config_get_value_uint64("replication",
"max_allowed_write_size",
1 << 20,
"write operation exceed this "
"threshold will be logged and reject, "
"default is 1MB, 0 means no check");
}

replica_stub::~replica_stub(void) { close(); }
Expand Down
3 changes: 0 additions & 3 deletions src/dist/replication/lib/replica_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,6 @@ class replica_stub : public serverlet<replica_stub>, public ref_counter
// cli service
std::unique_ptr<dsn::cli_service> _cli_service;

// write body size exceed this threshold will be logged and reject, 0 means no check
uint64_t _max_allowed_write_size;

// performance counters
perf_counter_wrapper _counter_replicas_count;
perf_counter_wrapper _counter_replicas_opening_count;
Expand Down