Skip to content

Commit

Permalink
fix: make the change on the write db
Browse files Browse the repository at this point in the history
  • Loading branch information
conorsch committed Jan 22, 2025
1 parent a36d511 commit 25f8ef8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/util/cometindex/src/indexer/indexing_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ use crate::{
/// c.f. https://github.com/launchbadge/sqlx/issues/481#issuecomment-727011811
async fn read_only_db(url: &str) -> anyhow::Result<PgPool> {
PgPoolOptions::new()
// TODO: analyze slow queries and make them faster
.acquire_slow_threshold(std::time::Duration::from_secs(5))
.after_connect(|conn, _| {
Box::pin(async move {
sqlx::query("SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;")
Expand All @@ -32,7 +30,12 @@ async fn read_only_db(url: &str) -> anyhow::Result<PgPool> {
}

async fn read_write_db(url: &str) -> anyhow::Result<PgPool> {
PgPoolOptions::new().connect(url).await.map_err(Into::into)
PgPoolOptions::new()
// TODO: analyze slow queries and make them faster
.acquire_slow_threshold(std::time::Duration::from_secs(5))
.connect(url)
.await
.map_err(Into::into)
}

#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
Expand Down

0 comments on commit 25f8ef8

Please sign in to comment.