Skip to content

Commit

Permalink
Revert "Refine logging of migrations and tx ingestion (stellar#237)"
Browse files Browse the repository at this point in the history
This reverts commit 556d535.
  • Loading branch information
2opremio committed Jul 8, 2024
1 parent acc9cfc commit 6ad1e61
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
10 changes: 3 additions & 7 deletions cmd/soroban-rpc/internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,7 @@ func (d *Daemon) mustInitializeStorage(cfg *config.Config) (*feewindow.FeeWindow
cfg.NetworkPassphrase,
cfg.HistoryRetentionWindow,
)
feewindows := feewindow.NewFeeWindows(
cfg.ClassicFeeStatsLedgerRetentionWindow,
cfg.SorobanFeeStatsLedgerRetentionWindow,
cfg.NetworkPassphrase,
)
feewindows := feewindow.NewFeeWindows(cfg.ClassicFeeStatsLedgerRetentionWindow, cfg.SorobanFeeStatsLedgerRetentionWindow, cfg.NetworkPassphrase)

readTxMetaCtx, cancelReadTxMeta := context.WithTimeout(context.Background(), cfg.IngestionTimeout)
defer cancelReadTxMeta()
Expand All @@ -319,7 +315,7 @@ func (d *Daemon) mustInitializeStorage(cfg *config.Config) (*feewindow.FeeWindow
initialSeq = currentSeq
d.logger.WithFields(supportlog.F{
"seq": currentSeq,
}).Info("initializing in-memory store and applying DB data migrations")
}).Info("initializing in-memory store")
} else if (currentSeq-initialSeq)%inMemoryInitializationLedgerLogPeriod == 0 {
d.logger.WithFields(supportlog.F{
"seq": currentSeq,
Expand Down Expand Up @@ -350,7 +346,7 @@ func (d *Daemon) mustInitializeStorage(cfg *config.Config) (*feewindow.FeeWindow
if currentSeq != 0 {
d.logger.WithFields(supportlog.F{
"seq": currentSeq,
}).Info("finished initializing in-memory store and applying DB data migrations")
}).Info("finished initializing in-memory store")
}

return feewindows, eventStore
Expand Down
1 change: 0 additions & 1 deletion cmd/soroban-rpc/internal/db/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

sq "github.com/Masterminds/squirrel"

"github.com/stellar/go/xdr"

"github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/ledgerbucketwindow"
Expand Down
20 changes: 5 additions & 15 deletions cmd/soroban-rpc/internal/db/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,9 @@ type guardedMigration struct {
db *DB
migration MigrationApplier
alreadyMigrated bool
logger *log.Entry
applyLogged bool
}

func newGuardedDataMigration(
ctx context.Context, uniqueMigrationName string, logger *log.Entry, factory migrationApplierFactory, db *DB,
) (Migration, error) {
func newGuardedDataMigration(ctx context.Context, uniqueMigrationName string, factory migrationApplierFactory, db *DB) (Migration, error) {
migrationDB := &DB{
cache: db.cache,
SessionInterface: db.SessionInterface.Clone(),
Expand All @@ -136,7 +132,7 @@ func newGuardedDataMigration(
return nil, err
}
latestLedger, err := NewLedgerEntryReader(db).GetLatestLedgerSequence(ctx)
if errors.Is(err, ErrEmptyDB) {
if err != nil && err != ErrEmptyDB {
err = errors.Join(err, migrationDB.Rollback())
return nil, fmt.Errorf("failed to get latest ledger sequence: %w", err)
}
Expand All @@ -150,7 +146,6 @@ func newGuardedDataMigration(
db: migrationDB,
migration: applier,
alreadyMigrated: previouslyMigrated,
logger: logger,
}
return guardedMigration, nil
}
Expand All @@ -161,10 +156,6 @@ func (g *guardedMigration) Apply(ctx context.Context, meta xdr.LedgerCloseMeta)
// but, just in case.
return nil
}
if !g.applyLogged {
g.logger.WithField("ledger", meta.LedgerSequence()).Info("applying migration")
g.applyLogged = true
}
return g.migration.Apply(ctx, meta)
}

Expand All @@ -186,20 +177,19 @@ func (g *guardedMigration) Commit(ctx context.Context) error {
return g.db.Commit()
}

func (g *guardedMigration) Rollback(_ context.Context) error {
func (g *guardedMigration) Rollback(ctx context.Context) error {
return g.db.Rollback()
}

func BuildMigrations(ctx context.Context, logger *log.Entry, db *DB, cfg *config.Config) (Migration, error) {
migrationName := "TransactionsTable"
logger = logger.WithField("migration", migrationName)
factory := newTransactionTableMigration(
ctx,
logger,
logger.WithField("migration", migrationName),
cfg.HistoryRetentionWindow,
cfg.NetworkPassphrase,
)
m, err := newGuardedDataMigration(ctx, migrationName, logger, factory, db)
m, err := newGuardedDataMigration(ctx, migrationName, factory, db)
if err != nil {
return nil, fmt.Errorf("creating guarded transaction migration: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-rpc/internal/db/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (txn *transactionHandler) InsertTransactions(lcm xdr.LedgerCloseMeta) error
_, err = query.RunWith(txn.stmtCache).Exec()

L.WithField("duration", time.Since(start)).
Debugf("Ingested %d transaction lookups", len(transactions))
Infof("Ingested %d transaction lookups", len(transactions))

return err
}
Expand Down

0 comments on commit 6ad1e61

Please sign in to comment.