Skip to content

Commit 0a33383

Browse files
authored
bump 0.4.0 (#330)
* cleanup Signed-off-by: tabokie <xy.tao@outlook.com> * lock version Signed-off-by: tabokie <xy.tao@outlook.com> * bump version Signed-off-by: tabokie <xy.tao@outlook.com> * update date Signed-off-by: tabokie <xy.tao@outlook.com> --------- Signed-off-by: tabokie <xy.tao@outlook.com>
1 parent d4943a9 commit 0a33383

File tree

15 files changed

+54
-24
lines changed

15 files changed

+54
-24
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [Unreleased]
44

5+
## [0.4.0] - 2023-09-01
6+
57
### Behavior Changes
68

79
* `LogBatch::put` returns a `Result<()>` instead of `()`. It errs when the key is reserved for internal use.

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.3.0"
3+
version = "0.4.0"
44
authors = ["The TiKV Project Developers"]
55
edition = "2018"
66
rust-version = "1.66.0"

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ clean:
4141
format:
4242
cargo ${TOOLCHAIN_ARGS} fmt --all
4343

44+
CLIPPY_WHITELIST += -A clippy::bool_assert_comparison
4445
## Run clippy.
4546
clippy:
4647
ifdef WITH_NIGHTLY_FEATURES
47-
cargo ${TOOLCHAIN_ARGS} clippy --all --features nightly_group,failpoints --all-targets -- -D clippy::all
48+
cargo ${TOOLCHAIN_ARGS} clippy --all --features nightly_group,failpoints --all-targets -- -D clippy::all ${CLIPPY_WHITELIST}
4849
else
49-
cargo ${TOOLCHAIN_ARGS} clippy --all --features failpoints --all-targets -- -D clippy::all
50+
cargo ${TOOLCHAIN_ARGS} clippy --all --features failpoints --all-targets -- -D clippy::all ${CLIPPY_WHITELIST}
5051
endif
5152

5253
## Run tests.

README.md

Lines changed: 1 addition & 1 deletion
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.3.0"
57+
raft-engine = "0.4.0"
5858
```
5959

6060
Available Cargo features:

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.3.0"
3+
version = "0.4.0"
44
authors = ["The TiKV Project Developers"]
55
edition = "2018"
66
rust-version = "1.61.0"
@@ -11,4 +11,4 @@ license = "Apache-2.0"
1111
[dependencies]
1212
clap = { version = "3.1", features = ["derive", "cargo"] }
1313
env_logger = "0.10"
14-
raft-engine = { path = "..", version = "0.3.0", features = ["scripting", "internals"] }
14+
raft-engine = { path = "..", version = "0.4.0", features = ["scripting", "internals"] }

src/config.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ mod tests {
284284
assert_eq!(load.target_file_size, ReadableSize::mb(1));
285285
assert_eq!(load.purge_threshold, ReadableSize::mb(3));
286286
assert_eq!(load.format_version, Version::V1);
287+
assert_eq!(load.enable_log_recycle, false);
288+
assert_eq!(load.prefill_for_recycle, false);
287289
load.sanitize().unwrap();
288290
}
289291

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

299301
let soft_error = r#"
300-
recovery-read-block-size = "1KB"
302+
recovery-read-block-size = 1
301303
recovery-threads = 0
302304
target-file-size = "5000MB"
303305
format-version = 2
304306
enable-log-recycle = true
305307
prefill-for-recycle = true
306308
"#;
307309
let soft_load: Config = toml::from_str(soft_error).unwrap();
310+
assert!(soft_load.recovery_read_block_size.0 < MIN_RECOVERY_READ_BLOCK_SIZE as u64);
311+
assert!(soft_load.recovery_threads < MIN_RECOVERY_THREADS);
308312
let mut soft_sanitized = soft_load;
309313
soft_sanitized.sanitize().unwrap();
310314
assert!(soft_sanitized.recovery_read_block_size.0 >= MIN_RECOVERY_READ_BLOCK_SIZE as u64);
@@ -313,8 +317,6 @@ mod tests {
313317
soft_sanitized.purge_rewrite_threshold.unwrap(),
314318
soft_sanitized.target_file_size
315319
);
316-
assert_eq!(soft_sanitized.format_version, Version::V2);
317-
assert!(soft_sanitized.enable_log_recycle);
318320

319321
let recycle_error = r#"
320322
enable-log-recycle = true

src/engine.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ pub(crate) mod tests {
13241324
engine.append(rid, index, index + 1, Some(&data));
13251325
}
13261326
}
1327+
engine.append(11, 1, 11, Some(&data));
13271328

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

1345-
// Recover with rewrite queue and append queue.
1346+
engine.clean(11);
13461347
let cleaned_region_ids = engine.memtables.cleaned_region_ids();
1348+
assert_eq!(cleaned_region_ids.len(), 1);
13471349

13481350
let engine = engine.reopen();
13491351
assert_eq!(engine.memtables.cleaned_region_ids(), cleaned_region_ids);
@@ -2438,13 +2440,15 @@ pub(crate) mod tests {
24382440
lb.drain();
24392441
};
24402442
{
2443+
// begin.
24412444
let mut builder = AtomicGroupBuilder::with_id(3);
24422445
builder.begin(&mut log_batch);
24432446
log_batch.put(rid, key.clone(), value.clone()).unwrap();
24442447
flush(&mut log_batch);
24452448
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
24462449
}
24472450
{
2451+
// begin - unrelated - end.
24482452
let mut builder = AtomicGroupBuilder::with_id(3);
24492453
builder.begin(&mut log_batch);
24502454
rid += 1;
@@ -2464,6 +2468,7 @@ pub(crate) mod tests {
24642468
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
24652469
}
24662470
{
2471+
// begin - middle - middle - end.
24672472
let mut builder = AtomicGroupBuilder::with_id(3);
24682473
builder.begin(&mut log_batch);
24692474
rid += 1;
@@ -2488,6 +2493,7 @@ pub(crate) mod tests {
24882493
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
24892494
}
24902495
{
2496+
// begin - begin - end.
24912497
let mut builder = AtomicGroupBuilder::with_id(3);
24922498
builder.begin(&mut log_batch);
24932499
rid += 1;
@@ -2507,6 +2513,7 @@ pub(crate) mod tests {
25072513
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
25082514
}
25092515
{
2516+
// end - middle - end.
25102517
// We must change id to avoid getting merged with last group.
25112518
// It is actually not possible in real life to only have "begin" missing.
25122519
let mut builder = AtomicGroupBuilder::with_id(4);
@@ -2528,6 +2535,7 @@ pub(crate) mod tests {
25282535
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
25292536
}
25302537
{
2538+
// end - begin - end
25312539
let mut builder = AtomicGroupBuilder::with_id(5);
25322540
builder.begin(&mut LogBatch::default());
25332541
builder.end(&mut log_batch);
@@ -2547,6 +2555,26 @@ pub(crate) mod tests {
25472555
flush(&mut log_batch);
25482556
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
25492557
}
2558+
{
2559+
// begin - end - begin - end.
2560+
let mut builder = AtomicGroupBuilder::with_id(6);
2561+
builder.begin(&mut log_batch);
2562+
rid += 1;
2563+
log_batch.put(rid, key.clone(), value.clone()).unwrap();
2564+
data.insert(rid);
2565+
flush(&mut log_batch);
2566+
builder.end(&mut log_batch);
2567+
flush(&mut log_batch);
2568+
let mut builder = AtomicGroupBuilder::with_id(7);
2569+
builder.begin(&mut log_batch);
2570+
flush(&mut log_batch);
2571+
builder.end(&mut log_batch);
2572+
rid += 1;
2573+
log_batch.put(rid, key.clone(), value.clone()).unwrap();
2574+
data.insert(rid);
2575+
flush(&mut log_batch);
2576+
engine.pipe_log.rotate(LogQueue::Rewrite).unwrap();
2577+
}
25502578
engine.pipe_log.sync(LogQueue::Rewrite).unwrap();
25512579

25522580
let engine = engine.reopen();

src/env/default.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) 2017-present, PingCAP, Inc. Licensed under Apache-2.0.
22

3-
use std::io::{Error, ErrorKind, Read, Result as IoResult, Seek, SeekFrom, Write};
3+
#[cfg(feature = "failpoints")]
4+
use std::io::{Error, ErrorKind};
5+
use std::io::{Read, Result as IoResult, Seek, SeekFrom, Write};
46
use std::path::Path;
57
use std::sync::Arc;
68

src/env/log_fd/plain.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// Copyright (c) 2017-present, PingCAP, Inc. Licensed under Apache-2.0.
22

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

58
use fail::fail_point;

src/file_pipe_log/pipe.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ pub const DEFAULT_PATH_ID: PathId = 0;
3333
/// compatibility.
3434
pub const DEFAULT_FIRST_FILE_SEQ: FileSeq = 1;
3535

36-
#[derive(Debug)]
3736
pub struct File<F: FileSystem> {
3837
pub seq: FileSeq,
3938
pub handle: Arc<F::Handle>,

0 commit comments

Comments
 (0)