Skip to content

Commit

Permalink
pass ut
Browse files Browse the repository at this point in the history
  • Loading branch information
wcy-fdu committed Oct 30, 2023
1 parent 9cf7b91 commit b576ca9
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/batch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ workspace-hack = { path = "../workspace-hack" }
criterion = { workspace = true, features = ["async_tokio", "async"] }
rand = "0.8"
risingwave_expr_impl = { workspace = true }
risingwave_hummock_sdk = { workspace = true , features = ["enable_test_epoch"]}
tempfile = "3"
tikv-jemallocator = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion src/common/src/util/epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Epoch {
let physical_now = Epoch::physical_now();
let prev_physical_time = self.physical_time();

// The last eight bits of the previous epoch ((prev_epoch + 1, prev_epoch + 255)) will be
// The last 16 bits of the previous epoch ((prev_epoch + 1, prev_epoch + 65536)) will be
// used as the gap epoch when the mem table spill occurs.
let next_epoch = match physical_now.cmp(&prev_physical_time) {
Ordering::Greater => Self::from_physical_time(physical_now),
Expand Down
1 change: 1 addition & 0 deletions src/compute/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ workspace-hack = { path = "../workspace-hack" }

[dev-dependencies]
futures-async-stream = { workspace = true }
risingwave_hummock_sdk = { workspace = true , features = ["enable_test_epoch"]}
rand = "0.8"
tempfile = "3"

Expand Down
3 changes: 3 additions & 0 deletions src/ctl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ uuid = { version = "1", features = ["v4"] }
[target.'cfg(not(madsim))'.dependencies]
workspace-hack = { path = "../workspace-hack" }

[dev-dependencies]
risingwave_hummock_sdk = { workspace = true , features = ["enable_test_epoch"]}

[lints]
workspace = true
1 change: 1 addition & 0 deletions src/jni_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ tracing = "0.1"

[dev-dependencies]
risingwave_expr = { workspace = true }
risingwave_hummock_sdk = { workspace = true , features = ["enable_test_epoch"]}

[lints]
workspace = true
1 change: 1 addition & 0 deletions src/meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ assert_matches = "1"
maplit = "1.0.2"
rand = "0.8"
risingwave_test_runner = { workspace = true }
risingwave_hummock_sdk = { workspace = true , features = ["enable_test_epoch"]}

[features]
test = []
Expand Down
3 changes: 3 additions & 0 deletions src/rpc_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ tower = "0.4"
tracing = "0.1"
url = "2.4.1"

[dev-dependencies]
risingwave_hummock_sdk = { workspace = true , features = ["enable_test_epoch"]}

[target.'cfg(not(madsim))'.dependencies]
workspace-hack = { path = "../workspace-hack" }

Expand Down
1 change: 1 addition & 0 deletions src/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ workspace-hack = { path = "../workspace-hack" }
[dev-dependencies]
criterion = { workspace = true, features = ["async_futures"] }
moka = { version = "0.12", features = ["future"] }
risingwave_hummock_sdk = { workspace = true , features = ["enable_test_epoch"]}
risingwave_test_runner = { workspace = true }
uuid = { version = "1", features = ["v4"] }

Expand Down
3 changes: 3 additions & 0 deletions src/storage/backup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ serde_json = "1"
thiserror = "1"
twox-hash = "1"

[dev-dependencies]
risingwave_hummock_sdk = { workspace = true , features = ["enable_test_epoch"]}

[lints]
workspace = true
4 changes: 4 additions & 0 deletions src/storage/hummock_sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ workspace-hack = { path = "../../workspace-hack" }

[lints]
workspace = true

[features]
enable_test_epoch = []

26 changes: 20 additions & 6 deletions src/storage/hummock_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,18 +268,25 @@ pub fn version_checkpoint_dir(checkpoint_path: &str) -> String {
}

// const EPOCH_AVAILABLE_BITS: u64 = 16;
const EPOCH_MASK: u64 = 0xFFFF;
#[derive(Clone, Copy, PartialEq, Eq, Hash, Default, Debug, PartialOrd, Ord)]
pub struct EpochWithGap(u64);

impl EpochWithGap {
pub fn new(epoch: u64, spill_offset: u64) -> Self {
let epoch_with_gap = epoch + spill_offset;
EpochWithGap(epoch_with_gap)
#[cfg(not(feature = "enable_test_epoch"))]
{
let epoch_with_gap = epoch + spill_offset;
EpochWithGap(epoch_with_gap)
}
#[cfg(feature = "enable_test_epoch")]
{
let epoch_with_gap = epoch + spill_offset - spill_offset;
EpochWithGap(epoch_with_gap)
}
}

pub fn new_from_epoch(epoch_with_gap: u64) -> Self {
// debug_assert_eq!(epoch_with_gap % EPOCH_AVAILABLE_BITS, 0);

EpochWithGap(epoch_with_gap)
}

Expand All @@ -298,10 +305,17 @@ impl EpochWithGap {

// return the pure epoch without spill offset
pub fn pure_epoch(&self) -> HummockEpoch {
self.0 & !0xFFFF
#[cfg(not(feature = "enable_test_epoch"))]
{
self.0 & !EPOCH_MASK
}
#[cfg(feature = "enable_test_epoch")]
{
self.0
}
}

pub fn offset(&self) -> u64 {
self.0 & 0xFFFF
self.0 & EPOCH_MASK
}
}
1 change: 1 addition & 0 deletions src/storage/hummock_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ futures = { version = "0.3", default-features = false, features = [

futures-async-stream = "0.2.9"
risingwave_test_runner = { workspace = true }
risingwave_hummock_sdk = { workspace = true , features = ["enable_test_epoch"]}
serial_test = "2.0"
sync-point = { path = "../../utils/sync-point" }

Expand Down
8 changes: 4 additions & 4 deletions src/storage/hummock_test/src/state_store_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,13 +1446,13 @@ async fn test_replicated_local_hummock_storage() {
[
Ok(
(
FullKey { UserKey { 233, TableKey { 000061616161 } }, 1 },
FullKey { UserKey { 233, TableKey { 000061616161 } }, epoch: 1, epoch_with_gap: 1},
b"1111",
),
),
Ok(
(
FullKey { UserKey { 233, TableKey { 000062626262 } }, 1 },
FullKey { UserKey { 233, TableKey { 000062626262 } }, epoch: 1, epoch_with_gap: 1},
b"2222",
),
),
Expand Down Expand Up @@ -1513,13 +1513,13 @@ async fn test_replicated_local_hummock_storage() {
[
Ok(
(
FullKey { UserKey { 233, TableKey { 000063636363 } }, 2 },
FullKey { UserKey { 233, TableKey { 000063636363 } }, epoch: 2, epoch_with_gap: 2},
b"3333",
),
),
Ok(
(
FullKey { UserKey { 233, TableKey { 000064646464 } }, 2 },
FullKey { UserKey { 233, TableKey { 000064646464 } }, epoch: 2, epoch_with_gap: 2},
b"4444",
),
),
Expand Down
1 change: 1 addition & 0 deletions src/storage/hummock_trace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ tracing = "0.1"
[dev-dependencies]
itertools = "0.10.5"
mockall = "0.11.4"
risingwave_hummock_sdk = { workspace = true , features = ["enable_test_epoch"]}

[lints]
workspace = true
1 change: 1 addition & 0 deletions src/stream/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ risingwave_expr_impl = { workspace = true }
risingwave_hummock_test = { path = "../storage/hummock_test", features = [
"test",
] }
risingwave_hummock_sdk = { workspace = true , features = ["enable_test_epoch"]}
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.9"
tracing-test = "0.2"
Expand Down
4 changes: 4 additions & 0 deletions src/tests/compaction_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ tokio = { version = "0.2", package = "madsim-tokio", features = [
] }
tracing = "0.1"

[dev-dependencies]
risingwave_hummock_sdk = { workspace = true , features = ["enable_test_epoch"]}


[target.'cfg(not(madsim))'.dependencies]
workspace-hack = { path = "../../workspace-hack" }

Expand Down

0 comments on commit b576ca9

Please sign in to comment.