Skip to content

Commit

Permalink
set event db max connection size to 100 (#6641)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkuo authored and ebmifa committed Dec 7, 2022
1 parent b959b58 commit 21fcff7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
14 changes: 12 additions & 2 deletions crates/sui-core/src/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::Arc;

use move_bytecode_utils::module_cache::SyncModuleCache;
use tokio_stream::Stream;
use tracing::{debug, error, instrument, trace};
use tracing::{debug, error, instrument, trace, warn};

use sui_json_rpc_types::SuiMoveStruct;
use sui_storage::event_store::{EventStore, EventStoreType};
Expand Down Expand Up @@ -81,7 +81,17 @@ impl EventHandler {
let envelopes = res?;

// Ingest all envelopes together at once (for efficiency) into Event Store
self.event_store.add_events(&envelopes).await?;
let row_inserted: u64 = self.event_store.add_events(&envelopes).await?;

if row_inserted != envelopes.len() as u64 {
warn!(
num_events = envelopes.len(),
row_inserted = row_inserted,
tx_digest =? effects.transaction_digest,
"Inserted event record is less than expected."
);
}

trace!(
num_events = envelopes.len(),
tx_digest =? effects.transaction_digest,
Expand Down
9 changes: 7 additions & 2 deletions crates/sui-storage/src/event_store/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ use std::path::Path;

use async_trait::async_trait;
use serde_json::{json, Value};
use sqlx::ConnectOptions;
use sqlx::pool::PoolOptions;
use sqlx::{
sqlite::{SqliteConnectOptions, SqliteJournalMode, SqliteRow, SqliteSynchronous},
Executor, QueryBuilder, Row, SqlitePool,
};
use sqlx::{ConnectOptions, Sqlite};
use strum::{EnumMessage, IntoEnumIterator};
use tracing::{info, instrument, log, warn};

Expand Down Expand Up @@ -121,9 +122,13 @@ impl SqlEventStore {
.pragma("wal_autocheckpoint", "400") // In pages of 4KB each
.create_if_missing(true);
options.log_statements(log::LevelFilter::Off);
let pool = SqlitePool::connect_with(options)

let pool = PoolOptions::<Sqlite>::new()
.max_connections(100)
.connect_with(options)
.await
.map_err(convert_sqlx_err)?;

info!(?db_path, "Created/opened SQLite EventStore on disk");

Ok(Self { pool })
Expand Down

0 comments on commit 21fcff7

Please sign in to comment.