spetz commented on code in PR #1624:
URL: https://github.com/apache/iggy/pull/1624#discussion_r1991823050
##########
server/src/state/system.rs:
##########
@@ -241,6 +241,26 @@ impl SystemState {
topic.partitions.remove(&(last_partition_id - i));
}
}
+ EntryCommand::DeleteSegments(command) => {
+ let stream_id = find_stream_id(&streams,
&command.stream_id);
+ let stream = streams
+ .get_mut(&stream_id)
+ .unwrap_or_else(|| panic!("{}", format!("Stream:
{stream_id} not found")));
+ let topic_id = find_topic_id(&stream.topics,
&command.topic_id);
+ let topic = stream
+ .topics
+ .get_mut(&topic_id)
+ .unwrap_or_else(|| panic!("{}", format!("Topic:
{topic_id} not found")));
+ if topic.partitions.is_empty() {
+ continue;
+ }
+
+ let partition_id = command.partition_id;
+
+ let _partition =
topic.partitions.get(&command.partition_id).unwrap_or_else(|| panic!("{}",
format!("Partition {partition_id} not found.")));
+
+ // HOWTO: get the segments from PartitionState?
Review Comment:
The whole idea behind the state, is to have the ordered log of all the
actions related to managing the resources (streams, topics, partitions, users
etc.) - for each command producing the "side effects", there's an entry
appended to the log, and when the server starts, it loads all the log entries
to initialize its current state.
This is also critical for the replication purposes.
However, when it comes to the segments, it's probably not needed here, so do
not bother with the state at this point.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]