-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
storage: track latest reported status and report on reconnect #30576
Merged
aljoscha
merged 2 commits into
MaterializeInc:main
from
aljoscha:storage-report-latest-status-on-reconnect
Feb 10, 2025
+51
−12
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,7 +230,9 @@ impl<'w, A: Allocate> Worker<'w, A> { | |
timely_worker.index(), | ||
timely_worker.peers(), | ||
), | ||
object_status_updates: Default::default(), | ||
shared_status_updates: Default::default(), | ||
latest_status_updates: Default::default(), | ||
reported_status_updates: Default::default(), | ||
internal_cmd_tx, | ||
internal_cmd_rx, | ||
read_only_tx, | ||
|
@@ -308,11 +310,20 @@ pub struct StorageState { | |
/// Statistics for sources and sinks. | ||
pub aggregated_statistics: AggregatedStatistics, | ||
|
||
/// Status updates reported by health operators. | ||
/// A place shared with running dataflows, so that health operators, can | ||
/// report status updates back to us. | ||
/// | ||
/// **NOTE**: Operators that append to this collection should take care to only add new | ||
/// status updates if the status of the ingestion/export in question has _changed_. | ||
pub object_status_updates: Rc<RefCell<Vec<StatusUpdate>>>, | ||
pub shared_status_updates: Rc<RefCell<Vec<StatusUpdate>>>, | ||
|
||
/// The latest status update for each object. | ||
pub latest_status_updates: BTreeMap<GlobalId, StatusUpdate>, | ||
|
||
/// The latest status update that has been _reported_ back to the | ||
/// controller. This will be reset when a new client connects, so that we | ||
/// can determine what updates we have to report again. | ||
pub reported_status_updates: BTreeMap<GlobalId, StatusUpdate>, | ||
|
||
/// Sender for cluster-internal storage commands. These can be sent from | ||
/// within workers/operators and will be distributed to all workers. For | ||
|
@@ -458,13 +469,7 @@ impl<'w, A: Allocate> Worker<'w, A> { | |
self.report_frontier_progress(&response_tx); | ||
self.process_oneshot_ingestions(&response_tx); | ||
|
||
// Report status updates if any are present | ||
if self.storage_state.object_status_updates.borrow().len() > 0 { | ||
self.send_storage_response( | ||
&response_tx, | ||
StorageResponse::StatusUpdates(self.storage_state.object_status_updates.take()), | ||
); | ||
} | ||
self.report_status_updates(&response_tx); | ||
|
||
if last_stats_time.elapsed() >= stats_interval { | ||
self.report_storage_statistics(&response_tx); | ||
|
@@ -831,6 +836,50 @@ impl<'w, A: Allocate> Worker<'w, A> { | |
} | ||
} | ||
|
||
/// Pumps latest status updates from the buffer shared with operators and | ||
/// reports any updates that need reporting. | ||
pub fn report_status_updates(&mut self, response_tx: &ResponseSender) { | ||
let mut to_report = Vec::new(); | ||
|
||
// Pump updates into our state and stage them for reporting. | ||
if self.storage_state.shared_status_updates.borrow().len() > 0 { | ||
for shared_update in self.storage_state.shared_status_updates.take() { | ||
let id = shared_update.id; | ||
|
||
to_report.push(shared_update.clone()); | ||
|
||
self.storage_state | ||
.latest_status_updates | ||
.insert(id, shared_update.clone()); | ||
self.storage_state | ||
.reported_status_updates | ||
.insert(id, shared_update); | ||
} | ||
} | ||
|
||
// We reset what we have reported when a new client/controller connects, | ||
// such that we can re-send our latest status updates. | ||
// | ||
// And here we report any status where our latest known status differs | ||
// from what has been reported. | ||
for (id, latest_update) in self.storage_state.latest_status_updates.iter() { | ||
let reported_update = self.storage_state.reported_status_updates.get(id); | ||
if let Some(reported_update) = reported_update { | ||
if reported_update == latest_update { | ||
continue; | ||
} | ||
} | ||
to_report.push(latest_update.clone()); | ||
self.storage_state | ||
.reported_status_updates | ||
.insert(id.clone(), latest_update.clone()); | ||
} | ||
|
||
if to_report.len() > 0 { | ||
self.send_storage_response(response_tx, StorageResponse::StatusUpdates(to_report)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A place that's going to conflict with #31261 (fyi @petrosagg) |
||
} | ||
} | ||
|
||
/// Report source statistics back to the controller. | ||
pub fn report_storage_statistics(&mut self, response_tx: &ResponseSender) { | ||
let (sources, sinks) = self.storage_state.aggregated_statistics.emit_local(); | ||
|
@@ -1135,6 +1184,9 @@ impl<'w, A: Allocate> Worker<'w, A> { | |
*frontier = Antichain::from_elem(<_>::minimum()); | ||
} | ||
|
||
// Reset the reported status updates for the remaining objects. | ||
self.storage_state.reported_status_updates.clear(); | ||
|
||
// Execute the modified commands. | ||
for command in commands { | ||
self.storage_state.handle_storage_command(command); | ||
|
@@ -1288,6 +1340,8 @@ impl StorageState { | |
self.ingestions.remove(&id); | ||
self.exports.remove(&id); | ||
|
||
let _ = self.reported_status_updates.remove(&id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we need to remove the |
||
|
||
// This will stop reporting of frontiers. | ||
// | ||
// If this object still has its frontiers reported, we will notify the | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existence of this map surprises me! Naively I'd have thought that we can just unconditionally send the contents of
latest_status_updates
on reconnect. Or, if that's somehow hard to set up, wouldn't aninitial_status_reported
flag suffice?