-
Notifications
You must be signed in to change notification settings - Fork 560
Give indexing plan a time-based ID; use it to tiebreak publish tokens #6520
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -760,8 +760,8 @@ impl IndexingService { | |
| /// or not. | ||
| /// | ||
| /// If a pipeline actor has failed, this function just logs an error. | ||
| async fn assign_shards_to_pipelines(&mut self, tasks: &[IndexingTask]) { | ||
| for task in tasks { | ||
| async fn assign_shards_to_pipelines(&mut self, plan_request: &ApplyIndexingPlanRequest) { | ||
| for task in &plan_request.indexing_tasks { | ||
| if task.shard_ids.is_empty() { | ||
| continue; | ||
| } | ||
|
|
@@ -771,6 +771,7 @@ impl IndexingService { | |
| }; | ||
| let assignment = Assignment { | ||
| shard_ids: task.shard_ids.iter().cloned().collect(), | ||
| indexing_plan_id: plan_request.indexing_plan_id.clone(), | ||
| }; | ||
| let message = AssignShards(assignment); | ||
|
|
||
|
|
@@ -785,10 +786,10 @@ impl IndexingService { | |
| /// - Starting the pipelines that are not running. | ||
| async fn apply_indexing_plan( | ||
| &mut self, | ||
| tasks: &[IndexingTask], | ||
| plan_request: ApplyIndexingPlanRequest, | ||
|
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.
When an older Useful? React with 👍 / 👎. |
||
| ctx: &ActorContext<Self>, | ||
| ) -> Result<(), IndexingError> { | ||
| let pipeline_diff = self.compute_pipeline_diff(tasks); | ||
| let pipeline_diff = self.compute_pipeline_diff(&plan_request.indexing_tasks); | ||
|
|
||
| if !pipeline_diff.pipelines_to_shutdown.is_empty() { | ||
| self.shutdown_pipelines(&pipeline_diff.pipelines_to_shutdown) | ||
|
|
@@ -801,7 +802,7 @@ impl IndexingService { | |
| .spawn_pipelines(&pipeline_diff.pipelines_to_spawn, ctx) | ||
| .await?; | ||
| } | ||
| self.assign_shards_to_pipelines(tasks).await; | ||
| self.assign_shards_to_pipelines(&plan_request).await; | ||
| self.update_chitchat_running_plan().await; | ||
|
|
||
| if !spawn_pipeline_failures.is_empty() { | ||
|
|
@@ -1135,7 +1136,7 @@ impl Handler<ApplyIndexingPlanRequest> for IndexingService { | |
| ctx: &ActorContext<Self>, | ||
| ) -> Result<Self::Reply, ActorExitStatus> { | ||
| Ok(self | ||
| .apply_indexing_plan(&plan_request.indexing_tasks, ctx) | ||
| .apply_indexing_plan(plan_request, ctx) | ||
| .await | ||
| .map(|_| ApplyIndexingPlanResponse {})) | ||
| } | ||
|
|
@@ -1465,7 +1466,10 @@ mod tests { | |
| }, | ||
| ]; | ||
| indexing_service | ||
| .ask_for_res(ApplyIndexingPlanRequest { indexing_tasks }) | ||
| .ask_for_res(ApplyIndexingPlanRequest { | ||
| indexing_tasks, | ||
| indexing_plan_id: "01ARZ3NDEKTSV4RRFFQ69G5FAV".to_string(), | ||
| }) | ||
| .await | ||
| .unwrap(); | ||
| assert_eq!( | ||
|
|
@@ -1531,6 +1535,7 @@ mod tests { | |
| indexing_service | ||
| .ask_for_res(ApplyIndexingPlanRequest { | ||
| indexing_tasks: indexing_tasks.clone(), | ||
| indexing_plan_id: "01ARZ3NDEKTSV4RRFFQ69G5FAV".to_string(), | ||
| }) | ||
| .await | ||
| .unwrap(); | ||
|
|
@@ -1587,6 +1592,7 @@ mod tests { | |
| indexing_service | ||
| .ask_for_res(ApplyIndexingPlanRequest { | ||
| indexing_tasks: indexing_tasks.clone(), | ||
| indexing_plan_id: "01ARZ3NDEKTSV4RRFFQ69G5FAV".to_string(), | ||
| }) | ||
| .await | ||
| .unwrap(); | ||
|
|
@@ -1646,6 +1652,7 @@ mod tests { | |
| indexing_service | ||
| .ask_for_res(ApplyIndexingPlanRequest { | ||
| indexing_tasks: indexing_tasks.clone(), | ||
| indexing_plan_id: "01ARZ3NDEKTSV4RRFFQ69G5FAV".to_string(), | ||
| }) | ||
| .await | ||
| .unwrap(); | ||
|
|
@@ -1665,6 +1672,7 @@ mod tests { | |
| indexing_service | ||
| .ask_for_res(ApplyIndexingPlanRequest { | ||
| indexing_tasks: Vec::new(), | ||
| indexing_plan_id: "01ARZ3NDEKTSV4RRFFQ69G5FAV".to_string(), | ||
| }) | ||
| .await | ||
| .unwrap(); | ||
|
|
@@ -2072,6 +2080,7 @@ mod tests { | |
| params_fingerprint: 0, | ||
| }, | ||
| ], | ||
| indexing_plan_id: "01ARZ3NDEKTSV4RRFFQ69G5FAV".to_string(), | ||
| }) | ||
| .await | ||
| .unwrap(); | ||
|
|
||
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.
This relies on each later plan id comparing greater than the previous one, but
Ulid::new()does not guarantee monotonic sort order within the same millisecond. If two plans are applied in the same millisecond (for example via direct rebalance-triggered rebuilds), the newer plan can get a lexicographically smaller id, causingAcquireShardsto reject it as stale and leaving the older owner in place.Useful? React with 👍 / 👎.