feat: add "dropping" chunk lifecycle action
parent
68e20779a2
commit
e570c66697
|
@ -85,6 +85,9 @@ pub enum ChunkLifecycleAction {
|
|||
|
||||
/// Chunk is in the process of being compacted
|
||||
Compacting,
|
||||
|
||||
/// Chunk is about to be dropped from memory and (if persisted) from object store
|
||||
Dropping,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ChunkLifecycleAction {
|
||||
|
@ -99,6 +102,7 @@ impl ChunkLifecycleAction {
|
|||
Self::Moving => "Moving to the Read Buffer",
|
||||
Self::Persisting => "Persisting to Object Storage",
|
||||
Self::Compacting => "Compacting",
|
||||
Self::Dropping => "Dropping",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@ enum ChunkLifecycleAction {
|
|||
|
||||
/// Chunk is in the process of being compacted
|
||||
CHUNK_LIFECYCLE_ACTION_COMPACTING = 3;
|
||||
|
||||
/// Chunk is about to be dropped from memory and (if persisted) from object store.
|
||||
CHUNK_LIFECYCLE_ACTION_DROPPING = 4;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ impl From<Option<ChunkLifecycleAction>> for management::ChunkLifecycleAction {
|
|||
Some(ChunkLifecycleAction::Moving) => Self::Moving,
|
||||
Some(ChunkLifecycleAction::Persisting) => Self::Persisting,
|
||||
Some(ChunkLifecycleAction::Compacting) => Self::Compacting,
|
||||
Some(ChunkLifecycleAction::Dropping) => Self::Dropping,
|
||||
None => Self::Unspecified,
|
||||
}
|
||||
}
|
||||
|
@ -167,6 +168,7 @@ impl TryFrom<management::ChunkLifecycleAction> for Option<ChunkLifecycleAction>
|
|||
management::ChunkLifecycleAction::Compacting => {
|
||||
Ok(Some(ChunkLifecycleAction::Compacting))
|
||||
}
|
||||
management::ChunkLifecycleAction::Dropping => Ok(Some(ChunkLifecycleAction::Dropping)),
|
||||
management::ChunkLifecycleAction::Unspecified => Ok(None),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -815,6 +815,11 @@ impl CatalogChunk {
|
|||
}
|
||||
}
|
||||
|
||||
/// Start lifecycle action that should result in the chunk being dropped from memory and (if persisted) from object store.
|
||||
pub fn set_dropping(&mut self, registration: &TaskRegistration) -> Result<()> {
|
||||
self.set_lifecycle_action(ChunkLifecycleAction::Dropping, registration)
|
||||
}
|
||||
|
||||
/// Set the chunk's in progress lifecycle action or return an error if already in-progress
|
||||
fn set_lifecycle_action(
|
||||
&mut self,
|
||||
|
@ -925,6 +930,15 @@ mod tests {
|
|||
assert!(matches!(chunk.stage, ChunkStage::Frozen { .. }));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_drop() {
|
||||
let mut chunk = make_open_chunk();
|
||||
let registration = TaskRegistration::new();
|
||||
|
||||
// drop it
|
||||
chunk.set_dropping(®istration).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lifecycle_action() {
|
||||
let mut chunk = make_open_chunk();
|
||||
|
|
Loading…
Reference in New Issue