Skip to content

Commit

Permalink
refactor: Move manifest manager lock to MitoRegion (#3689)
Browse files Browse the repository at this point in the history
* feat: remove manager inner wip

* feat: put manifest lock in region

* feat: don't update manifest if manager is stopped

* chore: address CR comments
  • Loading branch information
evenyag authored Apr 15, 2024
1 parent 75d85f9 commit 2f4726f
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 188 deletions.
4 changes: 2 additions & 2 deletions src/mito2/src/engine/catchup_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ async fn test_catchup_with_manifest_update() {
// Ensures the mutable is empty.
assert!(region.version().memtables.mutable.is_empty());

let manifest = region.manifest_manager.manifest().await;
let manifest = region.manifest_manager.read().await.manifest();
assert_eq!(manifest.manifest_version, 0);

let resp = follower_engine
Expand All @@ -361,7 +361,7 @@ async fn test_catchup_with_manifest_update() {

// The inner region was replaced. We must get it again.
let region = follower_engine.get_region(region_id).unwrap();
let manifest = region.manifest_manager.manifest().await;
let manifest = region.manifest_manager.read().await.manifest();
assert_eq!(manifest.manifest_version, 2);
assert!(!region.is_writable());

Expand Down
7 changes: 7 additions & 0 deletions src/mito2/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,12 @@ pub enum Error {

#[snafu(display("checksum mismatch (actual: {}, expected: {})", actual, expected))]
ChecksumMismatch { actual: u32, expected: u32 },

#[snafu(display("Region {} is stopped", region_id))]
RegionStopped {
region_id: RegionId,
location: Location,
},
}

pub type Result<T, E = Error> = std::result::Result<T, E>;
Expand Down Expand Up @@ -684,6 +690,7 @@ impl ErrorExt for Error {
BiError { .. } => StatusCode::Internal,
EncodeMemtable { .. } | ReadDataPart { .. } => StatusCode::Internal,
ChecksumMismatch { .. } => StatusCode::Unexpected,
RegionStopped { .. } => StatusCode::RegionNotReady,
}
}

Expand Down
Loading

0 comments on commit 2f4726f

Please sign in to comment.