Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rerun conditional migrations #6565

Merged
merged 58 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
102dff1
Initial commit to rerun said migrations.
mgoelswirlds Aug 1, 2023
ae2ad08
Changes to fix sonarcloud issues.
mgoelswirlds Aug 1, 2023
901eb32
Changes to fix sonarcloud issues.
mgoelswirlds Aug 1, 2023
bc8af67
Adding common code to repeatable migration.
mgoelswirlds Aug 2, 2023
ae0ac55
Adding test cases and renaming variables.
mgoelswirlds Aug 2, 2023
0388007
Adding code back to respective migration tests.
mgoelswirlds Aug 3, 2023
488f89c
Removing unneeded variables.
mgoelswirlds Aug 3, 2023
30aa94a
Removing extra file.
mgoelswirlds Aug 3, 2023
9580a62
Set items to null.
mgoelswirlds Aug 4, 2023
ea2991a
Update hedera-mirror-importer/src/main/java/com/hedera/mirror/importe…
mgoelswirlds Aug 4, 2023
7f575b9
Update hedera-mirror-importer/src/main/java/com/hedera/mirror/importe…
mgoelswirlds Aug 4, 2023
2c6e69e
Update hedera-mirror-importer/src/main/java/com/hedera/mirror/importe…
mgoelswirlds Aug 4, 2023
8888db3
PR comment changes.TokenAccountBalanceMigration
mgoelswirlds Aug 4, 2023
305bc8b
Undoing the last changes and adding transaction based event listeners…
mgoelswirlds Aug 8, 2023
0653952
Merge branch 'main' into 6397-Time-sensitive-migrations
mgoelswirlds Aug 8, 2023
e35f1ba
Fixing merge conflict.
mgoelswirlds Aug 8, 2023
79feac5
Addressing PR comments.
mgoelswirlds Aug 8, 2023
cd3a698
Changing comments to match correct services version
mgoelswirlds Aug 8, 2023
606334b
Changing the version to match the services version
mgoelswirlds Aug 8, 2023
8806622
Addressing PR comments
mgoelswirlds Aug 8, 2023
392813e
combining ifs
mgoelswirlds Aug 8, 2023
fc5d337
Merge remote-tracking branch 'origin/main' into 6397-Time-sensitive-m…
mgoelswirlds Aug 9, 2023
4f5ccd7
fixing tests
mgoelswirlds Aug 9, 2023
32789d7
Undoing side effects.
mgoelswirlds Aug 9, 2023
20d71a2
Addressing PR comments
mgoelswirlds Aug 9, 2023
1143306
Fixing InitializeEntityBalanceMigration
mgoelswirlds Aug 10, 2023
f11db71
Adding tests to the synthetic migrations.
mgoelswirlds Aug 10, 2023
8a2340a
Addressing PR comments.
mgoelswirlds Aug 10, 2023
c850cb4
removing a file checked in by mistke
mgoelswirlds Aug 10, 2023
dbf7c61
Addressing PR comments
mgoelswirlds Aug 10, 2023
49463bb
Changing synthetic migrations to run based on consensus timestamp and…
mgoelswirlds Aug 13, 2023
8879cb5
Making migration changes to be more deterministic.
mgoelswirlds Aug 14, 2023
22a330e
Merge remote-tracking branch 'origin/main' into 6397-Time-sensitive-m…
mgoelswirlds Aug 14, 2023
98b0d70
missed checkin
mgoelswirlds Aug 14, 2023
3d03c94
Update hedera-mirror-importer/src/main/java/com/hedera/mirror/importe…
mgoelswirlds Aug 14, 2023
1dcd887
PR comment changes
mgoelswirlds Aug 14, 2023
99f8f68
PR comment changes
mgoelswirlds Aug 14, 2023
d701633
Fix test
mgoelswirlds Aug 14, 2023
42e323a
Pulling up code in an abstract class
mgoelswirlds Aug 15, 2023
b164527
Moving the onEnd logic in the common base class.
mgoelswirlds Aug 15, 2023
4e9737a
Merge remote-tracking branch 'origin/main' into 6397-Time-sensitive-m…
mgoelswirlds Aug 15, 2023
63c9f10
Adding the logic to save to the repository before running onENd.
mgoelswirlds Aug 15, 2023
15e19dc
Undoing Account balance file save changes.
mgoelswirlds Aug 15, 2023
ed59c5f
Update README.md
mgoelswirlds Aug 15, 2023
4bd8e6e
Saving the timeOffset for errata migration
mgoelswirlds Aug 15, 2023
e71e85b
Merge branch '6397-Time-sensitive-migrations' of https://github.com/h…
mgoelswirlds Aug 15, 2023
1ac1042
Providing order priority to Migrations.
mgoelswirlds Aug 16, 2023
97a1395
Merge remote-tracking branch 'origin/main' into 6397-Time-sensitive-m…
mgoelswirlds Aug 16, 2023
e127396
Merge remote-tracking branch 'origin/main' into 6397-Time-sensitive-m…
mgoelswirlds Aug 16, 2023
45702ab
Adding coverage.
mgoelswirlds Aug 16, 2023
c4acb56
Refactoring tests to add common setup methods.
mgoelswirlds Aug 17, 2023
180015f
Merge remote-tracking branch 'origin/main' into 6397-Time-sensitive-m…
mgoelswirlds Aug 17, 2023
c393971
Fixing Initialize balance test coverage.
mgoelswirlds Aug 17, 2023
604bd3e
Fixing Initialize balance test coverage.
mgoelswirlds Aug 17, 2023
4e752d9
Adding more coverage.
mgoelswirlds Aug 17, 2023
00815e1
Creating new migration objects in each onEnd test for InitializeEntit…
mgoelswirlds Aug 18, 2023
6e8ee7a
Deleting leftover method.
mgoelswirlds Aug 18, 2023
e7ddc3a
moving migration initialization to before each.
mgoelswirlds Aug 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

import com.google.common.base.Stopwatch;
import com.hedera.mirror.importer.MirrorProperties;
import com.hedera.mirror.importer.parser.balance.InitializeBalanceEvent;
import jakarta.inject.Named;
import org.flywaydb.core.api.MigrationVersion;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.event.EventListener;
import org.springframework.jdbc.core.JdbcOperations;

@Named
Expand Down Expand Up @@ -87,4 +89,12 @@ protected void doMigrate() {
int count = jdbcOperations.update(INITIALIZE_ENTITY_BALANCE_SQL);
log.info("Initialized {} entities balance in {}", count, stopwatch);
}

@EventListener
public void reRunMigration(InitializeBalanceEvent event) {
mgoelswirlds marked this conversation as resolved.
Show resolved Hide resolved
log.info(
"Re-running the InitializeEntityBalanceMigration on InitializeBalanceEvent created at {}",
event.getTimestamp());
mgoelswirlds marked this conversation as resolved.
Show resolved Hide resolved
doMigrate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
package com.hedera.mirror.importer.migration;

import com.hedera.mirror.common.domain.entity.EntityId;
import com.hedera.mirror.common.domain.transaction.RecordFile;
import com.hedera.mirror.importer.MirrorProperties;
import com.hedera.mirror.importer.db.DBProperties;
import com.hedera.mirror.importer.exception.ImporterException;
import com.hedera.mirror.importer.parser.record.RecordStreamFileListener;
import com.hedera.mirror.importer.repository.RecordFileRepository;
import com.hederahashgraph.api.proto.java.Key;
import jakarta.inject.Named;
import java.time.Duration;
Expand All @@ -30,13 +34,16 @@
import lombok.Data;
import org.flywaydb.core.api.MigrationVersion;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.util.Version;
import org.springframework.jdbc.core.DataClassRowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.transaction.support.TransactionOperations;

@Named
public class SyntheticCryptoTransferApprovalMigration extends AsyncJavaMigration<Long> {
public class SyntheticCryptoTransferApprovalMigration extends AsyncJavaMigration<Long>
implements RecordStreamFileListener {

public static final Version HAPI_VERSION_0_38_10 = new Version(0, 38, 10);
steven-sheehy marked this conversation as resolved.
Show resolved Hide resolved
// The contract id of the first synthetic transfer that could have exhibited this problem
private static final long GRANDFATHERED_ID = 2119900L;
// The created timestamp of the grandfathered id contract
Expand Down Expand Up @@ -140,6 +147,32 @@ with contractresults as (
update token_transfer set is_approval = true where consensus_timestamp = :consensus_timestamp and token_id = :token_id and account_id = :sender
""";

private final RecordFileRepository recordFileRepository;

@Override
public void onStart() throws ImporterException {
// Not Applicable
}
xin-hedera marked this conversation as resolved.
Show resolved Hide resolved

@Override
public void onEnd(RecordFile streamFile) throws ImporterException {
if (streamFile == null) {
return;
}

xin-hedera marked this conversation as resolved.
Show resolved Hide resolved
if ((streamFile.getHapiVersion()).isGreaterThanOrEqualTo(HAPI_VERSION_0_38_10)) {
var latestFile = recordFileRepository.findLatestWithOffset(1).orElse(null);
if (latestFile != null && latestFile.getHapiVersion().isLessThan(HAPI_VERSION_0_38_10)) {
xin-hedera marked this conversation as resolved.
Show resolved Hide resolved
migrateAsync();
xin-hedera marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

@Override
public void onError() {
// Not Applicable
}

private enum TRANSFER_TYPE {
CRYPTO_TRANSFER,
NFT_TRANSFER,
Expand All @@ -157,10 +190,12 @@ public SyntheticCryptoTransferApprovalMigration(
DBProperties dbProperties,
NamedParameterJdbcTemplate transferJdbcTemplate,
MirrorProperties mirrorProperties,
TransactionOperations transactionOperations) {
TransactionOperations transactionOperations,
RecordFileRepository recordFileRepository) {
super(transferJdbcTemplate, dbProperties.getSchema(), transactionOperations);
this.transferJdbcTemplate = transferJdbcTemplate;
this.mirrorProperties = mirrorProperties;
this.recordFileRepository = recordFileRepository;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@
package com.hedera.mirror.importer.migration;

import com.google.common.base.Stopwatch;
import com.hedera.mirror.common.domain.transaction.RecordFile;
import com.hedera.mirror.importer.MirrorProperties;
import com.hedera.mirror.importer.config.Owner;
import com.hedera.mirror.importer.exception.ImporterException;
import com.hedera.mirror.importer.parser.record.RecordStreamFileListener;
import com.hedera.mirror.importer.repository.RecordFileRepository;
import jakarta.inject.Named;
import org.flywaydb.core.api.MigrationVersion;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.util.Version;
import org.springframework.jdbc.core.JdbcTemplate;

@Named
public class SyntheticNftAllowanceOwnerMigration extends RepeatableMigration {
public class SyntheticNftAllowanceOwnerMigration extends RepeatableMigration implements RecordStreamFileListener {
// 779
xin-hedera marked this conversation as resolved.
Show resolved Hide resolved
public static final Version HAPI_VERSION_0_37_0 = new Version(0, 37, 0);
steven-sheehy marked this conversation as resolved.
Show resolved Hide resolved
private final RecordFileRepository recordFileRepository;

private static final String UPDATE_NFT_ALLOWANCE_OWNER_SQL =
"""
Expand Down Expand Up @@ -107,9 +115,13 @@ insert into nft_allowance (approved_for_all, owner, payer_account_id, spender, t
private final JdbcTemplate jdbcTemplate;

@Lazy
public SyntheticNftAllowanceOwnerMigration(@Owner JdbcTemplate jdbcTemplate, MirrorProperties mirrorProperties) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration took 779 ms on mainnet.So not converting it to Async.

public SyntheticNftAllowanceOwnerMigration(
@Owner JdbcTemplate jdbcTemplate,
MirrorProperties mirrorProperties,
RecordFileRepository recordFileRepository) {
super(mirrorProperties.getMigration());
this.jdbcTemplate = jdbcTemplate;
this.recordFileRepository = recordFileRepository;
}

@Override
Expand All @@ -129,4 +141,28 @@ protected void doMigrate() {
jdbcTemplate.execute(UPDATE_NFT_ALLOWANCE_OWNER_SQL);
log.info("Updated nft allowance owners in {}", stopwatch);
}

@Override
public void onStart() throws ImporterException {
// Not Applicable
}

@Override
public void onEnd(RecordFile streamFile) throws ImporterException {
if (streamFile == null) {
return;
}

if ((streamFile.getHapiVersion()).isGreaterThanOrEqualTo(HAPI_VERSION_0_37_0)) {
var latestFile = recordFileRepository.findLatestWithOffset(1).orElse(null);
if (latestFile != null && latestFile.getHapiVersion().isLessThan(HAPI_VERSION_0_37_0)) {
doMigrate();
}
}
}

@Override
public void onError() {
// Not Applicable
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@
package com.hedera.mirror.importer.migration;

import com.google.common.base.Stopwatch;
import com.hedera.mirror.common.domain.transaction.RecordFile;
import com.hedera.mirror.importer.MirrorProperties;
import com.hedera.mirror.importer.config.Owner;
import com.hedera.mirror.importer.exception.ImporterException;
import com.hedera.mirror.importer.parser.record.RecordStreamFileListener;
import com.hedera.mirror.importer.repository.RecordFileRepository;
import jakarta.inject.Named;
import org.flywaydb.core.api.MigrationVersion;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.util.Version;
import org.springframework.jdbc.core.JdbcTemplate;

@Named
public class SyntheticTokenAllowanceOwnerMigration extends RepeatableMigration {
public class SyntheticTokenAllowanceOwnerMigration extends RepeatableMigration implements RecordStreamFileListener {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration took 10158 ms on mainnet.So not converting it to Async.

Copy link
Collaborator

@xin-hedera xin-hedera Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt it can work in environment where the owner and regular user are different, e.g., mirror_node and mirror_importer.

The migration uses the owner jdbcTemplate bean because it deletes rows. in some environment, mirror_importer may not be able to delete rows.

When the migration runs inside onEnd, it's in the same database transaction, and the connection in the thread local storage uses regular user mirror_importer. The migration most likely uses the same connection, and may fail to delete rows.

Copy link
Collaborator

@xin-hedera xin-hedera Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you check if running it inside onEnd would actually pick a connection with different credentials other than owner?

this is a blocker for both SyntheticNftAllowanceOwnerMigration and SyntheticTokenAllowanceOwnerMigration

No I did not. Checking now.

Copy link
Member Author

@mgoelswirlds mgoelswirlds Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I did not. Will need to check this. looking now.
Even if it is a different user i.e. mirror_importer, I need to verify that it can delete the rows right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can discuss. running with mirror_importer may not break ourselves but can break other mirrornode operators in case in their environment mirror_importer doesn't have permission to delete rows.

then we may have to turn these two migrations to be async.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Lets discuss further offline.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that even when migrate is called from with the onEnd it uses the mirror_node user.

// 10158
xin-hedera marked this conversation as resolved.
Show resolved Hide resolved
public static final Version HAPI_VERSION_0_37_0 = new Version(0, 37, 0);
steven-sheehy marked this conversation as resolved.
Show resolved Hide resolved
private final RecordFileRepository recordFileRepository;

private static final String UPDATE_TOKEN_ALLOWANCE_OWNER_SQL =
"""
Expand Down Expand Up @@ -110,9 +118,13 @@ insert into token_allowance (amount, amount_granted, owner, payer_account_id, sp
private final JdbcTemplate jdbcTemplate;

@Lazy
public SyntheticTokenAllowanceOwnerMigration(@Owner JdbcTemplate jdbcTemplate, MirrorProperties mirrorProperties) {
public SyntheticTokenAllowanceOwnerMigration(
@Owner JdbcTemplate jdbcTemplate,
MirrorProperties mirrorProperties,
RecordFileRepository recordFileRepository) {
super(mirrorProperties.getMigration());
this.jdbcTemplate = jdbcTemplate;
this.recordFileRepository = recordFileRepository;
}

@Override
Expand All @@ -132,4 +144,27 @@ protected void doMigrate() {
jdbcTemplate.execute(UPDATE_TOKEN_ALLOWANCE_OWNER_SQL);
log.info("Updated token allowance owners in {}", stopwatch);
}

@Override
public void onStart() throws ImporterException {
// Not Applicable
}

@Override
public void onEnd(RecordFile streamFile) throws ImporterException {
if (streamFile == null) {
return;
}
if ((streamFile.getHapiVersion()).isGreaterThanOrEqualTo(HAPI_VERSION_0_37_0)) {
var latestFile = recordFileRepository.findLatestWithOffset(1).orElse(null);
if (latestFile != null && latestFile.getHapiVersion().isLessThan(HAPI_VERSION_0_37_0)) {
doMigrate();
}
}
}

@Override
public void onError() {
// Not Applicable
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

import com.google.common.base.Stopwatch;
import com.hedera.mirror.importer.MirrorProperties;
import com.hedera.mirror.importer.parser.balance.InitializeBalanceEvent;
import jakarta.inject.Named;
import org.flywaydb.core.api.MigrationVersion;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.event.EventListener;
import org.springframework.jdbc.core.JdbcOperations;

@Named
Expand Down Expand Up @@ -89,4 +91,10 @@ protected void doMigrate() {
int count = jdbcOperations.update(UPDATE_TOKEN_ACCOUNT_SQL);
log.info("Migrated {} token account balances in {}", count, stopwatch);
}

@EventListener
public void reRunMigration(InitializeBalanceEvent event) {
log.info("Running this on InitializeBalanceEvent created at {}", event.getTimestamp());
doMigrate();
}
}
steven-sheehy marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
import io.micrometer.core.instrument.Timer;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public abstract class AbstractStreamFileParser<T extends StreamFile<?>> implements StreamFileParser<T> {

public static final String STREAM_PARSE_DURATION_METRIC_NAME = "hedera.mirror.parse.duration";

protected final AtomicReference<T> last;
protected final Logger log = LogManager.getLogger(getClass());
protected final MeterRegistry meterRegistry;
protected final ParserProperties parserProperties;
Expand All @@ -44,6 +46,8 @@ protected AbstractStreamFileParser(
MeterRegistry meterRegistry,
ParserProperties parserProperties,
StreamFileRepository<T, Long> streamFileRepository) {

this.last = new AtomicReference<>();
this.meterRegistry = meterRegistry;
this.parserProperties = parserProperties;
this.streamFileRepository = streamFileRepository;
Expand Down Expand Up @@ -86,7 +90,7 @@ public void parse(T streamFile) {
success = true;
Instant consensusInstant = Instant.ofEpochSecond(0L, streamFile.getConsensusEnd());
parseLatencyMetric.record(Duration.between(consensusInstant, Instant.now()));
} catch (Throwable e) {
} catch (Exception e) {
log.error("Error parsing file {} after {}", streamFile.getName(), stopwatch, e);
throw e;
} finally {
Expand All @@ -102,14 +106,18 @@ private boolean shouldParse(T streamFile) {
if (!parserProperties.isEnabled()) {
return false;
}
var lastStreamFileFromDB = streamFileRepository.findLatest();

var last = streamFileRepository.findLatest();

if (last.isEmpty()) {
if (lastStreamFileFromDB.isEmpty()) {
return true;
}

var lastStreamFile = last.get();
if (last.get() == null) {
last.set(lastStreamFileFromDB.get());
last.get().setItems(null);
}

var lastStreamFile = lastStreamFileFromDB.get();
var name = streamFile.getName();

if (lastStreamFile.getConsensusEnd() >= streamFile.getConsensusStart()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -44,6 +46,7 @@
@Named
public class AccountBalanceFileParser extends AbstractStreamFileParser<AccountBalanceFile> {

private final ApplicationEventPublisher applicationEventPublisher;
private final BatchPersister batchPersister;
private final MirrorDateRangePropertiesProcessor mirrorDateRangePropertiesProcessor;
private final BalanceStreamFileListener streamFileListener;
Expand All @@ -53,10 +56,12 @@ public AccountBalanceFileParser(
MeterRegistry meterRegistry,
BalanceParserProperties parserProperties,
StreamFileRepository<AccountBalanceFile, Long> accountBalanceFileRepository,
ApplicationEventPublisher applicationEventPublisher,
MirrorDateRangePropertiesProcessor mirrorDateRangePropertiesProcessor,
BalanceStreamFileListener streamFileListener) {
super(meterRegistry, parserProperties, accountBalanceFileRepository);
this.batchPersister = batchPersister;
this.applicationEventPublisher = applicationEventPublisher;
this.mirrorDateRangePropertiesProcessor = mirrorDateRangePropertiesProcessor;
this.streamFileListener = streamFileListener;
}
Expand Down Expand Up @@ -84,6 +89,7 @@ protected void doParse(AccountBalanceFile accountBalanceFile) {
DateRangeFilter filter = mirrorDateRangePropertiesProcessor.getDateRangeFilter(StreamType.BALANCE);
int batchSize = ((BalanceParserProperties) parserProperties).getBatchSize();
long count = 0L;
AccountBalanceFile lastBalanceFile = publishInitializeAccountBalanceEvent();
xin-hedera marked this conversation as resolved.
Show resolved Hide resolved

if (filter.filter(accountBalanceFile.getConsensusTimestamp())) {
List<AccountBalance> accountBalances = new ArrayList<>(batchSize);
Expand Down Expand Up @@ -121,5 +127,17 @@ protected void doParse(AccountBalanceFile accountBalanceFile) {
accountBalanceFile.setLoadEnd(loadEnd.getEpochSecond());
streamFileListener.onEnd(accountBalanceFile);
streamFileRepository.save(accountBalanceFile);

last.compareAndSet(lastBalanceFile, accountBalanceFile);
xin-hedera marked this conversation as resolved.
Show resolved Hide resolved
}

@Nullable
private AccountBalanceFile publishInitializeAccountBalanceEvent() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this into another function to reduce cognitive complexity.

var lastBalanceFile = last.get();
xin-hedera marked this conversation as resolved.
Show resolved Hide resolved
// If no account balance file has been processed since last startup.
if (lastBalanceFile == null) {
applicationEventPublisher.publishEvent(new InitializeBalanceEvent(this));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the first account balance file being processed and the DB is empty then publishing InitializeBalanceEvent which will rerun balance migrations.

}
return lastBalanceFile;
xin-hedera marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading
Loading