Skip to content

Commit

Permalink
Merge pull request #1710 from tursodatabase/no-internal-connection-tr…
Browse files Browse the repository at this point in the history
…acking

do not track internal connections
  • Loading branch information
MarinPostma committed Aug 29, 2024
2 parents 294ab4a + 3a4eca3 commit cece90a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 7 additions & 0 deletions libsql-server/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,13 @@ impl<F> MakeThrottledConnection<F> {
1
}
}

pub async fn untracked(&self) -> Result<F::Connection, Error>
where
F: MakeConnection,
{
self.connection_maker.create().await
}
}

struct WaitersGuard<'a> {
Expand Down
5 changes: 3 additions & 2 deletions libsql-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ use utils::services::idle_shutdown::IdleShutdownKicker;
use self::bottomless_migrate::bottomless_migrate;
use self::config::MetaStoreConfig;
use self::connection::connection_manager::InnerWalManager;
use self::connection::MakeThrottledConnection;
use self::namespace::configurator::{
BaseNamespaceConfig, LibsqlPrimaryConfigurator, LibsqlReplicaConfigurator,
LibsqlSchemaConfigurator, NamespaceConfigurators, PrimaryConfig, PrimaryConfigurator,
Expand Down Expand Up @@ -338,7 +339,7 @@ pub type SqldStorage =

#[tracing::instrument(skip(connection_maker))]
async fn run_periodic_checkpoint<C>(
connection_maker: Arc<C>,
connection_maker: Arc<MakeThrottledConnection<C>>,
period: Duration,
namespace_name: NamespaceName,
) -> anyhow::Result<()>
Expand All @@ -362,7 +363,7 @@ where
} else {
interval.tick().await;
}
retry = match connection_maker.create().await {
retry = match connection_maker.untracked().await {
Ok(conn) => {
if let Err(e) = conn.vacuum_if_needed().await {
tracing::warn!("vacuum failed: {}", e);
Expand Down
6 changes: 3 additions & 3 deletions libsql-server/src/namespace/configurator/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use tokio_util::io::StreamReader;
use crate::connection::config::DatabaseConfig;
use crate::connection::connection_manager::InnerWalManager;
use crate::connection::legacy::MakeLegacyConnection;
use crate::connection::{Connection as _, MakeConnection};
use crate::connection::{Connection as _, MakeConnection, MakeThrottledConnection};
use crate::database::{PrimaryConnection, PrimaryConnectionMaker};
use crate::error::LoadDumpError;
use crate::namespace::broadcasters::BroadcasterHandle;
Expand Down Expand Up @@ -380,7 +380,7 @@ pub(super) async fn make_stats(
// right after checkpointing is exactly where it should be done.
pub(crate) async fn run_storage_monitor<M: MakeConnection>(
stats: Weak<Stats>,
connection_maker: Arc<M>,
connection_maker: Arc<MakeThrottledConnection<M>>,
) -> anyhow::Result<()> {
// on initialization, the database file doesn't exist yet, so we wait a bit for it to be
// created
Expand All @@ -392,7 +392,7 @@ pub(crate) async fn run_storage_monitor<M: MakeConnection>(
return Ok(());
};

match connection_maker.create().await {
match connection_maker.untracked().await {
Ok(conn) => {
let _ = BLOCKING_RT
.spawn_blocking(move || {
Expand Down

0 comments on commit cece90a

Please sign in to comment.