Skip to content

Commit

Permalink
Remove one more isntant usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Tatarintsev committed Nov 24, 2023
1 parent 18a8127 commit d04804d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl TransactionActorManager {
of the transaction. Consider increasing the interactive transaction timeout \
or doing less work in the transaction",
timeout.as_millis(),
start_time.elapsed().as_millis(),
start_time.elapsed_time().as_millis(),
)
}
None => {
Expand Down
5 changes: 3 additions & 2 deletions query-engine/core/src/interactive_transactions/actors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ use crate::{
TxId,
};
use connector::Connection;
use elapsed::ElapsedTimeCounter;
use schema::QuerySchemaRef;
use std::{collections::HashMap, sync::Arc};
use tokio::{
sync::{
mpsc::{channel, Receiver, Sender},
oneshot, RwLock,
},
time::{self, Duration, Instant},
time::{self, Duration},
};
use tracing::Span;
use tracing_futures::Instrument;
Expand Down Expand Up @@ -297,7 +298,7 @@ pub(crate) async fn spawn_itx_actor(
query_schema,
);

let start_time = Instant::now();
let start_time = ElapsedTimeCounter::start();
let sleep = time::sleep(timeout);
tokio::pin!(sleep);

Expand Down
10 changes: 7 additions & 3 deletions query-engine/core/src/interactive_transactions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::CoreError;
use connector::Transaction;
use elapsed::ElapsedTimeCounter;
use serde::Deserialize;
use std::fmt::Display;
use tokio::time::{Duration, Instant};
use tokio::time::Duration;

mod actor_manager;
mod actors;
Expand Down Expand Up @@ -104,7 +105,7 @@ impl<'a> CachedTx<'a> {
}
}

pub(crate) fn to_closed(&self, start_time: Instant, timeout: Duration) -> Option<ClosedTx> {
pub(crate) fn to_closed(&self, start_time: ElapsedTimeCounter, timeout: Duration) -> Option<ClosedTx> {
match self {
CachedTx::Open(_) => None,
CachedTx::Committed => Some(ClosedTx::Committed),
Expand All @@ -117,5 +118,8 @@ impl<'a> CachedTx<'a> {
pub(crate) enum ClosedTx {
Committed,
RolledBack,
Expired { start_time: Instant, timeout: Duration },
Expired {
start_time: ElapsedTimeCounter,
timeout: Duration,
},
}

0 comments on commit d04804d

Please sign in to comment.