Skip to content

Commit

Permalink
bump 0.3.0 (#256)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
tabokie authored Sep 14, 2022
1 parent 087d36b commit b95dd01
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 36 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ jobs:
- name: Clippy
run: make clippy
env:
WITH_STABLE_TOOLCHAIN: 'true'
WITH_STABLE_TOOLCHAIN: 'force'
- name: Run tests
run: make test
env:
RUST_BACKTRACE: 1
EXTRA_CARGO_ARGS: '--verbose'
WITH_STABLE_TOOLCHAIN: 'true'
WITH_STABLE_TOOLCHAIN: 'force'
coverage:
runs-on: ubuntu-latest
needs: nightly
Expand All @@ -98,7 +98,7 @@ jobs:
- name: Run tests
run: |
make test
env WITH_STABLE_TOOLCHAIN=true make test
env WITH_STABLE_TOOLCHAIN=auto make test
env:
RUSTFLAGS: '-Zinstrument-coverage'
LLVM_PROFILE_FILE: '%p-%m.profraw'
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Raft Engine Change Log

## [Unreleased]
## [0.3.0] - 2022-09-14

### Bug Fixes

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

### New Features
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "raft-engine"
version = "0.2.0"
version = "0.3.0"
authors = ["The TiKV Project Developers"]
edition = "2018"
rust-version = "1.57"
Expand Down
39 changes: 28 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@

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

WITH_NIGHTLY_FEATURES =
ifeq (,$(filter $(WITH_STABLE_TOOLCHAIN),auto force))
WITH_NIGHTLY_FEATURES = 1
endif

TOOLCHAIN_ARGS =
ifeq ($(shell (rustc --version | grep -q nightly); echo $$?), 1)
ifdef WITH_NIGHTLY_FEATURES
# Force use nightly toolchain if we are building with nightly features.
TOOLCHAIN_ARGS = +nightly
endif
else
ifeq ($(WITH_STABLE_TOOLCHAIN), force)
TOOLCHAIN_ARGS = +stable
endif
endif

.PHONY: format clippy test

all: format clippy test
Expand All @@ -14,21 +33,19 @@ format:
cargo fmt --all

## Run clippy.
ifeq ($(WITH_STABLE_TOOLCHAIN), true)
clippy:
cargo clippy --all --features all_stable --all-targets -- -D clippy::all
ifdef WITH_NIGHTLY_FEATURES
cargo ${TOOLCHAIN_ARGS} clippy --all --all-features --all-targets -- -D clippy::all
else
clippy:
cargo clippy --all --all-features --all-targets -- -D clippy::all
cargo ${TOOLCHAIN_ARGS} clippy --all --features all_stable --all-targets -- -D clippy::all
endif

## Run tests.
ifeq ($(WITH_STABLE_TOOLCHAIN), true)
test:
cargo test --all --features all_stable_except_failpoints ${EXTRA_CARGO_ARGS} -- --nocapture
cargo test --test failpoints --features all_stable ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
ifdef WITH_NIGHTLY_FEATURES
cargo ${TOOLCHAIN_ARGS} test --all --features all_except_failpoints ${EXTRA_CARGO_ARGS} -- --nocapture
cargo ${TOOLCHAIN_ARGS} test --test failpoints --all-features ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
else
test:
cargo test --all --features all_except_failpoints ${EXTRA_CARGO_ARGS} -- --nocapture
cargo test --test failpoints --all-features ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
cargo ${TOOLCHAIN_ARGS} test --all --features all_stable_except_failpoints ${EXTRA_CARGO_ARGS} -- --nocapture
cargo ${TOOLCHAIN_ARGS} test --test failpoints --features all_stable ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
endif
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Put this in your Cargo.toml:

```rust
[dependencies]
raft-engine = "0.2.0"
raft-engine = "0.3.0"
```

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

```
# rustup default nightly
```bash
# run tests with nightly features
make
# rustup default stable
env WITH_STABLE_TOOLCHAIN=true make
# run tests on stable toolchain
make WITH_STABLE_TOOLCHAIN=force
# filter a specific test case
env EXTRA_CARGO_ARGS=<testname> make test
make test EXTRA_CARGO_ARGS=<testname>
```

- 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.
Expand Down
4 changes: 2 additions & 2 deletions ctl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "raft-engine-ctl"
version = "0.2.0"
version = "0.3.0"
authors = ["The TiKV Project Developers"]
edition = "2018"
rust-version = "1.57"
Expand All @@ -11,4 +11,4 @@ license = "Apache-2.0"
[dependencies]
clap = { version = "3.1", features = ["derive", "cargo"] }
env_logger = "0.9"
raft-engine = { path = "..", version = "0.2.0", features = ["scripting", "internals"] }
raft-engine = { path = "..", version = "0.3.0", features = ["scripting", "internals"] }
7 changes: 4 additions & 3 deletions src/file_pipe_log/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ pub(super) fn lock_file_path<P: AsRef<Path>>(dir: P) -> PathBuf {
path
}

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

Expand All @@ -116,12 +117,12 @@ impl LogFileFormat {
}
}

pub const fn max_encode_len() -> usize {
pub const fn max_encoded_len() -> usize {
Self::header_len() + Self::payload_len(Version::V2)
}

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

Expand Down
8 changes: 4 additions & 4 deletions src/file_pipe_log/log_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ impl<F: FileSystem> LogFileWriter<F> {
written: file_size,
capacity: file_size,
};
// TODO: add tests for file_size in [header_len, max_encode_len].
if file_size < LogFileFormat::encode_len(format.version) || force_reset {
// TODO: add tests for file_size in [header_len, max_encoded_len].
if file_size < LogFileFormat::encoded_len(format.version) || force_reset {
f.write_header(format)?;
} else {
f.writer.seek(SeekFrom::Start(file_size as u64))?;
Expand All @@ -69,7 +69,7 @@ impl<F: FileSystem> LogFileWriter<F> {
fn write_header(&mut self, format: LogFileFormat) -> Result<()> {
self.writer.seek(SeekFrom::Start(0))?;
self.written = 0;
let mut buf = Vec::with_capacity(LogFileFormat::encode_len(format.version));
let mut buf = Vec::with_capacity(LogFileFormat::encoded_len(format.version));
format.encode(&mut buf)?;
self.write(&buf, 0)
}
Expand Down Expand Up @@ -165,7 +165,7 @@ impl<F: FileSystem> LogFileReader<F> {
/// to `0`, that is, the beginning of the file, to parse the
/// related `[LogFileFormat]`.
pub fn parse_format(&mut self) -> Result<LogFileFormat> {
let mut container = vec![0; LogFileFormat::max_encode_len()];
let mut container = vec![0; LogFileFormat::max_encoded_len()];
let size = self.read_to(0, &mut container)?;
container.truncate(size);
LogFileFormat::decode(&mut container.as_slice())
Expand Down
4 changes: 2 additions & 2 deletions src/file_pipe_log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ pub mod debug {
for from in formats {
for to in formats {
for shorter in [true, false] {
if LogFileFormat::encode_len(to.version)
< LogFileFormat::encode_len(from.version)
if LogFileFormat::encoded_len(to.version)
< LogFileFormat::encoded_len(from.version)
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/file_pipe_log/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ mod tests {
let pipe_log = new_test_pipes(&cfg).unwrap();
assert_eq!(pipe_log.file_span(queue), (1, 1));

let header_size = LogFileFormat::encode_len(cfg.format_version) as u64;
let header_size = LogFileFormat::encoded_len(cfg.format_version) as u64;

// generate file 1, 2, 3
let content: Vec<u8> = vec![b'a'; 1024];
Expand Down
2 changes: 1 addition & 1 deletion src/file_pipe_log/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<F: FileSystem> LogItemBatchFileReader<F> {
format: LogFileFormat,
reader: LogFileReader<F>,
) -> Result<()> {
self.valid_offset = LogFileFormat::encode_len(format.version);
self.valid_offset = LogFileFormat::encoded_len(format.version);
self.file_id = Some(file_id);
self.format = Some(format);
self.size = reader.file_size()?;
Expand Down
2 changes: 1 addition & 1 deletion stress/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "stress"
version = "0.2.0"
version = "0.3.0"
authors = ["The TiKV Authors"]
edition = "2018"

Expand Down

0 comments on commit b95dd01

Please sign in to comment.