-
Notifications
You must be signed in to change notification settings - Fork 312
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
feat: support to force send non-idempotent write when doing duplication #1908
Open
ninsmiracle
wants to merge
28
commits into
apache:master
Choose a base branch
from
ninsmiracle:support_no_idempotent_dup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
e60dc0a
support_no_idempotent_dup
31a4271
format and IWYU
61b446f
add two matric and type key if dup non-idempotent write retried
0d1152d
deal with conflict
0db1a56
pull
cef197a
small fix
a4f510a
PASS IWYU
538090b
format code
c5e39ca
Update src/common/duplication_common.cpp
ninsmiracle 11c013f
Merge branch 'apache:master' into support_no_idempotent_dup
ninsmiracle b521752
fix by github comment
0e19a01
format code
e827c78
pass IWYU
bb56598
pass IWYU2
3d0694f
Update src/server/pegasus_mutation_duplicator.cpp
ninsmiracle 7833e8c
fix by comment and format
95953ac
Merge branch 'support_no_idempotent_dup' of github.com:ninsmiracle/in…
d8e26b1
make comment in code more clearly
3831f7a
make function name better
01fa7af
fix type_force_send_non_idempotent_if_need
c400ef7
Update src/common/duplication_common.cpp
ninsmiracle 8dc378f
move DSN_DECLARE in duplication common
fcaabfe
move dup_unsafe_received_non_idempotent_duplicate_request discription…
cc853e7
pass IWYU
5d35724
Update src/server/pegasus_mutation_duplicator.cpp
ninsmiracle 76faaa7
Update src/server/pegasus_mutation_duplicator.cpp
ninsmiracle 2f90f2e
Update src/server/pegasus_mutation_duplicator.cpp
ninsmiracle 884aabe
Merge branch 'master' into support_no_idempotent_dup
ninsmiracle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,14 @@ METRIC_DEFINE_counter(replica, | |
dsn::metric_unit::kRequests, | ||
"The number of DUPLICATE requests"); | ||
|
||
METRIC_DEFINE_counter(replica, | ||
dup_unsafe_received_non_idempotent_duplicate_request, | ||
dsn::metric_unit::kRequests, | ||
"receive non-idempotent request from master cluster via duplication when " | ||
"FLAG_duplication_unsafe_allow_non_idempotent set as true." | ||
"This metric greater than zero means that there is already the possibility " | ||
"of inconsistency between clusters."); | ||
|
||
METRIC_DEFINE_percentile_int64(replica, | ||
dup_time_lag_ms, | ||
dsn::metric_unit::kMilliSeconds, | ||
|
@@ -168,6 +176,7 @@ pegasus_write_service::pegasus_write_service(pegasus_server_impl *server) | |
METRIC_VAR_INIT_replica(check_and_set_latency_ns), | ||
METRIC_VAR_INIT_replica(check_and_mutate_latency_ns), | ||
METRIC_VAR_INIT_replica(dup_requests), | ||
METRIC_VAR_INIT_replica(dup_unsafe_received_non_idempotent_duplicate_request), | ||
METRIC_VAR_INIT_replica(dup_time_lag_ms), | ||
METRIC_VAR_INIT_replica(dup_lagging_writes), | ||
_put_batch_size(0), | ||
|
@@ -415,6 +424,41 @@ int pegasus_write_service::duplicate(int64_t decree, | |
} | ||
continue; | ||
} | ||
|
||
// Parse non-idempotent writes via duplication | ||
if (request.task_code == dsn::apps::RPC_RRDB_RRDB_INCR || | ||
request.task_code == dsn::apps::RPC_RRDB_RRDB_CHECK_AND_SET || | ||
request.task_code == dsn::apps::RPC_RRDB_RRDB_CHECK_AND_MUTATE) { | ||
|
||
METRIC_VAR_INCREMENT(dup_unsafe_received_non_idempotent_duplicate_request); | ||
|
||
if (request.task_code == dsn::apps::RPC_RRDB_RRDB_INCR) { | ||
incr_rpc rpc(write); | ||
resp.__set_error(_impl->incr(ctx.decree, rpc.request(), rpc.response())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add some comments to describe what's you aim here. |
||
if (resp.error != rocksdb::Status::kOk) { | ||
return resp.error; | ||
} | ||
continue; | ||
} | ||
if (request.task_code == dsn::apps::RPC_RRDB_RRDB_CHECK_AND_SET) { | ||
check_and_set_rpc rpc(write); | ||
resp.__set_error(_impl->check_and_set(ctx.decree, rpc.request(), rpc.response())); | ||
if (resp.error != rocksdb::Status::kOk) { | ||
return resp.error; | ||
} | ||
continue; | ||
} | ||
if (request.task_code == dsn::apps::RPC_RRDB_RRDB_CHECK_AND_MUTATE) { | ||
check_and_mutate_rpc rpc(write); | ||
resp.__set_error( | ||
_impl->check_and_mutate(ctx.decree, rpc.request(), rpc.response())); | ||
if (resp.error != rocksdb::Status::kOk) { | ||
return resp.error; | ||
} | ||
continue; | ||
} | ||
} | ||
|
||
resp.__set_error(rocksdb::Status::kInvalidArgument); | ||
resp.__set_error_hint(fmt::format("unrecognized task code {}", request.task_code)); | ||
return empty_put(ctx.decree); | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the non-idempotent request be retried twice here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,it will. So I record specific
raw_key
into log.