Retry a Busy extension Stage so update checks do not strand plans (D-105)
This commit is contained in:
parent
312766e2a7
commit
b9fdd9da4f
1 changed files with 13 additions and 1 deletions
|
|
@ -116,7 +116,19 @@ impl Client {
|
|||
fn stage(&self, plan: Value) -> Result<Value,String> {
|
||||
let id = plan["plan_id"].as_str().ok_or("Missing prepared plan identity")?;
|
||||
self.output.borrow_mut().record("plan", &plan);
|
||||
self.operation(false,"Stage",&(id,self.options()))
|
||||
// A periodic update check (or another client) may hold a read-only
|
||||
// operation, which the daemon reports as Busy. Wait for it to finish
|
||||
// instead of leaving the freshly prepared extension plan unapplied.
|
||||
let deadline = Instant::now() + Duration::from_secs(180);
|
||||
loop {
|
||||
match self.operation(false,"Stage",&(id,self.options())) {
|
||||
Err(e) if e.contains("Error.Busy") && Instant::now() < deadline => {
|
||||
self.output.borrow_mut().progress("waiting-active-operation");
|
||||
std::thread::sleep(Duration::from_secs(5));
|
||||
}
|
||||
result => return result,
|
||||
}
|
||||
}
|
||||
}
|
||||
fn dispatch(&self, args: &[&str]) -> Result<Value,String> {
|
||||
match args {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue