Comments (8)
From NuRaft's point of view, appending multiple logs doesn't need to be atomic as long as succeeded logs are consecutive.
"All or nothing" is up to you; if you want to make 10 logs atomic, you should make append_entries
fail on the 6th log failure. Otherwise, it is OK for NuRaft to move forward with the succeeded 5 logs.
from nuraft.
Thanks for the response. Irrespective of the number of logs submitted to append_entries, handle_result() is called once. If partial number of logs append fails, How to handle it? What is the error that handle_result() gets in this case?
from nuraft.
If failure is detected so that you want to make the call fail, you can return ReturnNull
in the callback AppendLogs
.
NuRaft/src/handle_client_request.cxx
Lines 146 to 147 in 7ce0ef8
then it will make
append_entries
call fail with BAD_REQUEST
code.from nuraft.
In case of raft_params::async_handler,
// Async mode:
// append_entries
returns immediately.
// handle_result
will be invoked asynchronously,
// after getting a consensus.
While appending 10 (multiple) logs, after appending 5 logs successfully, if leader change happens, remaining 5 logs will fail.
How do the caller come to know this failure, so that he can either
- make first 5 logs also as failed and retry all again.
- retry the failed 5 logs again.
I see that caller comes to know result with handle_result(), which shows whether it succeeded or failed?
https://github.com/eBay/NuRaft/blob/7ce0ef89775c0976c98381b3d5eda93cea6dca37/examples/calculator/calc_server.cxx#L47
Is there any other way to find this and return ReturnNull in the callback AppendLogs as you mentioned?
from nuraft.
- If the leader changes before committing 5 appended logs, those logs are invalid and will be rolled back by the new leader.
- YOU are the one who implements log store, so you are responsible for detecting such errors, not NuRaft. So any error happens in YOUR LOG STORE, you should remember it, and in YOUR callback function for
AppendLogs
, you should returnReturnNull
. Thenhandle_result
will check it byresult.get_result_code() != cmd_result_code::BAD_REQUEST
.
from nuraft.
OK that means, out of 10 logs, if leader change happens after appending 5 logs, logs 6 to 10 get the leader change error in the handle_result(), and also the new leader will rollback logs 1 to 5. Is this correct?
If so, All I need to do is tell the caller that logs 1 to 10 failed and it can retry.
AppendLogs callback is for having custom checks on the appended logs.
Thanks for the help.
from nuraft.
OK that means, out of 10 logs, if leader change happens after appending 5 logs, logs 6 to 10 get the leader change error in the handle_result(), and also the new leader will rollback logs 1 to 5. Is this correct?
Yes, that's correct.
from nuraft.
Thanks a lot for your help
from nuraft.
Related Issues (20)
- ssl_test() fails when build with -DDISABLE_SSL=1
- rpc port binding HOT 2
- integer overflow ? HOT 3
- buffer overflow vulnerability HOT 2
- Whether we should add consistency test. HOT 2
- bug: runtests.sh calls missing buffer_test script HOT 2
- RPC should set connection timeout. HOT 3
- OpenSSF Security Scorecard improvements
- Wrong "src" and "dst" when cs_new<req_msg> HOT 2
- deadblock HOT 1
- Clean up CMakeLists HOT 2
- nuraft 2.0.0 cannot work on centos7 + centos8 HOT 2
- Preconditions of apply_pack HOT 1
- handle_append_entries_resp() declined append HOT 1
- How to use NuRaft with CMake's FetchContent? HOT 12
- CMake targets should be namespaced using ALIAS targets
- CMake targets are missing usage requirements
- Leadership yielding is not synchronized with replicated log HOT 1
- Should the type be uint8_t instead of size_t for serialize_v1p(...) in srv_state.hxx line 133 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuraft.