diff --git a/ledger/indexer-benchmark/src/main/scala/ledger/indexerbenchmark/IndexerBenchmark.scala b/ledger/indexer-benchmark/src/main/scala/ledger/indexerbenchmark/IndexerBenchmark.scala index 25a90fa23c93..5b12c6e1a582 100644 --- a/ledger/indexer-benchmark/src/main/scala/ledger/indexerbenchmark/IndexerBenchmark.scala +++ b/ledger/indexer-benchmark/src/main/scala/ledger/indexerbenchmark/IndexerBenchmark.scala @@ -70,7 +70,6 @@ class IndexerBenchmark() { val indexerFactory = new JdbcIndexer.Factory( config.indexerConfig, readService, - indexerEC, metrics, LfValueTranslationCache.Cache.none, ) diff --git a/ledger/participant-integration-api/src/main/scala/platform/indexer/IndexerStartupMode.scala b/ledger/participant-integration-api/src/main/scala/platform/indexer/IndexerStartupMode.scala index fd7330ba1793..f9447d64f94e 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/indexer/IndexerStartupMode.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/indexer/IndexerStartupMode.scala @@ -11,8 +11,6 @@ object IndexerStartupMode { case object MigrateAndStart extends IndexerStartupMode - case object ResetAndStart extends IndexerStartupMode - case object ValidateAndWaitOnly extends IndexerStartupMode case object MigrateOnEmptySchemaAndStart extends IndexerStartupMode diff --git a/ledger/participant-integration-api/src/main/scala/platform/indexer/JdbcIndexer.scala b/ledger/participant-integration-api/src/main/scala/platform/indexer/JdbcIndexer.scala index da30caa9867a..0445d0ee6964 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/indexer/JdbcIndexer.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/indexer/JdbcIndexer.scala @@ -20,35 +20,26 @@ import com.daml.platform.store.DbType.{ } import com.daml.platform.store.appendonlydao.events.{CompressionStrategy, LfValueTranslation} import com.daml.platform.store.backend.DataSourceStorageBackend.DataSourceConfig -import com.daml.platform.store.backend.{ - DataSourceStorageBackend, - ResetStorageBackend, - StorageBackendFactory, -} +import com.daml.platform.store.backend.StorageBackendFactory import com.daml.platform.store.backend.postgresql.PostgresDataSourceConfig import com.daml.platform.store.{DbType, LfValueTranslationCache} -import scala.concurrent.{ExecutionContext, Future} -import scala.util.Using +import scala.concurrent.Future object JdbcIndexer { private[daml] final class Factory( config: IndexerConfig, readService: state.ReadService, - servicesExecutionContext: ExecutionContext, metrics: Metrics, lfValueTranslationCache: LfValueTranslationCache.Cache, )(implicit materializer: Materializer) { - def initialized( - resetSchema: Boolean = false - )(implicit loggingContext: LoggingContext): ResourceOwner[Indexer] = { + def initialized()(implicit loggingContext: LoggingContext): ResourceOwner[Indexer] = { val factory = StorageBackendFactory.of(DbType.jdbcType(config.jdbcUrl)) val dataSourceStorageBackend = factory.createDataSourceStorageBackend val ingestionStorageBackend = factory.createIngestionStorageBackend val parameterStorageBackend = factory.createParameterStorageBackend val DBLockStorageBackend = factory.createDBLockStorageBackend - val resetStorageBackend = factory.createResetStorageBackend val stringInterningStorageBackend = factory.createStringInterningStorageBackend val indexer = ParallelIndexerFactory( jdbcUrl = config.jdbcUrl, @@ -104,24 +95,8 @@ object JdbcIndexer { mat = materializer, readService = readService, ) - if (resetSchema) { - reset(resetStorageBackend, dataSourceStorageBackend).flatMap(_ => indexer) - } else { - indexer - } + indexer } - private def reset( - resetStorageBackend: ResetStorageBackend, - dataSourceStorageBackend: DataSourceStorageBackend, - )(implicit loggingContext: LoggingContext): ResourceOwner[Unit] = - ResourceOwner.forFuture(() => - Future( - Using.resource(dataSourceStorageBackend.createDataSource(config.jdbcUrl).getConnection)( - resetStorageBackend.reset - ) - )(servicesExecutionContext) - ) - } } diff --git a/ledger/participant-integration-api/src/main/scala/platform/indexer/StandaloneIndexerServer.scala b/ledger/participant-integration-api/src/main/scala/platform/indexer/StandaloneIndexerServer.scala index 5babbc566599..8eb0659678a5 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/indexer/StandaloneIndexerServer.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/indexer/StandaloneIndexerServer.scala @@ -11,12 +11,11 @@ import com.daml.logging.{ContextualizedLogger, LoggingContext} import com.daml.metrics.Metrics import com.daml.platform.store.{FlywayMigrations, LfValueTranslationCache} -import scala.concurrent.{ExecutionContext, Future} +import scala.concurrent.Future final class StandaloneIndexerServer( readService: state.ReadService, config: IndexerConfig, - servicesExecutionContext: ExecutionContext, metrics: Metrics, lfValueTranslationCache: LfValueTranslationCache.Cache, additionalMigrationPaths: Seq[String] = Seq.empty, @@ -34,7 +33,6 @@ final class StandaloneIndexerServer( val indexerFactory = new JdbcIndexer.Factory( config, readService, - servicesExecutionContext, metrics, lfValueTranslationCache, ) @@ -47,11 +45,10 @@ final class StandaloneIndexerServer( def startIndexer( migration: Future[Unit], initializedDebugLogMessage: String = "Waiting for the indexer to initialize the database.", - resetSchema: Boolean = false, ): Resource[ReportsHealth] = Resource .fromFuture(migration) - .flatMap(_ => indexerFactory.initialized(resetSchema).acquire()) + .flatMap(_ => indexerFactory.initialized().acquire()) .flatMap(indexer.start) .map { case (healthReporter, _) => logger.debug(initializedDebugLogMessage) @@ -64,12 +61,6 @@ final class StandaloneIndexerServer( migration = flywayMigrations.migrate(config.allowExistingSchema) ) - case IndexerStartupMode.ResetAndStart => - startIndexer( - migration = Future.unit, - resetSchema = true, - ) - case IndexerStartupMode.ValidateAndStart => startIndexer( migration = flywayMigrations.validate() diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/FlywayMigrations.scala b/ledger/participant-integration-api/src/main/scala/platform/store/FlywayMigrations.scala index 9c988dc7f705..fcd61b33e611 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/FlywayMigrations.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/FlywayMigrations.scala @@ -63,14 +63,6 @@ private[platform] class FlywayMigrations( ) } - def reset(): Future[Unit] = run { configBase => - val flyway = configBase - .load() - logger.info("Running Flyway clean...") - flyway.clean() - logger.info("Flyway schema clean finished successfully.") - } - @nowarn("msg=method ignoreFutureMigrations .* is deprecated") def validateAndWaitOnly(retries: Int, retryBackoff: FiniteDuration): Future[Unit] = runF { configBase => diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/JdbcLedgerDao.scala b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/JdbcLedgerDao.scala index 4974ddbb4823..66e5b832cb8f 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/JdbcLedgerDao.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/JdbcLedgerDao.scala @@ -36,7 +36,6 @@ import com.daml.platform.store.backend.{ DeduplicationStorageBackend, ParameterStorageBackend, ReadStorageBackend, - ResetStorageBackend, } import com.daml.platform.store.cache.LedgerEndCache import com.daml.platform.store.entries.{ @@ -74,7 +73,6 @@ private class JdbcLedgerDao( readStorageBackend: ReadStorageBackend, parameterStorageBackend: ParameterStorageBackend, deduplicationStorageBackend: DeduplicationStorageBackend, - resetStorageBackend: ResetStorageBackend, errorFactories: ErrorFactories, materializer: Materializer, ) extends LedgerDao { @@ -647,9 +645,6 @@ private class JdbcLedgerDao( }(servicesExecutionContext) } - override def reset()(implicit loggingContext: LoggingContext): Future[Unit] = - dbDispatcher.executeSql(metrics.daml.index.db.truncateAllTables)(resetStorageBackend.reset) - private val translation: LfValueTranslation = new LfValueTranslation( cache = lfValueTranslationCache, @@ -825,7 +820,6 @@ private[platform] object JdbcLedgerDao { dbSupport.storageBackendFactory.readStorageBackend(ledgerEndCache, stringInterning), dbSupport.storageBackendFactory.createParameterStorageBackend, dbSupport.storageBackendFactory.createDeduplicationStorageBackend, - dbSupport.storageBackendFactory.createResetStorageBackend, errorFactories, materializer = materializer, ), @@ -873,7 +867,6 @@ private[platform] object JdbcLedgerDao { dbSupport.storageBackendFactory.readStorageBackend(ledgerEndCache, stringInterning), dbSupport.storageBackendFactory.createParameterStorageBackend, dbSupport.storageBackendFactory.createDeduplicationStorageBackend, - dbSupport.storageBackendFactory.createResetStorageBackend, errorFactories, materializer = materializer, ), @@ -922,7 +915,6 @@ private[platform] object JdbcLedgerDao { dbSupport.storageBackendFactory.readStorageBackend(ledgerEndCache, stringInterning), dbSupport.storageBackendFactory.createParameterStorageBackend, dbSupport.storageBackendFactory.createDeduplicationStorageBackend, - dbSupport.storageBackendFactory.createResetStorageBackend, errorFactories, materializer, ), diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/LedgerDao.scala b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/LedgerDao.scala index f2519aa3f7d5..ed4440db2035 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/LedgerDao.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/LedgerDao.scala @@ -293,9 +293,6 @@ private[platform] trait LedgerWriteDao extends ReportsHealth { optEntry: Option[PackageLedgerEntry], )(implicit loggingContext: LoggingContext): Future[PersistenceResponse] - /** Resets the platform into a state as it was never used before. Meant to be used solely for testing. */ - def reset()(implicit loggingContext: LoggingContext): Future[Unit] - /** This is a combined store transaction method to support sandbox-classic and tests * !!! Usage of this is discouraged, with the removal of sandbox-classic this will be removed */ diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/MeteredLedgerDao.scala b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/MeteredLedgerDao.scala index ec5dac85b762..10f9078fa94e 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/MeteredLedgerDao.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/MeteredLedgerDao.scala @@ -171,9 +171,6 @@ private[platform] class MeteredLedgerDao(ledgerDao: LedgerDao, metrics: Metrics) )(implicit loggingContext: LoggingContext): Future[Unit] = ledgerDao.initialize(ledgerId, participantId) - override def reset()(implicit loggingContext: LoggingContext): Future[Unit] = - ledgerDao.reset() - override def storePartyEntry( offset: Offset, partyEntry: PartyLedgerEntry, diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/backend/StorageBackend.scala b/ledger/participant-integration-api/src/main/scala/platform/store/backend/StorageBackend.scala index a7c034ef503e..ec972ba24581 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/backend/StorageBackend.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/backend/StorageBackend.scala @@ -37,14 +37,6 @@ import scala.util.Try trait ResetStorageBackend { - /** Truncates all storage backend tables, EXCEPT the packages table. - * Does not touch other tables, like the Flyway history table. - * Reason: the reset() call is used by the ledger API reset service, - * which is mainly used for application tests in another big project, - * and re-uploading packages after each test significantly slows down their test time. - */ - def reset(connection: Connection): Unit - /** Truncates ALL storage backend tables. * Does not touch other tables, like the Flyway history table. * The result is a database that looks the same as a freshly created database with Flyway migrations applied. diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/backend/h2/H2ResetStorageBackend.scala b/ledger/participant-integration-api/src/main/scala/platform/store/backend/h2/H2ResetStorageBackend.scala index 47823f95768e..f94d33941e71 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/backend/h2/H2ResetStorageBackend.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/backend/h2/H2ResetStorageBackend.scala @@ -10,27 +10,6 @@ import com.daml.platform.store.backend.ResetStorageBackend object H2ResetStorageBackend extends ResetStorageBackend { - override def reset(connection: Connection): Unit = { - SQL("""set referential_integrity false; - |truncate table configuration_entries; - |truncate table package_entries; - |truncate table parameters; - |truncate table participant_command_completions; - |truncate table participant_command_submissions; - |truncate table participant_events_divulgence; - |truncate table participant_events_create; - |truncate table participant_events_consuming_exercise; - |truncate table participant_events_non_consuming_exercise; - |truncate table party_entries; - |truncate table string_interning; - |truncate table participant_events_create_filter; - |truncate table participant_users; - |truncate table participant_user_rights; - |set referential_integrity true;""".stripMargin) - .execute()(connection) - () - } - override def resetAll(connection: Connection): Unit = { SQL("""set referential_integrity false; |truncate table configuration_entries; diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/backend/oracle/OracleResetStorageBackend.scala b/ledger/participant-integration-api/src/main/scala/platform/store/backend/oracle/OracleResetStorageBackend.scala index 0a1ce5707332..466a003f0882 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/backend/oracle/OracleResetStorageBackend.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/backend/oracle/OracleResetStorageBackend.scala @@ -9,24 +9,6 @@ import anorm.SQL import com.daml.platform.store.backend.ResetStorageBackend object OracleResetStorageBackend extends ResetStorageBackend { - override def reset(connection: Connection): Unit = - List( - "truncate table configuration_entries cascade", - "truncate table package_entries cascade", - "truncate table parameters cascade", - "truncate table participant_command_completions cascade", - "truncate table participant_command_submissions cascade", - "truncate table participant_events_divulgence cascade", - "truncate table participant_events_create cascade", - "truncate table participant_events_consuming_exercise cascade", - "truncate table participant_events_non_consuming_exercise cascade", - "truncate table party_entries cascade", - "truncate table string_interning cascade", - "truncate table participant_events_create_filter cascade", - "truncate table participant_users cascade", - "truncate table participant_user_rights cascade", - ).map(SQL(_)).foreach(_.execute()(connection)) - override def resetAll(connection: Connection): Unit = List( "truncate table configuration_entries cascade", diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/backend/postgresql/PostgresResetStorageBackend.scala b/ledger/participant-integration-api/src/main/scala/platform/store/backend/postgresql/PostgresResetStorageBackend.scala index fb29be28f1dc..e9c39090e6e7 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/backend/postgresql/PostgresResetStorageBackend.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/backend/postgresql/PostgresResetStorageBackend.scala @@ -9,26 +9,6 @@ import anorm.SQL import com.daml.platform.store.backend.ResetStorageBackend object PostgresResetStorageBackend extends ResetStorageBackend { - override def reset(connection: Connection): Unit = { - SQL("""truncate table configuration_entries cascade; - |truncate table package_entries cascade; - |truncate table parameters cascade; - |truncate table participant_command_completions cascade; - |truncate table participant_command_submissions cascade; - |truncate table participant_events_divulgence cascade; - |truncate table participant_events_create cascade; - |truncate table participant_events_consuming_exercise cascade; - |truncate table participant_events_non_consuming_exercise cascade; - |truncate table party_entries cascade; - |truncate table string_interning cascade; - |truncate table participant_events_create_filter cascade; - |truncate table participant_users cascade; - |truncate table participant_user_rights cascade; - |""".stripMargin) - .execute()(connection) - () - } - override def resetAll(connection: Connection): Unit = { SQL("""truncate table configuration_entries cascade; |truncate table packages cascade; diff --git a/ledger/participant-integration-api/src/test/lib/scala/platform/indexer/ha/IndexerStabilityTestFixture.scala b/ledger/participant-integration-api/src/test/lib/scala/platform/indexer/ha/IndexerStabilityTestFixture.scala index dbc597e0181d..9a5322aa7fb3 100644 --- a/ledger/participant-integration-api/src/test/lib/scala/platform/indexer/ha/IndexerStabilityTestFixture.scala +++ b/ledger/participant-integration-api/src/test/lib/scala/platform/indexer/ha/IndexerStabilityTestFixture.scala @@ -91,7 +91,6 @@ object IndexerStabilityTestFixture { indexing <- new StandaloneIndexerServer( readService = readService, config = indexerConfig, - servicesExecutionContext = servicesExecutionContext, metrics = metrics, lfValueTranslationCache = LfValueTranslationCache.Cache.none, ).acquire() diff --git a/ledger/participant-integration-api/src/test/lib/scala/platform/store/backend/StorageBackendTestsReset.scala b/ledger/participant-integration-api/src/test/lib/scala/platform/store/backend/StorageBackendTestsReset.scala index 19cd5424041a..ac946a942d65 100644 --- a/ledger/participant-integration-api/src/test/lib/scala/platform/store/backend/StorageBackendTestsReset.scala +++ b/ledger/participant-integration-api/src/test/lib/scala/platform/store/backend/StorageBackendTestsReset.scala @@ -44,67 +44,6 @@ private[backend] trait StorageBackendTestsReset extends Matchers with StorageBac config shouldBe None } - it should "reset everything except packages when using reset" in { - val dtos: Vector[DbDto] = Vector( - // 1: config change - dtoConfiguration(offset(1)), - // 2: party allocation - dtoPartyEntry(offset(2)), - // 3: package upload - dtoPackage(offset(3)), - dtoPackageEntry(offset(3)), - // 4: transaction with create node - dtoCreate(offset(4), 1L, "#4"), - DbDto.CreateFilter(1L, someTemplateId.toString, someParty.toString), - dtoCompletion(offset(4)), - // 5: transaction with exercise node and retroactive divulgence - dtoExercise(offset(5), 2L, true, "#4"), - dtoDivulgence(Some(offset(5)), 3L, "#4"), - dtoCompletion(offset(5)), - DbDto.StringInterningDto(2, "2"), - ) - - // Initialize and insert some data - executeSql(backend.parameter.initializeParameters(someIdentityParams)) - executeSql(ingest(dtos, _)) - executeSql(updateLedgerEnd(ledgerEnd(5, 3L))) - - // Reset - executeSql(backend.reset.reset) - - // Check the contents - val identity = executeSql(backend.parameter.ledgerIdentity) - val end = executeSql(backend.parameter.ledgerEnd) - val events = executeSql(backend.contract.contractStateEvents(0, Long.MaxValue)) - - // Check the contents (queries that don't read beyond ledger end) - advanceLedgerEndToMakeOldDataVisible() - val parties = executeSql(backend.party.knownParties) - val config = executeSql(backend.configuration.ledgerConfiguration) - val packages = executeSql(backend.packageBackend.lfPackages) - val stringInterningEntries = executeSql( - backend.stringInterning.loadStringInterningEntries(0, 1000) - ) - val filterIds = executeSql( - backend.event.activeContractEventIds( - partyFilter = someParty, - templateIdFilter = None, - startExclusive = 0, - endInclusive = 1000, - limit = 1000, - ) - ) - - identity shouldBe None - end shouldBe None - parties shouldBe empty - packages should not be empty // Note: reset() does not delete packages - events shouldBe empty - config shouldBe None - stringInterningEntries shouldBe empty - filterIds shouldBe empty - } - it should "reset everything when using resetAll" in { val dtos: Vector[DbDto] = Vector( // 1: config change diff --git a/ledger/participant-state/kvutils/app/src/main/scala/com/daml/ledger/participant/state/kvutils/app/Runner.scala b/ledger/participant-state/kvutils/app/src/main/scala/com/daml/ledger/participant/state/kvutils/app/Runner.scala index da1505a411a7..4b0bab5385a2 100644 --- a/ledger/participant-state/kvutils/app/src/main/scala/com/daml/ledger/participant/state/kvutils/app/Runner.scala +++ b/ledger/participant-state/kvutils/app/src/main/scala/com/daml/ledger/participant/state/kvutils/app/Runner.scala @@ -140,7 +140,6 @@ final class Runner[T <: ReadWriteService, Extra]( indexerHealth <- new StandaloneIndexerServer( readService = readService, config = configProvider.indexerConfig(participantConfig, config), - servicesExecutionContext = servicesExecutionContext, metrics = metrics, lfValueTranslationCache = lfValueTranslationCache, ).acquire() diff --git a/ledger/participant-state/kvutils/tools/src/main/scala/ledger/participant/state/kvutils/tools/integritycheck/IntegrityChecker.scala b/ledger/participant-state/kvutils/tools/src/main/scala/ledger/participant/state/kvutils/tools/integritycheck/IntegrityChecker.scala index 189b8033276c..5b2fcaa7f100 100644 --- a/ledger/participant-state/kvutils/tools/src/main/scala/ledger/participant/state/kvutils/tools/integritycheck/IntegrityChecker.scala +++ b/ledger/participant-state/kvutils/tools/src/main/scala/ledger/participant/state/kvutils/tools/integritycheck/IntegrityChecker.scala @@ -251,18 +251,14 @@ class IntegrityChecker[LogResult]( resourceContext: ResourceContext, materializer: Materializer, loggingContext: LoggingContext, - ): ResourceOwner[Indexer] = + ): ResourceOwner[Indexer] = { + val indexerFactory = new JdbcIndexer.Factory( + config, + readService, + metrics, + lfValueTranslationCache, + ) for { - servicesExecutionContext <- ResourceOwner - .forExecutorService(() => Executors.newWorkStealingPool()) - .map(ExecutionContext.fromExecutorService) - indexerFactory = new JdbcIndexer.Factory( - config, - readService, - servicesExecutionContext, - metrics, - lfValueTranslationCache, - ) migrating <- ResourceOwner.forFuture(() => StandaloneIndexerServer .migrateOnly( @@ -272,6 +268,7 @@ class IntegrityChecker[LogResult]( ) migrated <- migrating } yield migrated + } } object IntegrityChecker { diff --git a/ledger/recovering-indexer-integration-tests/src/test/suite/scala/com/digitalasset/platform/indexer/RecoveringIndexerIntegrationSpec.scala b/ledger/recovering-indexer-integration-tests/src/test/suite/scala/com/digitalasset/platform/indexer/RecoveringIndexerIntegrationSpec.scala index 67f61f9caab0..4c508738eeb4 100644 --- a/ledger/recovering-indexer-integration-tests/src/test/suite/scala/com/digitalasset/platform/indexer/RecoveringIndexerIntegrationSpec.scala +++ b/ledger/recovering-indexer-integration-tests/src/test/suite/scala/com/digitalasset/platform/indexer/RecoveringIndexerIntegrationSpec.scala @@ -196,9 +196,6 @@ class RecoveringIndexerIntegrationSpec for { actorSystem <- ResourceOwner.forActorSystem(() => ActorSystem()) materializer <- ResourceOwner.forMaterializer(() => Materializer(actorSystem)) - servicesExecutionContext <- ResourceOwner - .forExecutorService(() => Executors.newWorkStealingPool()) - .map(ExecutionContext.fromExecutorService) participantState <- newParticipantState(ledgerId, participantId)(materializer, loggingContext) _ <- new StandaloneIndexerServer( readService = participantState._1, @@ -208,7 +205,6 @@ class RecoveringIndexerIntegrationSpec startupMode = IndexerStartupMode.MigrateAndStart, restartDelay = restartDelay, ), - servicesExecutionContext = servicesExecutionContext, metrics = new Metrics(new MetricRegistry), lfValueTranslationCache = LfValueTranslationCache.Cache.none, )(materializer, loggingContext) diff --git a/ledger/sandbox-classic/src/main/scala/platform/sandbox/SandboxServer.scala b/ledger/sandbox-classic/src/main/scala/platform/sandbox/SandboxServer.scala index 11c5886483a3..7846d40ed3eb 100644 --- a/ledger/sandbox-classic/src/main/scala/platform/sandbox/SandboxServer.scala +++ b/ledger/sandbox-classic/src/main/scala/platform/sandbox/SandboxServer.scala @@ -48,7 +48,6 @@ import com.daml.platform.sandbox.config.SandboxConfig.EngineMode import com.daml.platform.sandbox.config.{LedgerName, SandboxConfig} import com.daml.platform.sandbox.stores.ledger.ScenarioLoader.LedgerEntryOrBump import com.daml.platform.sandbox.stores.ledger._ -import com.daml.platform.sandbox.stores.ledger.sql.SqlStartMode import com.daml.platform.sandbox.stores.{InMemoryActiveLedgerState, SandboxIndexAndWriteService} import com.daml.platform.services.time.TimeProviderType import com.daml.platform.store.{DbSupport, DbType, FlywayMigrations, LfValueTranslationCache} @@ -234,7 +233,6 @@ final class SandboxServer( materializer: Materializer, metrics: Metrics, packageStore: InMemoryPackageStore, - startMode: SqlStartMode, currentPort: Option[Port], )(implicit loggingContext: LoggingContext): Resource[ApiServer] = { implicit val _materializer: Materializer = materializer @@ -311,7 +309,6 @@ final class SandboxServer( dbSupport = dbSupport, timeProvider = timeProvider, ledgerEntries = ledgerEntries, - startMode = startMode, queueDepth = config.maxParallelSubmissions, transactionCommitter = transactionCommitter, templateStore = packageStore, @@ -464,9 +461,6 @@ final class SandboxServer( materializer, metrics, packageStore, - SqlStartMode - .fromString(config.sqlStartMode.toString) - .getOrElse(SqlStartMode.MigrateAndStart), currentPort = None, ) Future.successful(new SandboxState(apiServerResource)) diff --git a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/SandboxIndexAndWriteService.scala b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/SandboxIndexAndWriteService.scala index 2983f035e677..dd718a296c03 100644 --- a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/SandboxIndexAndWriteService.scala +++ b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/SandboxIndexAndWriteService.scala @@ -26,7 +26,7 @@ import com.daml.platform.sandbox.LedgerIdGenerator import com.daml.platform.sandbox.config.LedgerName import com.daml.platform.sandbox.stores.ledger.ScenarioLoader.LedgerEntryOrBump import com.daml.platform.sandbox.stores.ledger.inmemory.InMemoryLedger -import com.daml.platform.sandbox.stores.ledger.sql.{SqlLedger, SqlStartMode} +import com.daml.platform.sandbox.stores.ledger.sql.SqlLedger import com.daml.platform.sandbox.stores.ledger.{Ledger, MeteredLedger} import com.daml.platform.server.api.validation.ErrorFactories import com.daml.platform.store.{DbSupport, LfValueTranslationCache} @@ -52,7 +52,6 @@ private[sandbox] object SandboxIndexAndWriteService { dbSupport: DbSupport, timeProvider: TimeProvider, ledgerEntries: ImmArray[LedgerEntryOrBump], - startMode: SqlStartMode, queueDepth: Int, transactionCommitter: TransactionCommitter, templateStore: InMemoryPackageStore, @@ -84,7 +83,6 @@ private[sandbox] object SandboxIndexAndWriteService { initialLedgerEntries = ledgerEntries, queueDepth = queueDepth, transactionCommitter = transactionCommitter, - startMode = startMode, eventsPageSize = eventsPageSize, eventsProcessingParallelism = eventsProcessingParallelism, acsIdPageSize = acsIdPageSize, diff --git a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/sql/SqlLedger.scala b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/sql/SqlLedger.scala index cfbd8d6b50f3..30949e954846 100644 --- a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/sql/SqlLedger.scala +++ b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/sql/SqlLedger.scala @@ -78,7 +78,6 @@ private[sandbox] object SqlLedger { initialLedgerEntries: ImmArray[LedgerEntryOrBump], queueDepth: Int, transactionCommitter: TransactionCommitter, - startMode: SqlStartMode, eventsPageSize: Int, eventsProcessingParallelism: Int, acsIdPageSize: Int, @@ -117,12 +116,6 @@ private[sandbox] object SqlLedger { errorFactories, ) for { - _ <- startMode match { - case SqlStartMode.ResetAndStart => - Resource.fromFuture(dao.reset()) - case SqlStartMode.MigrateAndStart => - Resource.unit - } existingLedgerId <- Resource.fromFuture(dao.lookupLedgerId()) existingParticipantId <- Resource.fromFuture(dao.lookupParticipantId()) ledgerId <- Resource.fromFuture(initialize(dao, existingLedgerId, existingParticipantId)) diff --git a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/sql/SqlStartMode.scala b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/sql/SqlStartMode.scala deleted file mode 100644 index 53c0cdae76ca..000000000000 --- a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/sql/SqlStartMode.scala +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package com.daml.platform.sandbox.stores.ledger.sql - -private[sandbox] sealed abstract class SqlStartMode extends Product with Serializable - -private[sandbox] object SqlStartMode { - /* We do not allow ResetAndStart to be set from options bubbled up to config to avoid mishaps */ - def fromString(value: String): Option[SqlStartMode] = { - Vector(MigrateAndStart, ResetAndStart).find(_.toString == value) - } - - /** Will continue using an initialised ledger, otherwise initialize a new one */ - final case object MigrateAndStart extends SqlStartMode - - /** Will always reset and initialize the ledger, even if it has data. */ - final case object ResetAndStart extends SqlStartMode - -} diff --git a/ledger/sandbox-classic/src/test/lib/scala/platform/sandbox/LedgerResource.scala b/ledger/sandbox-classic/src/test/lib/scala/platform/sandbox/LedgerResource.scala index 3592d652097d..96062d55cc9c 100644 --- a/ledger/sandbox-classic/src/test/lib/scala/platform/sandbox/LedgerResource.scala +++ b/ledger/sandbox-classic/src/test/lib/scala/platform/sandbox/LedgerResource.scala @@ -24,7 +24,7 @@ import com.daml.platform.sandbox.stores.InMemoryActiveLedgerState import com.daml.platform.sandbox.stores.ledger.Ledger import com.daml.platform.sandbox.stores.ledger.ScenarioLoader.LedgerEntryOrBump import com.daml.platform.sandbox.stores.ledger.inmemory.InMemoryLedger -import com.daml.platform.sandbox.stores.ledger.sql.{SqlLedger, SqlStartMode} +import com.daml.platform.sandbox.stores.ledger.sql.SqlLedger import com.daml.platform.server.api.validation.ErrorFactories import com.daml.platform.store.{DbSupport, LfValueTranslationCache} import com.daml.testing.postgresql.PostgresResource @@ -97,7 +97,6 @@ private[sandbox] object LedgerResource { initialLedgerEntries = ImmArray.Empty, queueDepth = 128, transactionCommitter = StandardTransactionCommitter, - startMode = SqlStartMode.ResetAndStart, eventsPageSize = 100, eventsProcessingParallelism = 8, acsIdPageSize = 2000, diff --git a/ledger/sandbox-classic/src/test/suite/scala/platform/sandbox/stores/ledger/sql/SqlLedgerSpec.scala b/ledger/sandbox-classic/src/test/suite/scala/platform/sandbox/stores/ledger/sql/SqlLedgerSpec.scala index 69c405d53546..bf4fe251d656 100644 --- a/ledger/sandbox-classic/src/test/suite/scala/platform/sandbox/stores/ledger/sql/SqlLedgerSpec.scala +++ b/ledger/sandbox-classic/src/test/suite/scala/platform/sandbox/stores/ledger/sql/SqlLedgerSpec.scala @@ -450,7 +450,6 @@ final class SqlLedgerSpec initialLedgerEntries = ImmArray.Empty, queueDepth = queueDepth, transactionCommitter = LegacyTransactionCommitter, - startMode = SqlStartMode.MigrateAndStart, eventsPageSize = 100, eventsProcessingParallelism = 8, acsIdPageSize = 2000, diff --git a/ledger/sandbox-on-x/src/main/scala/com/daml/ledger/sandbox/SandboxOnXRunner.scala b/ledger/sandbox-on-x/src/main/scala/com/daml/ledger/sandbox/SandboxOnXRunner.scala index 7908ec2120d3..414647a9076c 100644 --- a/ledger/sandbox-on-x/src/main/scala/com/daml/ledger/sandbox/SandboxOnXRunner.scala +++ b/ledger/sandbox-on-x/src/main/scala/com/daml/ledger/sandbox/SandboxOnXRunner.scala @@ -161,7 +161,6 @@ object SandboxOnXRunner { indexerHealthChecks <- buildIndexerServer( metrics, - servicesExecutionContext, new TimedReadService(readServiceWithSubscriber, metrics), translationCache, ) @@ -260,7 +259,6 @@ object SandboxOnXRunner { private def buildIndexerServer( metrics: Metrics, - servicesExecutionContext: ExecutionContextExecutorService, readService: ReadService, translationCache: LfValueTranslationCache.Cache, )(implicit @@ -273,7 +271,6 @@ object SandboxOnXRunner { indexerHealth <- new StandaloneIndexerServer( readService = readService, config = BridgeConfigProvider.indexerConfig(participantConfig, config), - servicesExecutionContext = servicesExecutionContext, metrics = metrics, lfValueTranslationCache = translationCache, ) diff --git a/ledger/sandbox/src/main/scala/platform/sandboxnext/Runner.scala b/ledger/sandbox/src/main/scala/platform/sandboxnext/Runner.scala index 2f0d61a800a9..f72f28041818 100644 --- a/ledger/sandbox/src/main/scala/platform/sandboxnext/Runner.scala +++ b/ledger/sandbox/src/main/scala/platform/sandboxnext/Runner.scala @@ -191,7 +191,6 @@ class Runner(config: SandboxConfig) extends ResourceOwner[Port] { allowExistingSchema = true, enableCompression = config.enableCompression, ), - servicesExecutionContext = servicesExecutionContext, metrics = metrics, lfValueTranslationCache = lfValueTranslationCache, ) diff --git a/ledger/sandbox/src/main/scala/platform/sandboxnext/StartupMode.scala b/ledger/sandbox/src/main/scala/platform/sandboxnext/StartupMode.scala deleted file mode 100644 index a71dd658147e..000000000000 --- a/ledger/sandbox/src/main/scala/platform/sandboxnext/StartupMode.scala +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package com.daml.platform.sandboxnext - -sealed trait StartupMode - -object StartupMode { - - case object MigrateAndStart extends StartupMode - - case object ResetAndStart extends StartupMode - -}