From 665aa8661384c10a80e8be8919f55309d6aeb64c Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Mon, 8 Jul 2024 22:27:11 +0200 Subject: [PATCH] Fix typo from #237 (#238) * Fix typo from #237 I didn't adapt the logic right. This was hard to debug because, in integration tests, it caused the daemon to run `d.logger.WithError(err).Fatal("could not build migrations")`, which in turn runs `os.Exit` which ends the test right away (without flushing logs etc). I need to think how to improve this. One option is to override the `ExitFunc` in logrus with an assertion. * Add verbosity again to see what's wrong * Fix the error further * Revert "Add verbosity again to see what's wrong" This reverts commit 0be1cd6e01fbedcab3fcd48c4634c2ff0f3debff. --- cmd/soroban-rpc/internal/db/migration.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/soroban-rpc/internal/db/migration.go b/cmd/soroban-rpc/internal/db/migration.go index e3df2070..552cc98d 100644 --- a/cmd/soroban-rpc/internal/db/migration.go +++ b/cmd/soroban-rpc/internal/db/migration.go @@ -136,7 +136,7 @@ func newGuardedDataMigration( return nil, err } latestLedger, err := NewLedgerEntryReader(db).GetLatestLedgerSequence(ctx) - if errors.Is(err, ErrEmptyDB) { + if err != nil && !errors.Is(err, ErrEmptyDB) { err = errors.Join(err, migrationDB.Rollback()) return nil, fmt.Errorf("failed to get latest ledger sequence: %w", err) }