Skip to content

Commit f884875

Browse files
committed
In mithril-signer: use TransactionsImporterWithVacuum with the preloader
Since it will be the one that will make the db size growing the most and we wan't to avoid locking the database (as vacuum needs to) in normal operations.
1 parent 38b5e4f commit f884875

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

mithril-signer/src/runtime/signer_services.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use crate::{
3333
aggregator_client::AggregatorClient, metrics::MetricsService, single_signer::SingleSigner,
3434
AggregatorHTTPClient, CardanoTransactionsImporter, Configuration, MithrilSingleSigner,
3535
ProtocolInitializerStore, ProtocolInitializerStorer, TransactionsImporterByChunk,
36-
TransactionsImporterWithPruner, HTTP_REQUEST_TIMEOUT_DURATION, SQLITE_FILE,
37-
SQLITE_FILE_CARDANO_TRANSACTION,
36+
TransactionsImporterWithPruner, TransactionsImporterWithVacuum, HTTP_REQUEST_TIMEOUT_DURATION,
37+
SQLITE_FILE, SQLITE_FILE_CARDANO_TRANSACTION,
3838
};
3939

4040
type StakeStoreService = Arc<StakeStore>;
@@ -276,7 +276,7 @@ impl<'a> ServiceBuilder for ProductionServiceBuilder<'a> {
276276
let mithril_stake_distribution_signable_builder =
277277
Arc::new(MithrilStakeDistributionSignableBuilder::default());
278278
let transaction_store = Arc::new(CardanoTransactionRepository::new(
279-
sqlite_connection_cardano_transaction_pool,
279+
sqlite_connection_cardano_transaction_pool.clone(),
280280
));
281281
let block_scanner = Arc::new(CardanoBlockScanner::new(
282282
slog_scope::logger(),
@@ -302,15 +302,27 @@ impl<'a> ServiceBuilder for ProductionServiceBuilder<'a> {
302302
));
303303
// Wrap the transaction importer with decorator to chunk its workload, so it prunes
304304
// transactions after each chunk, reducing the storage footprint
305-
let transactions_importer = Arc::new(TransactionsImporterByChunk::new(
305+
let state_machine_transactions_importer = Arc::new(TransactionsImporterByChunk::new(
306306
transaction_store.clone(),
307-
transactions_importer,
307+
transactions_importer.clone(),
308+
self.config.transactions_import_block_chunk_size,
309+
slog_scope::logger(),
310+
));
311+
// For the preloader, we want to vacuum the database after each chunk, to reclaim disk space
312+
// earlier than with just auto_vacuum (that execute only after the end of all import).
313+
let preloader_transactions_importer = Arc::new(TransactionsImporterByChunk::new(
314+
transaction_store.clone(),
315+
Arc::new(TransactionsImporterWithVacuum::new(
316+
sqlite_connection_cardano_transaction_pool,
317+
transactions_importer.clone(),
318+
slog_scope::logger(),
319+
)),
308320
self.config.transactions_import_block_chunk_size,
309321
slog_scope::logger(),
310322
));
311323
let block_range_root_retriever = transaction_store.clone();
312324
let cardano_transactions_builder = Arc::new(CardanoTransactionsSignableBuilder::new(
313-
transactions_importer.clone(),
325+
state_machine_transactions_importer,
314326
block_range_root_retriever,
315327
slog_scope::logger(),
316328
));
@@ -322,7 +334,7 @@ impl<'a> ServiceBuilder for ProductionServiceBuilder<'a> {
322334
let metrics_service = Arc::new(MetricsService::new().unwrap());
323335
let cardano_transactions_preloader = Arc::new(CardanoTransactionsPreloader::new(
324336
signed_entity_type_lock.clone(),
325-
transactions_importer.clone(),
337+
preloader_transactions_importer,
326338
self.config.preload_security_parameter,
327339
chain_observer.clone(),
328340
slog_scope::logger(),

0 commit comments

Comments
 (0)