Releases: databendlabs/openraft
v0.9.6
Summary:
- Added:
- Improved:
- 99596c75
declare_raft_types
allows the types in any order.
- 99596c75
- Fixed:
- 14d42e4f Load mebmership since
last_applied
, notlast_membership.index
on startup.
- 14d42e4f Load mebmership since
Detail:
Added:
-
Added: 5776139d Add
#[since(version="1.0")]
to specify first version of a feature; by 张炎泼; 2024-04-12#[since(version = "1.0.0")]
adds a doc line/// Since: Version(1.0.0)
.Example:
/// Foo function /// /// Does something. #[since(version = "1.0.0")] fn foo() {}
The above code will be transformed into:
/// Foo function /// /// Does something. /// /// Since: Version(1.0.0) fn foo() {}
-
Added: b172dc8e Add macro
expand!()
to expand a template; by 张炎泼; 2024-04-13expand!()
renders a template with arguments multiple times.Example:
expand!(KEYED, // ignore duplicate by `K` (K, T, V) => {let K: T = V;}, (a, u64, 1), (a, u32, 2), // duplicate `a` will be ignored (c, Vec<u8>, vec![1,2]) );
The above code will be transformed into:
let a: u64 = 1; let c: Vec<u8> = vec![1, 2];
Improved:
-
Improved: 99596c75
declare_raft_types
allows the types in any order; by 张炎泼; 2024-04-13By rewriting the template expanding part with a
#[proc_macro]
expand!()
defined inopenraft_macros
,declare_raft_types
does not require the types in fixed order:Example:
declare_raft_types!(All: D = (), NodeId = u64, R = (), Node = (),
Fixed:
-
Fixed: 14d42e4f Load mebmership since
last_applied
, notlast_membership.index
on startup; by 张炎泼; 2024-04-25Modify
StorageHelper::last_membership_in_log()
to scan the log
starting from the last applied index rather than the index of the last
applied membership log. This change reduces unnecessary I/O operations
during startup, previously caused by scanning from an incorrect starting
point.
v0.9.5
Summary:
- Added:
Detail:
Added:
-
Added: e4fed706 Add
Raft::is_initialized()
; by 张炎泼; 2024-04-08Raft::is_initialized()
returnstrue
if this raft node is already
initialized withRaft::initialize()
, by checking if log is empty and
vote
is not written. -
Added: 3b18517a Add
RaftTypeConfig::Responder
to customize returning client write response; by 张炎泼; 2024-04-03This commit introduces the
Responder
trait that defines the mechanism
by whichRaftCore
sends responses back to the client after processing
write requests. Applications can now customize response handling by
implementing their own version of theRaftTypeConfig::Responder
trait.The
Responder::from_app_data(RaftTypeConfig::D)
method is invoked to
create a newResponder
instance when a client write request is
received.
Once the write operation is completed withinRaftCore
,
Responder::send(WriteResult)
is called to dispatch the result
back to the client.By default,
RaftTypeConfig::Responder
retains the existing
functionality using a oneshot channel, ensuring backward compatibility.This change is non-breaking, requiring no modifications to existing
applications.- Fix: #1068
-
Added: c508a354
Raft::client_write_ff()
ff for fire-and-forget; by 张炎泼; 2024-04-08Raft<C>::client_write_ff() -> C::Responder::Receiver
submit a client
request to Raft to update the state machine, returns an application
defined response receiverResponder::Receiver
to receive the response._ff
means fire and forget.It is same as [
Raft::client_write
] but does not wait for the response.
When using this method, it is the application's responsibility for
defining mechanism building and consuming theResponder::Receiver
.- Part of #1068
Full Changelog: v0.9.4...v0.9.5
v0.9.4
Summary:
- Changed:
- 2b8bc842 Add default value to
declare_raft_types
.
- 2b8bc842 Add default value to
- Added:
- 93c0d9ae Implement
TryAsRef<ForwardToLeader<..>>
forRaftError
.
- 93c0d9ae Implement
Detail:
Changed:
-
Changed: 2b8bc842 Add default value to
declare_raft_types
;Types used in
declare_raft_types
can be omitted, in which case the default type will be used.
The default values for each type are:D
:String
R
:String
NodeId
:u64
Node
:::openraft::BasicNode
Entry
:::openraft::Entry<Self>
SnapshotData
:Cursor<Vec<u8>>
AsyncRuntime
:::openraft::TokioRuntime
Note that The types must be specified in the exact order:
D
,R
,NodeId
,Node
,Entry
,SnapshotData
,AsyncRuntime
.For example, to declare with only
D
,R
andEntry
types:openraft::declare_raft_types!( pub TypeConfig: D = ClientRequest, R = ClientResponse, Entry = MyEntry, );
Type
NodeId
,Node
,SnapshotData
andAsyncRuntime
will be filled
with default values mentioned above.Or one can just use the default types for all:
openraft::declare_raft_types!(pub TypeConfig);
Upgrade tip:
Ensures types declared in
declare_raft_types
are in the correct order
Added:
- Added: 93c0d9ae Implement
TryAsRef<ForwardToLeader<..>>
forRaftError
;
Full Changelog: v0.9.3...v0.9.4
Contributors
v0.9.2
- Added:
- Improved:
- Fixed:
v0.9.0
Upgrade guide from 0.8 to 0.9:
https://docs.rs/openraft/latest/openraft/docs/upgrade_guide/upgrade_08_09/index.html
What's Changed
- Feature: define custom Entry type for raft log by @drmingdrmer in #720
- Fix: trait RaftLogId should be public by @drmingdrmer in #726
- Change: StoreBuilder does not need to run a test, it only needs to build a store by @drmingdrmer in #730
- Feature: add methods to StorageIOError to simplify error creation by @drmingdrmer in #738
- Change: remove
Clone
from traitAppData
by @drmingdrmer in #740 - Change: instead of a slice,
RaftStorage::append_to_log()
now accepts anIntoIterator
by @drmingdrmer in #742 - Improve: send AppendEntries response before committing entries by @drmingdrmer in #751
- Change: remove unused trait RaftStorageDebug by @drmingdrmer in #759
- Change: remove defensive check utilities by @drmingdrmer in #761
- Change: move
RaftStateMachine
out ofRaftStorage
by @drmingdrmer in #763 - Improve: move state machine operations to another task by @drmingdrmer in #767
- Fix: if the application does not persist snapshot, build a snapshot when starting up by @drmingdrmer in #768
- Improve: getting a snapshot does not block RaftCore task by @drmingdrmer in #773
- Fix: debug level check by @drmingdrmer in #780
- Improve: reduce rate to flush metrics by @drmingdrmer in #782
- Change:
RaftMetrics.replication
type toBTreeMap<NodeId, Option<LogId>>
by @drmingdrmer in #785 - Feature: add backoff strategy for unreachable nodes by @drmingdrmer in #779
- Change: move snapshot type definition from storage traits to
RaftTypeConfig
by @drmingdrmer in #799 - Feature: add RaftMetrics::purged to report the last purged log id by @drmingdrmer in #809
- Feature: add Wait::purged() to wait for purged to become the expected by @drmingdrmer in #810
- Fix: replication should be able to shutdown when replicating snapshot to unreachable node by @drmingdrmer in #811
- Feature: add
RaftMetrics.vote
,Wait::vote()
by @drmingdrmer in #815 - Improve: build snapshot in anohter task by @drmingdrmer in #816
- Feature: new RaftNetwork API with argument RCPOption by @drmingdrmer in #825
- Feature:
RaftNetwork::send_append_entries()
can return PartialSuccess by @drmingdrmer in #831 - Change: remove unused error CommittedAdvanceTooMany by @drmingdrmer in #838
- Fix: add_learner() should block forever by @drmingdrmer in #847
- Feature: leader lease by @drmingdrmer in #848
- Feature: add SnapshotPolicy::Never by @drmingdrmer in #854
- Feature: add Raft::purge_log() by @drmingdrmer in #855
- Change: add AsyncRuntime type parameter to RaftTypeConfig by @wvwwvwwv in #869
- Feature: add ChangeMembers::SetNodes by @drmingdrmer in #876
- Feature: add 'singlethreaded' raft mode by @wvwwvwwv in #878
- Fix: restore replication progress when a leader starts up by @drmingdrmer in #884
- Change: move external command trigger to dedicated Trigger struct by @drmingdrmer in #888
- Change: move runtime config API to dedicated RuntimeConfigHandle by @drmingdrmer in #889
- Change: RaftLogReaderExt::get_log_id() should not return last-purged-id by @drmingdrmer in #892
- Change: move get_log_state() from RaftLogReader to RaftStorage by @drmingdrmer in #893
- Feature: save committed log id by @drmingdrmer in #897
- Feature: permit follower log to revert to earlier state with
--features loosen-follower-log-revert
by @drmingdrmer in #903 - Feature: add feature flag "tracing-log" to emit log record for tracing event by @drmingdrmer in #908
- Fix: Do not report snapshot.last_log_id to metrics until snapshot is finished building/installing by @drmingdrmer in #913
- Fix: AsyncReadExt::read_buf() only reads at most 2MB per call by @drmingdrmer in #925
- Fix: End
tick_loop()
when the receiver is gone. by @schreter in #930 - Fix: avoid panic with "loosen-follower-log-revert" enabled by @drmingdrmer in #937
- Fix: For single-threaded execution, there is no need for
Send
/Sync
bounds by @schreter in #934 - Change: remove
N, LS, SM
fromRaft<C, N, LS, SM>
by @drmingdrmer in #941 - Feature: add
PayloadTooLarge
error by @drmingdrmer in #951 - Feature: add
Raft::access_raft_state()
to accessRaftState
with a function by @drmingdrmer in #957 - Feature: Add new methods to
openraft::metrics::Wait
by @drmingdrmer in #960 - Feature: add
Wait::voter_ids()
and deprecateWait::members()
by @drmingdrmer in #961 - Feature: add
Raft::ensure_linearizable()
to ensure linearizable read by @drmingdrmer in #964 - Feature: add
Wait::eq()
andge()
to await a metics by @drmingdrmer in #967 - Change: #959 ditch async_trait for the singlethreade feature by @wvwwvwwv in #982
- Feature: add
Raft::data_metrics()
andRaft::server_metrics()
by @YangKian in #990 - Fix: Split serde bound for
RaftError
into serialize and deserialize by @tvsfx in #991 - Feature: Add random number generator to
AsyncRuntime
by @schreter in #995 - Feature: add Raft::get_snapshot() to get the last snapshot from state machine by @drmingdrmer in #1000
- Fix: Remove implementation of
Instant
forstd::time::Instant
by @schreter in #1001 - Feature: add
Raft::install_complete_snapshot()
to install a snapshot by @drmingdrmer in #1002 - Feature: Add
Raft::begin_receiving_snapshot()
by @drmingdrmer in #1008 - Change: remove
AsyncRuntime::abort()
by @drmingdrmer in #1012 - Feature:
RaftNetwork::snapshot()
to send a complete snapshot by @drmingdrmer in #1009 - Feature: feature flag
generic-snapshot-data
by @drmingdrmer in #1016 - Change: remove deprecated RaftNetwork methods without
option
argument by @drmingdrmer in #1028 - Change: rename
Raft::install_complete_snapshot()
toinstall_full_snapshot()
by @drmingdrmer in #1030 - Feature: AsyncRuntime::oneshot by @Miaxos in #1026
- Change: remove openraft-0.7 compatibility support by @drmingdrmer in #1033
- Feature: add trait
RaftLogStorageExt
to provide additional raft-log methods by @drmingdrmer in #1034 - Change:
Raft::begin_receiving_snapshot()
does not need to checkVote
by @drmingdrmer in #1037 - Change:
Raft::begin_receiving_snapshot()
return onlyFatal
error. by @drmingdrmer in #1038 - Fix: install_snapshot() should return local vote, not request vote by @drmingdrmer in #1042
New Contributors
- @HHoflittlefish777 made their first contribution in #842
- @leiysky made their first contribution in #849
- @wvwwvwwv made their first contribution in #869
- @caicancai made their first contribution in #932
- @pfwang80s ma...
v0.8.9
What's Changed
- Feature: define custom Entry type for raft log by @drmingdrmer in #720
- Fix: trait RaftLogId should be public by @drmingdrmer in #726
- Change: StoreBuilder does not need to run a test, it only needs to build a store by @drmingdrmer in #730
- Feature: add methods to StorageIOError to simplify error creation by @drmingdrmer in #738
- Change: remove
Clone
from traitAppData
by @drmingdrmer in #740 - Change: instead of a slice,
RaftStorage::append_to_log()
now accepts anIntoIterator
by @drmingdrmer in #742 - Improve: follower stores the accepted log id by @drmingdrmer in #748
- Improve: send AppendEntries response before committing entries by @drmingdrmer in #751
- Change: remove unused trait RaftStorageDebug by @drmingdrmer in #759
- Change: remove defensive check utilities by @drmingdrmer in #761
- Change: move
RaftStateMachine
out ofRaftStorage
by @drmingdrmer in #763 - Improve: move state machine operations to another task by @drmingdrmer in #767
- Fix: if the application does not persist snapshot, build a snapshot when starting up by @drmingdrmer in #768
- Improve: getting a snapshot does not block RaftCore task by @drmingdrmer in #773
- Fix: debug level check by @drmingdrmer in #780
- Improve: reduce rate to flush metrics by @drmingdrmer in #782
- Change:
RaftMetrics.replication
type toBTreeMap<NodeId, Option<LogId>>
by @drmingdrmer in #785 - Feature: add backoff strategy for unreachable nodes by @drmingdrmer in #779
- Improve: create a channel
notify
specifically for interal messages by @drmingdrmer in #794 - Change: move snapshot type definition from storage traits to
RaftTypeConfig
by @drmingdrmer in #799 - Improve: move receiving snapshot chunk to sm::Worker by @drmingdrmer in #803
- Feature: add RaftMetrics::purged to report the last purged log id by @drmingdrmer in #809
- Feature: add Wait::purged() to wait for purged to become the expected by @drmingdrmer in #810
- Fix: replication should be able to shutdown when replicating snapshot to unreachable node by @drmingdrmer in #811
- Feature: add
RaftMetrics.vote
,Wait::vote()
by @drmingdrmer in #815 - Improve: build snapshot in anohter task by @drmingdrmer in #816
- Feature: new RaftNetwork API with argument RCPOption by @drmingdrmer in #825
- Feature:
RaftNetwork::send_append_entries()
can return PartialSuccess by @drmingdrmer in #831 - Change: remove unused error CommittedAdvanceTooMany by @drmingdrmer in #838
- Fix: add_learner() should block forever by @drmingdrmer in #847
- Feature: leader lease by @drmingdrmer in #848
- Feature: add SnapshotPolicy::Never by @drmingdrmer in #854
- Feature: add Raft::purge_log() by @drmingdrmer in #855
- Improve: IntoIterator::IntoIter should be Send by @drmingdrmer in #868
- Improve: impl Clone for Raft does not require Clone for its type parameters by @drmingdrmer in #872
New Contributors
- @HHoflittlefish777 made their first contribution in #842
- @leiysky made their first contribution in #849
Full Changelog: v0.8.3...v0.8.9
Fix election timeout to reduce conflicts
Improved:
-
Improved: 23f4a73b AppDataResponse does not need a Clone trait bound; by 张炎泼; 2023-03-09
- Fix: #703
-
Improved: 664635e0 loosen validity check with RaftState.snapshot_last_log_id(); by 张炎泼; 2023-03-10
A application may not persist snapshot. And when it restarted, the
last-purged-log-id is notNone
butsnapshot_last_log_id()
is None.
This is a valid state and should not emit error. -
Improved: 54aea8a2 fix: delay election if a greater last log id is seen; by 张炎泼; 2023-03-14
If this node sees a greater last-log-id on another node, it will be less
likely to be elected as a leader.
In this case, it is necessary to sleep for a longer period of time
smaller_log_timeout
so that other nodes with a greater last-log-id
have a chance to elect themselves.
Changed:
-
Changed: 9ddb5715 RaftState: make
RaftState.vote
private. Accesses vote via 2 new public methods:vote_ref()
andvote_last_modified()
.; by 张炎泼; 2023-03-12 -
Changed: 3b4f4e18 move log id related traits to mod
openraft::log_id
; by 张炎泼; 2023-03-14Move trait
RaftLogId
,LogIdOptionExt
andLogIndexOptionExt
fromopenraft::raft_types
to modopenraft::log_id
Revert to standard heartbeat; Improve change-membership API; Fix bugs
Full change-log: https://github.com/datafuselabs/openraft/blob/v0.8.2/change-log.md#v082
Changed:
- Changed: 342d0de2 rename variants in ChangeMembers, add
AddVoters
; by 张炎泼; 2023-03-01
Added:
- Added: 50821c37 impl PartialEq for Entry; by 张炎泼; 2023-03-02
Fixed:
Add Membership methods: voter_ids(), learner_ids(), get_node()
Feature: add Membership methods: voter_ids(), learner_ids(), get_node()
Generalization and refactor code base
Openraft 0.8 focused on refactoring codebase, including:
- Move logic to
Engine
, which is a event-driven non-async mod, in order to make logic more clear and tests easier: #291 - Migrate to a more generic API design:
NodeId
andNode
are no longer concrete types but a trait, so it is possible for an application to use any node-id type or node type. - Make the consensus implementation more generic: it supports both multi-leader per term mode and single-leader per term mode: feature flag single-term-leader
Full change log: https://github.com/datafuselabs/openraft/blob/release-0.8/change-log/v0.8.0.md