From d04804d838eedc282541579ed41d183acd647231 Mon Sep 17 00:00:00 2001 From: Sergey Tatarintsev Date: Fri, 24 Nov 2023 16:52:06 +0100 Subject: [PATCH] Remove one more isntant usage --- .../core/src/interactive_transactions/actor_manager.rs | 2 +- .../core/src/interactive_transactions/actors.rs | 5 +++-- query-engine/core/src/interactive_transactions/mod.rs | 10 +++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/query-engine/core/src/interactive_transactions/actor_manager.rs b/query-engine/core/src/interactive_transactions/actor_manager.rs index e7c3c770c7e5..f2d1f539ebbf 100644 --- a/query-engine/core/src/interactive_transactions/actor_manager.rs +++ b/query-engine/core/src/interactive_transactions/actor_manager.rs @@ -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 => { diff --git a/query-engine/core/src/interactive_transactions/actors.rs b/query-engine/core/src/interactive_transactions/actors.rs index 0aac2b341bcd..58d24c528261 100644 --- a/query-engine/core/src/interactive_transactions/actors.rs +++ b/query-engine/core/src/interactive_transactions/actors.rs @@ -5,6 +5,7 @@ use crate::{ TxId, }; use connector::Connection; +use elapsed::ElapsedTimeCounter; use schema::QuerySchemaRef; use std::{collections::HashMap, sync::Arc}; use tokio::{ @@ -12,7 +13,7 @@ use tokio::{ mpsc::{channel, Receiver, Sender}, oneshot, RwLock, }, - time::{self, Duration, Instant}, + time::{self, Duration}, }; use tracing::Span; use tracing_futures::Instrument; @@ -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); diff --git a/query-engine/core/src/interactive_transactions/mod.rs b/query-engine/core/src/interactive_transactions/mod.rs index ce125e8fa17e..ac92d52efcf2 100644 --- a/query-engine/core/src/interactive_transactions/mod.rs +++ b/query-engine/core/src/interactive_transactions/mod.rs @@ -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; @@ -104,7 +105,7 @@ impl<'a> CachedTx<'a> { } } - pub(crate) fn to_closed(&self, start_time: Instant, timeout: Duration) -> Option { + pub(crate) fn to_closed(&self, start_time: ElapsedTimeCounter, timeout: Duration) -> Option { match self { CachedTx::Open(_) => None, CachedTx::Committed => Some(ClosedTx::Committed), @@ -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, + }, }