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

refactor: change large write size request forbiden log #458

Merged
merged 20 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from 10 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
3 changes: 3 additions & 0 deletions include/dsn/dist/replication/replication_app_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ class replication_app_base : public replica_base
// Thread-safe.
virtual void set_partition_version(int32_t partition_version){};

// log for the large write size request
virtual void dwarn_write_request(dsn::message_ex *request, uint64_t max_allowed_write_size);
foreverneverer marked this conversation as resolved.
Show resolved Hide resolved

public:
//
// utility functions to be used by app
Expand Down
6 changes: 1 addition & 5 deletions src/dist/replication/lib/replica_2pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ void replica::on_client_write(dsn::message_ex *request, bool ignore_throttling)

if (dsn_unlikely(_stub->_max_allowed_write_size &&
request->body_size() > _stub->_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);
_app->dwarn_write_request(request, _stub->_max_allowed_write_size);
_stub->_counter_recent_write_size_exceed_threshold_count->increment();
response_client_write(request, ERR_INVALID_DATA);
return;
Expand Down
12 changes: 12 additions & 0 deletions src/dist/replication/lib/replication_app_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <sstream>
#include <memory>
#include <dsn/utility/fail_point.h>
#include <dsn/dist/fmt_logging.h>

namespace dsn {
namespace replication {
Expand Down Expand Up @@ -581,5 +582,16 @@ ::dsn::error_code replication_app_base::update_init_info_ballot_and_decree(repli
_info.init_offset_in_private_log,
r->last_durable_decree());
}

void replication_app_base::dwarn_write_request(dsn::message_ex *request,
uint64_t 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(),
max_allowed_write_size);
}

} // namespace replication
} // namespace dsn