Skip to content

Commit 60075af

Browse files
committed
fix(cubestore): Immediately restart stale streaming jobs to avoid processing gaps for sparse streams
1 parent 93d5bd1 commit 60075af

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

rust/cubestore/cubestore/src/scheduler/mod.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::cluster::{pick_worker_by_ids, Cluster};
22
use crate::config::ConfigObj;
3-
use crate::metastore::job::{Job, JobType};
3+
use crate::metastore::job::{Job, JobStatus, JobType};
44
use crate::metastore::partition::partition_file_name;
55
use crate::metastore::table::Table;
66
use crate::metastore::{
@@ -490,6 +490,21 @@ impl SchedulerImpl {
490490
}
491491
}
492492
}
493+
if let MetaStoreEvent::UpdateJob(_, new_job) = &event {
494+
match new_job.get_row().job_type() {
495+
JobType::TableImportCSV(location) if Table::is_stream_location(location) => {
496+
match new_job.get_row().status() {
497+
JobStatus::Error(e) if e.contains("Stale stream timeout") => {
498+
log::info!("Removing stale stream job: {:?}", new_job);
499+
self.meta_store.delete_job(new_job.get_id()).await?;
500+
self.reconcile_table_imports().await?;
501+
}
502+
_ => {}
503+
}
504+
}
505+
_ => {}
506+
}
507+
}
493508
if let MetaStoreEvent::DeleteJob(job) = event {
494509
match job.get_row().job_type() {
495510
JobType::RepartitionChunk => match job.get_row().row_reference() {

rust/cubestore/cubestore/src/streaming/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ impl StreamingService for StreamingServiceImpl {
118118
Duration::from_secs(self.config_obj.stale_stream_timeout()),
119119
stream.next(),
120120
)
121-
.await?
121+
.await
122+
.map_err(|e| CubeError::user(format!("Stale stream timeout: {}", e)))?
122123
{
123124
let rows = new_rows?;
124125
debug!("Received {} rows for {}", rows.len(), location);

0 commit comments

Comments
 (0)