diff --git a/cmd/soroban-rpc/internal/ingest/service.go b/cmd/soroban-rpc/internal/ingest/service.go index 744e515f9..4865e59c4 100644 --- a/cmd/soroban-rpc/internal/ingest/service.go +++ b/cmd/soroban-rpc/internal/ingest/service.go @@ -12,6 +12,7 @@ import ( "github.com/stellar/go/historyarchive" "github.com/stellar/go/ingest" backends "github.com/stellar/go/ingest/ledgerbackend" + supportdb "github.com/stellar/go/support/db" "github.com/stellar/go/support/log" "github.com/stellar/go/xdr" @@ -208,9 +209,14 @@ func (s *Service) fillEntriesFromCheckpoint(ctx context.Context, archive history if err != nil { return err } + transactionCommitted := false defer func() { - if err := tx.Rollback(); err != nil { - s.logger.WithError(err).Warn("could not rollback fillEntriesFromCheckpoint write transactions") + if !transactionCommitted { + // Internally, we might already have rolled back the transaction. We should + // not generate benign error/warning here in case the transaction was already rolled back. + if rollbackErr := tx.Rollback(); rollbackErr != nil && rollbackErr != supportdb.ErrAlreadyRolledback { + s.logger.WithError(rollbackErr).Warn("could not rollback fillEntriesFromCheckpoint write transactions") + } } }() @@ -222,9 +228,12 @@ func (s *Service) fillEntriesFromCheckpoint(ctx context.Context, archive history } s.logger.Info("committing checkpoint ledger entries") - if err := tx.Commit(checkpointLedger); err != nil { + err = tx.Commit(checkpointLedger) + transactionCommitted = true + if err != nil { return err } + s.logger.Info("finished checkpoint processing") return nil }