Skip to content

Commit 4d71356

Browse files
Add feature flag for import update backfilling (#1165)
Signed-off-by: Robert Autenrieth <[email protected]>
1 parent 1e59217 commit 4d71356

File tree

30 files changed

+92
-3
lines changed

30 files changed

+92
-3
lines changed

apps/app/src/main/scala/org/lfdecentralizedtrust/splice/config/ConfigTransforms.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ object ConfigTransforms {
194194
disableOnboardingParticipantPromotionDelay(),
195195
setDefaultGrpcDeadlineForBuyExtraTraffic(),
196196
setDefaultGrpcDeadlineForTreasuryService(),
197+
enableImportUpdateBackfilling(),
197198
)
198199
}
199200

@@ -861,4 +862,10 @@ object ConfigTransforms {
861862
rows.toMap
862863
}
863864

865+
def enableImportUpdateBackfilling(): ConfigTransform =
866+
updateAllScanAppConfigs((_, config) =>
867+
config
868+
.copy(updateHistoryBackfillImportUpdatesEnabled = true)
869+
)
870+
864871
}

apps/common/src/main/scala/org/lfdecentralizedtrust/splice/store/UpdateHistory.scala

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class UpdateHistory(
7777
val backfillingRequired: BackfillingRequirement,
7878
override protected val loggerFactory: NamedLoggerFactory,
7979
enableissue12777Workaround: Boolean,
80+
enableImportUpdateBackfill: Boolean,
8081
val oMetrics: Option[HistoryMetrics] = None,
8182
)(implicit
8283
ec: ExecutionContext,
@@ -245,7 +246,13 @@ class UpdateHistory(
245246

246247
_ <- cleanUpDataAfterDomainMigration(newHistoryId)
247248

248-
_ <- deleteInvalidAcsSnapshots(newHistoryId)
249+
_ <-
250+
if (enableImportUpdateBackfill) {
251+
deleteInvalidAcsSnapshots(newHistoryId)
252+
} else {
253+
logger.info(s"Not deleting invalid ACS snapshots for history $newHistoryId")
254+
Future.unit
255+
}
249256
} yield {
250257
state.updateAndGet(
251258
_.copy(
@@ -649,6 +656,7 @@ class UpdateHistory(
649656
private[this] def deleteInvalidAcsSnapshots(
650657
historyId: Long
651658
)(implicit tc: TraceContext): Future[Unit] = {
659+
assert(enableImportUpdateBackfill)
652660
def migrationsWithCorruptSnapshots(): Future[Set[Long]] = {
653661
for {
654662
migrationsWithImportUpdates <- storage
@@ -1834,7 +1842,8 @@ class UpdateHistory(
18341842

18351843
def getBackfillingState()(implicit
18361844
tc: TraceContext
1837-
): Future[BackfillingState] = getBackfillingStateForHistory(historyId)
1845+
): Future[BackfillingState] =
1846+
getBackfillingStateForHistory(historyId)
18381847

18391848
private[this] def getBackfillingStateForHistory(historyId: Long)(implicit
18401849
tc: TraceContext
@@ -1856,6 +1865,9 @@ class UpdateHistory(
18561865
case Some((updatesComplete, importUpdatesComplete)) =>
18571866
if (updatesComplete && importUpdatesComplete) {
18581867
BackfillingState.Complete
1868+
} else if (updatesComplete && !enableImportUpdateBackfill) {
1869+
// If import update backfilling is disabled, behave as if it was not implemented
1870+
BackfillingState.Complete
18591871
} else {
18601872
BackfillingState.InProgress(
18611873
updatesComplete = updatesComplete,

apps/common/src/main/scala/org/lfdecentralizedtrust/splice/store/db/DbAppStore.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ abstract class DbTxLogAppStore[TXE](
2424
domainMigrationInfo: DomainMigrationInfo,
2525
participantId: ParticipantId,
2626
enableissue12777Workaround: Boolean,
27+
enableImportUpdateBackfill: Boolean,
2728
backfillingRequired: BackfillingRequirement,
2829
oHistoryMetrics: Option[HistoryMetrics] = None,
2930
)(implicit
@@ -37,6 +38,7 @@ abstract class DbTxLogAppStore[TXE](
3738
domainMigrationInfo = domainMigrationInfo,
3839
participantId = participantId,
3940
enableissue12777Workaround = enableissue12777Workaround,
41+
enableImportUpdateBackfill = enableImportUpdateBackfill,
4042
backfillingRequired,
4143
oHistoryMetrics = oHistoryMetrics,
4244
)
@@ -66,6 +68,7 @@ abstract class DbAppStore(
6668
domainMigrationInfo: DomainMigrationInfo,
6769
participantId: ParticipantId,
6870
enableissue12777Workaround: Boolean,
71+
enableImportUpdateBackfill: Boolean,
6972
backfillingRequired: BackfillingRequirement,
7073
oHistoryMetrics: Option[HistoryMetrics] = None,
7174
)(implicit
@@ -112,6 +115,7 @@ abstract class DbAppStore(
112115
backfillingRequired,
113116
loggerFactory,
114117
enableissue12777Workaround,
118+
enableImportUpdateBackfill,
115119
oHistoryMetrics,
116120
)
117121

apps/common/src/test/scala/org/lfdecentralizedtrust/splice/store/TxLogBackfillingStoreTest.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ class TxLogBackfillingStoreTest
554554
backfillingRequired,
555555
loggerFactory,
556556
enableissue12777Workaround = true,
557+
enableImportUpdateBackfill = true,
557558
)
558559
}
559560

apps/common/src/test/scala/org/lfdecentralizedtrust/splice/store/UpdateHistoryTestBase.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ abstract class UpdateHistoryTestBase
252252
backfillingRequired,
253253
loggerFactory,
254254
enableissue12777Workaround = true,
255+
enableImportUpdateBackfill = true,
255256
)
256257
}
257258

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/ScanApp.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class ScanApp(
172172
migrationInfo,
173173
participantId,
174174
config.cache.svNodeStateTtl,
175+
config.updateHistoryBackfillImportUpdatesEnabled,
175176
nodeMetrics.dbScanStore,
176177
)
177178
acsSnapshotStore = AcsSnapshotStore(

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/automation/ScanAutomationService.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class ScanAutomationService(
7171
svName,
7272
ledgerClient,
7373
config.updateHistoryBackfillBatchSize,
74+
config.updateHistoryBackfillImportUpdatesEnabled,
7475
svParty,
7576
upgradesConfig,
7677
triggerContext,

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/automation/ScanHistoryBackfillingTrigger.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class ScanHistoryBackfillingTrigger(
4949
svName: String,
5050
ledgerClient: SpliceLedgerClient,
5151
batchSize: Int,
52+
importUpdateBackfillingEnabled: Boolean,
5253
svParty: PartyId,
5354
upgradesConfig: UpgradesConfig,
5455
override protected val context: TriggerContext,
@@ -122,6 +123,11 @@ class ScanHistoryBackfillingTrigger(
122123
case ScanHistoryBackfillingTrigger.InitializeBackfillingTask(_) =>
123124
initializeBackfilling()
124125
case ScanHistoryBackfillingTrigger.ImportUpdatesBackfillTask() =>
126+
if (!importUpdateBackfillingEnabled) {
127+
throw new RuntimeException(
128+
"Import updates backfilling is disabled, this place should not be reached"
129+
)
130+
}
125131
performImportUpdatesBackfilling()
126132
case ScanHistoryBackfillingTrigger.BackfillTask() =>
127133
performBackfilling()

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/config/ScanAppConfig.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ case class ScanAppBackendConfig(
4343
spliceInstanceNames: SpliceInstanceNamesConfig,
4444
updateHistoryBackfillEnabled: Boolean = true,
4545
updateHistoryBackfillBatchSize: Int = 100,
46+
updateHistoryBackfillImportUpdatesEnabled: Boolean = false,
4647
txLogBackfillEnabled: Boolean = true,
4748
txLogBackfillBatchSize: Int = 100,
4849
bftSequencers: Seq[BftSequencerConfig] = Seq.empty,
4950
cache: ScanCacheConfig = ScanCacheConfig(),
51+
// TODO(#1164): Enable by default
5052
) extends SpliceBackendConfig
5153
with BaseScanAppConfig // TODO(DACH-NY/canton-network-node#736): fork or generalize this trait.
5254
{

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/store/ScanStore.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ object ScanStore {
319319
domainMigrationInfo: DomainMigrationInfo,
320320
participantId: ParticipantId,
321321
svNodeStateCacheTtl: NonNegativeFiniteDuration,
322+
enableImportUpdateBackfill: Boolean,
322323
metrics: DbScanStoreMetrics,
323324
)(implicit
324325
ec: ExecutionContext,
@@ -337,6 +338,7 @@ object ScanStore {
337338
domainMigrationInfo,
338339
participantId,
339340
svNodeStateCacheTtl,
341+
enableImportUpdateBackfill,
340342
metrics,
341343
)
342344
case storageType => throw new RuntimeException(s"Unsupported storage type $storageType")

0 commit comments

Comments
 (0)