Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
allow janus to return state=already_running to work around vacuum ove…
Browse files Browse the repository at this point in the history
…rlaps
  • Loading branch information
khodzha committed Dec 7, 2020
1 parent 1c27500 commit 3a58024
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/backend/janus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ use self::transactions::Transaction;
const STREAM_UPLOAD_METHOD: &str = "stream.upload";
pub(crate) const JANUS_API_VERSION: &str = "v1";

const ALREADY_RUNNING_STATE: &str = "already_running";

pub(crate) trait OpaqueId {
fn opaque_id(&self) -> &str;
}
Expand Down Expand Up @@ -306,6 +308,12 @@ async fn handle_response_impl<C: Context>(
.error(AppErrorKind::MessageParsingFailed)
})?;

// if vacuuming was already started by previous request - just do nothing
let maybe_already_running = plugin_data.get("state").and_then(|v| v.as_str()) == Some(ALREADY_RUNNING_STATE);
if maybe_already_running {
return Ok(Box::new(stream::empty()) as MessageStream);
}

let started_at = plugin_data
.get("started_at")
.ok_or_else(|| anyhow!("Missing 'started_at' in response"))
Expand Down

0 comments on commit 3a58024

Please sign in to comment.