Skip to content
Snippets Groups Projects
Commit f7b5a318 authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon:
Browse files

fix: used to panic when computing distant deadlines

parent 9485e9c1
No related branches found
No related tags found
1 merge request!565fix: used to panic when computing deadlines
Pipeline #19246 failed
use crate::tlog;
use crate::traft::Result;
use crate::traft::{error::Error, event, node, RaftIndex, RaftSpaceAccess};
use crate::util::instant_saturating_add;
use std::time::{Duration, Instant};
......@@ -28,7 +29,7 @@ pub fn wait_for_index_timeout(
raft_storage: &RaftSpaceAccess,
timeout: Duration,
) -> Result<RaftIndex> {
let deadline = Instant::now() + timeout;
let deadline = instant_saturating_add(Instant::now(), timeout);
loop {
let cur_applied = raft_storage.applied()?.unwrap_or(0);
if cur_applied >= applied {
......
......@@ -24,6 +24,7 @@ use crate::storage::SPACE_ID_INTERNAL_MAX;
use crate::storage::{set_local_schema_version, Clusterwide, ClusterwideSpaceId, PropertyName};
use crate::traft::op::{Ddl, DdlBuilder, Op};
use crate::traft::{self, event, node, RaftIndex};
use crate::util::instant_saturating_add;
/// Space definition.
///
......@@ -435,7 +436,7 @@ pub fn wait_for_ddl_commit(
timeout: Duration,
) -> traft::Result<RaftIndex> {
let raft_storage = &node::global()?.raft_storage;
let deadline = Instant::now() + timeout;
let deadline = instant_saturating_add(Instant::now(), timeout);
let last_seen = prepare_commit;
loop {
let cur_applied = raft_storage.applied()?.expect("commit is always persisted");
......@@ -468,7 +469,7 @@ fn wait_for_no_pending_schema_change(
storage: &Clusterwide,
timeout: Duration,
) -> traft::Result<()> {
let deadline = Instant::now() + timeout;
let deadline = instant_saturating_add(Instant::now(), timeout);
loop {
if storage.properties.pending_schema_change()?.is_none() {
return Ok(());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment