Skip to content

Commit b95dd01

Browse files
authored
bump 0.3.0 (#256)
* bump 0.3.0 Signed-off-by: tabokie <xy.tao@outlook.com> * encode_len -> encoded_len Signed-off-by: tabokie <xy.tao@outlook.com> * patch changelog Signed-off-by: tabokie <xy.tao@outlook.com> * makefile force set toolchain if incompatible Signed-off-by: tabokie <xy.tao@outlook.com> * simplify a bit Signed-off-by: tabokie <xy.tao@outlook.com> * simplify make test command Signed-off-by: tabokie <xy.tao@outlook.com> Signed-off-by: tabokie <xy.tao@outlook.com>
1 parent 087d36b commit b95dd01

File tree

12 files changed

+55
-36
lines changed

12 files changed

+55
-36
lines changed

.github/workflows/rust.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ jobs:
6969
- name: Clippy
7070
run: make clippy
7171
env:
72-
WITH_STABLE_TOOLCHAIN: 'true'
72+
WITH_STABLE_TOOLCHAIN: 'force'
7373
- name: Run tests
7474
run: make test
7575
env:
7676
RUST_BACKTRACE: 1
7777
EXTRA_CARGO_ARGS: '--verbose'
78-
WITH_STABLE_TOOLCHAIN: 'true'
78+
WITH_STABLE_TOOLCHAIN: 'force'
7979
coverage:
8080
runs-on: ubuntu-latest
8181
needs: nightly
@@ -98,7 +98,7 @@ jobs:
9898
- name: Run tests
9999
run: |
100100
make test
101-
env WITH_STABLE_TOOLCHAIN=true make test
101+
env WITH_STABLE_TOOLCHAIN=auto make test
102102
env:
103103
RUSTFLAGS: '-Zinstrument-coverage'
104104
LLVM_PROFILE_FILE: '%p-%m.profraw'

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Raft Engine Change Log
22

3-
## [Unreleased]
3+
## [0.3.0] - 2022-09-14
44

55
### Bug Fixes
66

77
* Unconditionally tolerate `fallocate` failures as a fix to its portability issue. Errors other than `EOPNOTSUPP` will still emit a warning.
88
* Avoid leaving fractured write after failure by reseeking the file writer. Panic if the reseek fails as well.
9+
* Fix a parallel recovery panic bug.
910
* Fix panic when an empty batch is written to engine and then reused.
1011

1112
### New Features

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "raft-engine"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
authors = ["The TiKV Project Developers"]
55
edition = "2018"
66
rust-version = "1.57"

Makefile

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,28 @@
22

33
## Additionaly arguments passed to cargo.
44
EXTRA_CARGO_ARGS ?=
5-
## Whether to disable nightly-only feature. [true/false]
5+
## How to test stable toolchain.
6+
## - auto: use current default toolchain, disable nightly features.
7+
## - force: always use stable toolchain, disable nightly features.
68
WITH_STABLE_TOOLCHAIN ?=
79

10+
WITH_NIGHTLY_FEATURES =
11+
ifeq (,$(filter $(WITH_STABLE_TOOLCHAIN),auto force))
12+
WITH_NIGHTLY_FEATURES = 1
13+
endif
14+
15+
TOOLCHAIN_ARGS =
16+
ifeq ($(shell (rustc --version | grep -q nightly); echo $$?), 1)
17+
ifdef WITH_NIGHTLY_FEATURES
18+
# Force use nightly toolchain if we are building with nightly features.
19+
TOOLCHAIN_ARGS = +nightly
20+
endif
21+
else
22+
ifeq ($(WITH_STABLE_TOOLCHAIN), force)
23+
TOOLCHAIN_ARGS = +stable
24+
endif
25+
endif
26+
827
.PHONY: format clippy test
928

1029
all: format clippy test
@@ -14,21 +33,19 @@ format:
1433
cargo fmt --all
1534

1635
## Run clippy.
17-
ifeq ($(WITH_STABLE_TOOLCHAIN), true)
1836
clippy:
19-
cargo clippy --all --features all_stable --all-targets -- -D clippy::all
37+
ifdef WITH_NIGHTLY_FEATURES
38+
cargo ${TOOLCHAIN_ARGS} clippy --all --all-features --all-targets -- -D clippy::all
2039
else
21-
clippy:
22-
cargo clippy --all --all-features --all-targets -- -D clippy::all
40+
cargo ${TOOLCHAIN_ARGS} clippy --all --features all_stable --all-targets -- -D clippy::all
2341
endif
2442

2543
## Run tests.
26-
ifeq ($(WITH_STABLE_TOOLCHAIN), true)
2744
test:
28-
cargo test --all --features all_stable_except_failpoints ${EXTRA_CARGO_ARGS} -- --nocapture
29-
cargo test --test failpoints --features all_stable ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
45+
ifdef WITH_NIGHTLY_FEATURES
46+
cargo ${TOOLCHAIN_ARGS} test --all --features all_except_failpoints ${EXTRA_CARGO_ARGS} -- --nocapture
47+
cargo ${TOOLCHAIN_ARGS} test --test failpoints --all-features ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
3048
else
31-
test:
32-
cargo test --all --features all_except_failpoints ${EXTRA_CARGO_ARGS} -- --nocapture
33-
cargo test --test failpoints --all-features ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
49+
cargo ${TOOLCHAIN_ARGS} test --all --features all_stable_except_failpoints ${EXTRA_CARGO_ARGS} -- --nocapture
50+
cargo ${TOOLCHAIN_ARGS} test --test failpoints --features all_stable ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
3451
endif

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Put this in your Cargo.toml:
5454

5555
```rust
5656
[dependencies]
57-
raft-engine = "0.2.0"
57+
raft-engine = "0.3.0"
5858
```
5959

6060
Available Cargo features:
@@ -74,13 +74,13 @@ Contributions are always welcome! Here are a few tips for making a PR:
7474
- All commits must be signed off (with `git commit -s`) to pass the [DCO check](https://probot.github.io/apps/dco/).
7575
- Tests are automatically run against the changes, some of them can be run locally:
7676

77-
```
78-
# rustup default nightly
77+
```bash
78+
# run tests with nightly features
7979
make
80-
# rustup default stable
81-
env WITH_STABLE_TOOLCHAIN=true make
80+
# run tests on stable toolchain
81+
make WITH_STABLE_TOOLCHAIN=force
8282
# filter a specific test case
83-
env EXTRA_CARGO_ARGS=<testname> make test
83+
make test EXTRA_CARGO_ARGS=<testname>
8484
```
8585

8686
- For changes that might induce performance effects, please quote the targeted benchmark results in the PR description. In addition to micro-benchmarks, there is a standalone [stress test tool](https://github.com/tikv/raft-engine/tree/master/stress) which you can use to demonstrate the system performance.

ctl/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "raft-engine-ctl"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
authors = ["The TiKV Project Developers"]
55
edition = "2018"
66
rust-version = "1.57"
@@ -11,4 +11,4 @@ license = "Apache-2.0"
1111
[dependencies]
1212
clap = { version = "3.1", features = ["derive", "cargo"] }
1313
env_logger = "0.9"
14-
raft-engine = { path = "..", version = "0.2.0", features = ["scripting", "internals"] }
14+
raft-engine = { path = "..", version = "0.3.0", features = ["scripting", "internals"] }

src/file_pipe_log/format.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ pub(super) fn lock_file_path<P: AsRef<Path>>(dir: P) -> PathBuf {
9292
path
9393
}
9494

95-
/// In-memory representation of `Format` in log files.
95+
/// Log file format. It will be encoded to file header.
9696
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
9797
pub struct LogFileFormat {
9898
pub version: Version,
99+
/// 0 stands for no alignment.
99100
pub alignment: u64,
100101
}
101102

@@ -116,12 +117,12 @@ impl LogFileFormat {
116117
}
117118
}
118119

119-
pub const fn max_encode_len() -> usize {
120+
pub const fn max_encoded_len() -> usize {
120121
Self::header_len() + Self::payload_len(Version::V2)
121122
}
122123

123124
/// Length of whole `LogFileFormat` written on storage.
124-
pub fn encode_len(version: Version) -> usize {
125+
pub fn encoded_len(version: Version) -> usize {
125126
Self::header_len() + Self::payload_len(version)
126127
}
127128

src/file_pipe_log/log_file.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ impl<F: FileSystem> LogFileWriter<F> {
5757
written: file_size,
5858
capacity: file_size,
5959
};
60-
// TODO: add tests for file_size in [header_len, max_encode_len].
61-
if file_size < LogFileFormat::encode_len(format.version) || force_reset {
60+
// TODO: add tests for file_size in [header_len, max_encoded_len].
61+
if file_size < LogFileFormat::encoded_len(format.version) || force_reset {
6262
f.write_header(format)?;
6363
} else {
6464
f.writer.seek(SeekFrom::Start(file_size as u64))?;
@@ -69,7 +69,7 @@ impl<F: FileSystem> LogFileWriter<F> {
6969
fn write_header(&mut self, format: LogFileFormat) -> Result<()> {
7070
self.writer.seek(SeekFrom::Start(0))?;
7171
self.written = 0;
72-
let mut buf = Vec::with_capacity(LogFileFormat::encode_len(format.version));
72+
let mut buf = Vec::with_capacity(LogFileFormat::encoded_len(format.version));
7373
format.encode(&mut buf)?;
7474
self.write(&buf, 0)
7575
}
@@ -165,7 +165,7 @@ impl<F: FileSystem> LogFileReader<F> {
165165
/// to `0`, that is, the beginning of the file, to parse the
166166
/// related `[LogFileFormat]`.
167167
pub fn parse_format(&mut self) -> Result<LogFileFormat> {
168-
let mut container = vec![0; LogFileFormat::max_encode_len()];
168+
let mut container = vec![0; LogFileFormat::max_encoded_len()];
169169
let size = self.read_to(0, &mut container)?;
170170
container.truncate(size);
171171
LogFileFormat::decode(&mut container.as_slice())

src/file_pipe_log/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ pub mod debug {
315315
for from in formats {
316316
for to in formats {
317317
for shorter in [true, false] {
318-
if LogFileFormat::encode_len(to.version)
319-
< LogFileFormat::encode_len(from.version)
318+
if LogFileFormat::encoded_len(to.version)
319+
< LogFileFormat::encoded_len(from.version)
320320
{
321321
continue;
322322
}

src/file_pipe_log/pipe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ mod tests {
620620
let pipe_log = new_test_pipes(&cfg).unwrap();
621621
assert_eq!(pipe_log.file_span(queue), (1, 1));
622622

623-
let header_size = LogFileFormat::encode_len(cfg.format_version) as u64;
623+
let header_size = LogFileFormat::encoded_len(cfg.format_version) as u64;
624624

625625
// generate file 1, 2, 3
626626
let content: Vec<u8> = vec![b'a'; 1024];

0 commit comments

Comments
 (0)