Skip to content

Commit

Permalink
ensure ReadVersion is created with replication options
Browse files Browse the repository at this point in the history
  • Loading branch information
kwannoel committed Jun 9, 2023
1 parent 23ecee7 commit a1e3da4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,14 @@ impl HummockEventHandler {
HummockEvent::RegisterReadVersion {
table_id,
new_read_version_sender,
is_replicated,
} => {
let pinned_version = self.pinned_version.load();
let basic_read_version = Arc::new(RwLock::new(
HummockReadVersion::new((**pinned_version).clone()),
HummockReadVersion::new_with_replication_option(
(**pinned_version).clone(),
is_replicated,
),
));

let instance_id = self.generate_instance_id();
Expand Down
7 changes: 6 additions & 1 deletion src/storage/src/hummock/event_handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub enum HummockEvent {
table_id: TableId,
new_read_version_sender:
oneshot::Sender<(Arc<RwLock<HummockReadVersion>>, LocalInstanceGuard)>,
is_replicated: bool,
},

DestroyReadVersion {
Expand Down Expand Up @@ -116,7 +117,11 @@ impl HummockEvent {
HummockEvent::RegisterReadVersion {
table_id,
new_read_version_sender: _,
} => format!("RegisterReadVersion table_id {:?}", table_id,),
is_replicated,
} => format!(
"RegisterReadVersion table_id {:?}, is_replicated: {:?}",
table_id, is_replicated
),

HummockEvent::DestroyReadVersion {
table_id,
Expand Down
1 change: 1 addition & 0 deletions src/storage/src/hummock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ impl HummockStorage {
.send(HummockEvent::RegisterReadVersion {
table_id: option.table_id,
new_read_version_sender: tx,
is_replicated: option.is_replicated,
})
.unwrap();

Expand Down
11 changes: 5 additions & 6 deletions src/storage/src/hummock/store/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ pub struct HummockReadVersion {
}

impl HummockReadVersion {
fn new_inner(committed_version: CommittedVersion, is_replicated: bool) -> Self {
pub fn new_with_replication_option(
committed_version: CommittedVersion,
is_replicated: bool,
) -> Self {
// before build `HummockReadVersion`, we need to get the a initial version which obtained
// from meta. want this initialization after version is initialized (now with
// notification), so add a assert condition to guarantee correct initialization order
Expand All @@ -234,11 +237,7 @@ impl HummockReadVersion {
}

pub fn new(committed_version: CommittedVersion) -> Self {
Self::new_inner(committed_version, false)
}

pub fn new_replicated(committed_version: CommittedVersion) -> Self {
Self::new_inner(committed_version, true)
Self::new_with_replication_option(committed_version, false)
}

/// Updates the read version with `VersionUpdate`.
Expand Down

0 comments on commit a1e3da4

Please sign in to comment.