From a24040d61465d3749fb1395cd15b3b44dc13bdc8 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 02:03:53 +0000 Subject: [PATCH 1/9] feat: Updated openraft/src/docs/upgrade_guide/upgr --- openraft/src/docs/upgrade_guide/upgrade-v07-v08.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md index 5aa42662b..c6e020968 100644 --- a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md +++ b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md @@ -1,4 +1,4 @@ -# Guide for upgrading from [v0.7](https://github.com/datafuselabs/openraft/tree/v0.7.4) to [v0.8](https://github.com/datafuselabs/openraft/tree/release-0.8): +# Guide for upgrading from `v0.7` to `v0.8`: [Change log v0.8](https://github.com/datafuselabs/openraft/blob/release-0.8/change-log.md) @@ -13,7 +13,7 @@ To upgrade: 1. Update the application to adopt `v0.8` openraft. The updated `RaftStorage` implementation must pass [`testing::Suite`](`crate::testing::Suite`): an example of running it is [`RaftStorage` test suite](https://github.com/datafuselabs/openraft/blob/release-0.8/memstore/src/test.rs), - and the compatibility test: [compatibility test](https://github.com/datafuselabs/openraft/blob/main/rocksstore-compat07/src/compatibility_test.rs) + and the compatibility test: `compatibility test`. 2. Then shutdown all `v0.7` nodes and then bring up `v0.8` nodes. @@ -230,7 +230,7 @@ that can be deserialized from `v0.7` or `v0.8` data, such as Openraft also provides a testing suite [`compat::testing::Suite07`] to ensure old data will be correctly read. -An application should ensure that its storage passes this test suite. Just like [rocksdb-compatability-test][compatibility test] does. +An application should ensure that its storage passes this test suite. Just like rocksdb-compatability-test does. To test compatibility of the application storage API: From ade9580f323c5a20dd16d1cfdf903d963d3a0c1c Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 02:04:47 +0000 Subject: [PATCH 2/9] feat: Updated openraft/src/docs/upgrade_guide/upgr --- .../src/docs/upgrade_guide/upgrade-v07-v08.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md index c6e020968..db7ab7e9c 100644 --- a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md +++ b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md @@ -42,6 +42,21 @@ Openraft `v0.8` provides several [`feature_flags`] to provide compatibility with Openraft `v0.8` introduces several more generic types to define application types that are defined as associated types of `RaftTypeConfig`. An `v0.8` application should implement [`RaftTypeConfig`]: + ```ignore + pub(crate) struct MyTypeConfig {} + impl RaftTypeConfig for MyTypeConfig { + type D = ClientRequest; + type R = ClientResponse; + type NodeId = u64; + type Node = openraft::EmptyNode; + type Entry = openraft::entry::Entry; + type SnapshotData = Cursor; + } + ``` + + Openraft `v0.8` introduces several more generic types to define application types that are defined as associated types of `RaftTypeConfig`. + An `v0.8` application should implement [`RaftTypeConfig`]: + ```ignore pub(crate) struct MyTypeConfig {} impl RaftTypeConfig for MyTypeConfig { From 94dfd85b5d00a997ae2fe9aa5f0e5dbba5d9efd7 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 02:05:12 +0000 Subject: [PATCH 3/9] feat: Updated openraft/src/docs/upgrade_guide/upgr --- openraft/src/docs/upgrade_guide/upgrade-v07-v08.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md index db7ab7e9c..c9befae5c 100644 --- a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md +++ b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md @@ -39,7 +39,7 @@ Openraft `v0.8` provides several [`feature_flags`] to provide compatibility with - Add type config to define concrete types to use for openraft, See [`RaftTypeConfig`]. - Openraft `v0.8` introduces several more generic types to define application types that are defined as associated types of `RaftTypeConfig`. + Openraft `v0.8` introduces a macro `declare_raft_types` to declare these generic application types that are defined as associated types of `RaftTypeConfig`. An `v0.8` application should implement [`RaftTypeConfig`]: ```ignore @@ -89,6 +89,13 @@ Openraft `v0.8` provides several [`feature_flags`] to provide compatibility with ```ignore openraft::declare_raft_types!( + pub MyTypeConfig: + D = ClientRequest, + R = ClientResponse, + NodeId = u64, + Node = openraft::EmptyNode, + Entry = openraft::entry::Entry, + SnapshotData = Cursor>, pub MyTypeConfig: D = ClientRequest, R = ClientResponse, From f8a45dd3ec1fcdda37acd301ea20c6d7ef197152 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 02:06:38 +0000 Subject: [PATCH 4/9] feat: Updated openraft/src/docs/upgrade_guide/upgr --- openraft/src/docs/upgrade_guide/upgrade-v07-v08.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md index c9befae5c..6d820454b 100644 --- a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md +++ b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md @@ -109,6 +109,11 @@ Openraft `v0.8` provides several [`feature_flags`] to provide compatibility with - To upgrade to `v0.8`, data types have generic type parameters need to be updated, such as: - `LogId` becomes `LogId`, - `Membership` becomes `Membership`, +- To upgrade to `v0.8`, data types have generic type parameters need to be updated, such as: + - `LogId` becomes `LogId`, + - `Membership` becomes `Membership`, + - `Entry` becomes `Entry`. + Where `u64` is node id type in `v0.7` and `MyTypeConfig` is the type config defined in the previous step. - `Entry` becomes `Entry`. Where `u64` is node id type in `v0.7` and `MyTypeConfig` is the type config defined in the previous step. From 2c2b2af977677ef9b3bbe7c09f4a5cab2400f89c Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 02:07:34 +0000 Subject: [PATCH 5/9] feat: Updated openraft/src/docs/upgrade_guide/upgr --- openraft/src/docs/upgrade_guide/upgrade-v07-v08.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md index 6d820454b..11fc6c853 100644 --- a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md +++ b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md @@ -120,7 +120,7 @@ Openraft `v0.8` provides several [`feature_flags`] to provide compatibility with - Update `RaftStorage` methods implementation according to the [Storage API changes](#storage-api-changes) chapter. - - Replace `HardState` with `Vote`, and `[read/save]_hard_state` with `[read/write]_vote`. + - Replace `HardState` with `Vote`. - Replace `EffectiveMembership` with `StoredMembership`. In order to ensure compatibility with version `0.7`, the storage implementation must replace the types used for deserialization with those supplied by [`compat::compat07`]. From a5a811a01bcf7d46a7e7fb908a80563c2aae79fa Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 02:08:14 +0000 Subject: [PATCH 6/9] feat: Updated openraft/src/docs/upgrade_guide/upgr --- openraft/src/docs/upgrade_guide/upgrade-v07-v08.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md index 11fc6c853..02df8ab19 100644 --- a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md +++ b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md @@ -126,8 +126,8 @@ Openraft `v0.8` provides several [`feature_flags`] to provide compatibility with In order to ensure compatibility with version `0.7`, the storage implementation must replace the types used for deserialization with those supplied by [`compat::compat07`]. [`compat::compat07`] includes types like [`compat::compat07::Entry`] that can be deserialized from both `v0.7` serialized `Entry` and `v0.8` serialized `Entry`. -- Move `RaftNetwork` methods implementation according to the - [Network-API-changes](#network-api-changes) chapter. +- Move `RaftNetwork` and `RaftNetworkFactory` methods implementation according to the + [Network API changes](#network-api-changes), and update the code to split `RaftNetwork` and `RaftNetworkFactory` as follows: - Use `v0.8` [`Adaptor`] to install `RaftStorage` to `Raft`. From d058886720e6062ba39b2961332a3ca48b6b9896 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 02:08:43 +0000 Subject: [PATCH 7/9] feat: Updated openraft/src/docs/upgrade_guide/upgr --- openraft/src/docs/upgrade_guide/upgrade-v07-v08.md | 1 + 1 file changed, 1 insertion(+) diff --git a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md index 02df8ab19..4343ef1d5 100644 --- a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md +++ b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md @@ -150,6 +150,7 @@ Openraft `v0.8` provides several [`feature_flags`] to provide compatibility with where C: RaftTypeConfig, N: RaftNetworkFactory, + S: RaftStorage, S: RaftStorage, ``` From 4613cbddfed65560295aaf9ae23f2f0c12cd8240 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 02:09:02 +0000 Subject: [PATCH 8/9] feat: Updated openraft/src/docs/upgrade_guide/upgr --- openraft/src/docs/upgrade_guide/upgrade-v07-v08.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md index 4343ef1d5..838317cfa 100644 --- a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md +++ b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md @@ -32,6 +32,7 @@ Openraft `v0.8` provides several [`feature_flags`] to provide compatibility with - `serde`: Make sure that the application uses `serde` to serialize data; Openraft v0.8 provides a compatibility layer that is built upon `serde`. - `compat-07`: Enable feature flag `compat-07` to enable the compatibility layer [`compat::compat07`](`crate::compat::compat07`). +- Optionally enable feature flag `single-term-leader` if the application wants to use standard raft. See [Multi/single leader in each term](#multisingle-leader-in-each-term) chapter. - Optionally enable feature flag `single-term-leader` if the application wants to use standard raft. See [Multi/single leader in each term](#multisingle-leader-in-each-term) chapter. @@ -203,8 +204,8 @@ And `v0.8` will be compatible with `v0.7` only when it uses `u64` as `NodeId` an ## Implement a compatible storage layer In addition to enabling `compat-07` feature flag, openraft provides a compatible layer in -[`compat::compat07`] to help application developer to upgrade. -This mod provides several types that can deserialize from both `v0.7` format data and the latest format data. +[`compat::compat07`] to help the application developer to upgrade. +[`compat::compat07`] provides several types that can deserialize from both `v0.7` format data and the latest format data. An application uses these types to replace the corresponding ones in a `RaftStorage` implementation, so that `v0.7` data and `v0.8` data can both be read. From 5cb2242ed8175a1038a9924cf55827b14963f979 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 02:09:57 +0000 Subject: [PATCH 9/9] feat: Updated openraft/src/docs/upgrade_guide/upgr --- openraft/src/docs/upgrade_guide/upgrade-v07-v08.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md index 838317cfa..ce2c71af4 100644 --- a/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md +++ b/openraft/src/docs/upgrade_guide/upgrade-v07-v08.md @@ -429,7 +429,7 @@ Function `get_log_entries()` and `try_get_log_entry()` are provided with default [`compat::compat07::Entry`]: `crate::compat::compat07::Entry` [compatibility test]: https://github.com/datafuselabs/openraft/blob/release-0.8/rocksstore-compat07/src/compatibility_test.rs -[`RaftStorage` test suite]: https://github.com/datafuselabs/openraft/blob/release-0.8/memstore/src/test.rs +the compatibility test for the application storage API: rocksstore-compat07 at [rocksstore-compat07] [`compat::testing::Suite07`]: `crate::compat::testing::Suite07`