Skip to content

Commit

Permalink
bump 0.4.0 (#330)
Browse files Browse the repository at this point in the history
* cleanup

Signed-off-by: tabokie <[email protected]>

* lock version

Signed-off-by: tabokie <[email protected]>

* bump version

Signed-off-by: tabokie <[email protected]>

* update date

Signed-off-by: tabokie <[email protected]>

---------

Signed-off-by: tabokie <[email protected]>
  • Loading branch information
tabokie authored Sep 1, 2023
1 parent d4943a9 commit 0a33383
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 24 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

## [0.4.0] - 2023-09-01

### Behavior Changes

* `LogBatch::put` returns a `Result<()>` instead of `()`. It errs when the key is reserved for internal use.
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.3.0"
version = "0.4.0"
authors = ["The TiKV Project Developers"]
edition = "2018"
rust-version = "1.66.0"
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ clean:
format:
cargo ${TOOLCHAIN_ARGS} fmt --all

CLIPPY_WHITELIST += -A clippy::bool_assert_comparison
## Run clippy.
clippy:
ifdef WITH_NIGHTLY_FEATURES
cargo ${TOOLCHAIN_ARGS} clippy --all --features nightly_group,failpoints --all-targets -- -D clippy::all
cargo ${TOOLCHAIN_ARGS} clippy --all --features nightly_group,failpoints --all-targets -- -D clippy::all ${CLIPPY_WHITELIST}
else
cargo ${TOOLCHAIN_ARGS} clippy --all --features failpoints --all-targets -- -D clippy::all
cargo ${TOOLCHAIN_ARGS} clippy --all --features failpoints --all-targets -- -D clippy::all ${CLIPPY_WHITELIST}
endif

## Run tests.
Expand Down
2 changes: 1 addition & 1 deletion 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.3.0"
raft-engine = "0.4.0"
```

Available Cargo features:
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.3.0"
version = "0.4.0"
authors = ["The TiKV Project Developers"]
edition = "2018"
rust-version = "1.61.0"
Expand All @@ -11,4 +11,4 @@ license = "Apache-2.0"
[dependencies]
clap = { version = "3.1", features = ["derive", "cargo"] }
env_logger = "0.10"
raft-engine = { path = "..", version = "0.3.0", features = ["scripting", "internals"] }
raft-engine = { path = "..", version = "0.4.0", features = ["scripting", "internals"] }
8 changes: 5 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ mod tests {
assert_eq!(load.target_file_size, ReadableSize::mb(1));
assert_eq!(load.purge_threshold, ReadableSize::mb(3));
assert_eq!(load.format_version, Version::V1);
assert_eq!(load.enable_log_recycle, false);
assert_eq!(load.prefill_for_recycle, false);
load.sanitize().unwrap();
}

Expand All @@ -297,14 +299,16 @@ mod tests {
assert!(hard_load.sanitize().is_err());

let soft_error = r#"
recovery-read-block-size = "1KB"
recovery-read-block-size = 1
recovery-threads = 0
target-file-size = "5000MB"
format-version = 2
enable-log-recycle = true
prefill-for-recycle = true
"#;
let soft_load: Config = toml::from_str(soft_error).unwrap();
assert!(soft_load.recovery_read_block_size.0 < MIN_RECOVERY_READ_BLOCK_SIZE as u64);
assert!(soft_load.recovery_threads < MIN_RECOVERY_THREADS);
let mut soft_sanitized = soft_load;
soft_sanitized.sanitize().unwrap();
assert!(soft_sanitized.recovery_read_block_size.0 >= MIN_RECOVERY_READ_BLOCK_SIZE as u64);
Expand All @@ -313,8 +317,6 @@ mod tests {
soft_sanitized.purge_rewrite_threshold.unwrap(),
soft_sanitized.target_file_size
);
assert_eq!(soft_sanitized.format_version, Version::V2);
assert!(soft_sanitized.enable_log_recycle);

let recycle_error = r#"
enable-log-recycle = true
Expand Down
30 changes: 29 additions & 1 deletion src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,7 @@ pub(crate) mod tests {
engine.append(rid, index, index + 1, Some(&data));
}
}
engine.append(11, 1, 11, Some(&data));

// The engine needs purge, and all old entries should be rewritten.
assert!(engine
Expand All @@ -1342,8 +1343,9 @@ pub(crate) mod tests {
});
}

// Recover with rewrite queue and append queue.
engine.clean(11);
let cleaned_region_ids = engine.memtables.cleaned_region_ids();
assert_eq!(cleaned_region_ids.len(), 1);

let engine = engine.reopen();
assert_eq!(engine.memtables.cleaned_region_ids(), cleaned_region_ids);
Expand Down Expand Up @@ -2438,13 +2440,15 @@ pub(crate) mod tests {
lb.drain();
};
{
// begin.
let mut builder = AtomicGroupBuilder::with_id(3);
builder.begin(&mut log_batch);
log_batch.put(rid, key.clone(), value.clone()).unwrap();
flush(&mut log_batch);
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
}
{
// begin - unrelated - end.
let mut builder = AtomicGroupBuilder::with_id(3);
builder.begin(&mut log_batch);
rid += 1;
Expand All @@ -2464,6 +2468,7 @@ pub(crate) mod tests {
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
}
{
// begin - middle - middle - end.
let mut builder = AtomicGroupBuilder::with_id(3);
builder.begin(&mut log_batch);
rid += 1;
Expand All @@ -2488,6 +2493,7 @@ pub(crate) mod tests {
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
}
{
// begin - begin - end.
let mut builder = AtomicGroupBuilder::with_id(3);
builder.begin(&mut log_batch);
rid += 1;
Expand All @@ -2507,6 +2513,7 @@ pub(crate) mod tests {
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
}
{
// end - middle - end.
// We must change id to avoid getting merged with last group.
// It is actually not possible in real life to only have "begin" missing.
let mut builder = AtomicGroupBuilder::with_id(4);
Expand All @@ -2528,6 +2535,7 @@ pub(crate) mod tests {
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
}
{
// end - begin - end
let mut builder = AtomicGroupBuilder::with_id(5);
builder.begin(&mut LogBatch::default());
builder.end(&mut log_batch);
Expand All @@ -2547,6 +2555,26 @@ pub(crate) mod tests {
flush(&mut log_batch);
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
}
{
// begin - end - begin - end.
let mut builder = AtomicGroupBuilder::with_id(6);
builder.begin(&mut log_batch);
rid += 1;
log_batch.put(rid, key.clone(), value.clone()).unwrap();
data.insert(rid);
flush(&mut log_batch);
builder.end(&mut log_batch);
flush(&mut log_batch);
let mut builder = AtomicGroupBuilder::with_id(7);
builder.begin(&mut log_batch);
flush(&mut log_batch);
builder.end(&mut log_batch);
rid += 1;
log_batch.put(rid, key.clone(), value.clone()).unwrap();
data.insert(rid);
flush(&mut log_batch);
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
}
engine.pipe_log.sync(LogQueue::Rewrite).unwrap();

let engine = engine.reopen();
Expand Down
4 changes: 3 additions & 1 deletion src/env/default.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2017-present, PingCAP, Inc. Licensed under Apache-2.0.

use std::io::{Error, ErrorKind, Read, Result as IoResult, Seek, SeekFrom, Write};
#[cfg(feature = "failpoints")]
use std::io::{Error, ErrorKind};
use std::io::{Read, Result as IoResult, Seek, SeekFrom, Write};
use std::path::Path;
use std::sync::Arc;

Expand Down
3 changes: 3 additions & 0 deletions src/env/log_fd/plain.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright (c) 2017-present, PingCAP, Inc. Licensed under Apache-2.0.

//! A naive file handle implementation based on standard `File`. All I/O
//! operations need to synchronize under a `RwLock`.
use crate::env::{Handle, Permission};

use fail::fail_point;
Expand Down
1 change: 0 additions & 1 deletion src/file_pipe_log/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub const DEFAULT_PATH_ID: PathId = 0;
/// compatibility.
pub const DEFAULT_FIRST_FILE_SEQ: FileSeq = 1;

#[derive(Debug)]
pub struct File<F: FileSystem> {
pub seq: FileSeq,
pub handle: Arc<F::Handle>,
Expand Down
9 changes: 2 additions & 7 deletions src/log_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,6 @@ impl LogItemBatch {
self.items.drain(..)
}

pub fn push(&mut self, item: LogItem) {
self.item_size += item.approximate_size();
self.items.push(item);
}

pub fn merge(&mut self, rhs: &mut LogItemBatch) {
for item in &mut rhs.items {
if let LogItemContent::EntryIndexes(entry_indexes) = &mut item.content {
Expand Down Expand Up @@ -1582,7 +1577,7 @@ mod tests {
}

#[test]
fn test_corruption() {
fn test_header_corruption() {
let region_id = 7;
let data = vec![b'x'; 16];
let mut batch = LogBatch::default();
Expand Down Expand Up @@ -1688,7 +1683,7 @@ mod tests {
batch_handle.len = len;
let file_context = LogFileContext::new(batch_handle.id, Version::V2);
batch.prepare_write(&file_context).unwrap();
// batch.finish_write(batch_handle);
assert_eq!(batch.approximate_size(), len);
let encoded = batch.encoded_bytes();
assert_eq!(encoded.len(), len);
let mut bytes_slice = encoded;
Expand Down
3 changes: 1 addition & 2 deletions src/memtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ impl<A: AllocatorTrait> MemTableAccessor<A> {
/// [`MemTable`]s.
///
/// This method is only used for recovery.
#[allow(dead_code)]
#[cfg(test)]
pub fn cleaned_region_ids(&self) -> HashSet<u64> {
let mut ids = HashSet::default();
let removed_memtables = self.removed_memtables.lock();
Expand Down Expand Up @@ -1202,7 +1202,6 @@ fn has_internal_key(item: &LogItem) -> bool {
matches!(&item.content, LogItemContent::Kv(KeyValue { key, .. }) if crate::is_internal_key(key, None))
}

#[derive(Debug)]
struct PendingAtomicGroup {
status: AtomicGroupStatus,
items: Vec<LogItem>,
Expand Down
1 change: 0 additions & 1 deletion src/pipe_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ impl Display for Version {
}
}

#[derive(Debug, Clone)]
pub struct LogFileContext {
pub id: FileId,
pub version: Version,
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ pub mod lz4 {
}
} else if !src.is_empty() {
Err(Error::Corruption(format!(
"Content to compress to short {}",
"Content to compress too short {}",
src.len()
)))
} else {
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.3.0"
version = "0.4.0"
authors = ["The TiKV Authors"]
edition = "2018"

Expand Down

0 comments on commit 0a33383

Please sign in to comment.