From 49584d17ba7e650ba26ac344714500d5a6e72793 Mon Sep 17 00:00:00 2001 From: Tsachi Herman <24438559+tsachiherman@users.noreply.github.com> Date: Thu, 26 Oct 2023 11:48:24 -0400 Subject: [PATCH 1/2] remove noisy rollback message. --- cmd/soroban-rpc/internal/ingest/service.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/soroban-rpc/internal/ingest/service.go b/cmd/soroban-rpc/internal/ingest/service.go index 744e515f9..d90221777 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 == false { + // 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 err := tx.Rollback(); err != nil && err != supportdb.ErrAlreadyRolledback { + s.logger.WithError(err).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 } From 37284987a2eb652d98935a9cb6691b8ac3b0662e Mon Sep 17 00:00:00 2001 From: Tsachi Herman <24438559+tsachiherman@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:28:53 -0400 Subject: [PATCH 2/2] update per feedback from golangci --- cmd/soroban-rpc/internal/ingest/service.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/soroban-rpc/internal/ingest/service.go b/cmd/soroban-rpc/internal/ingest/service.go index d90221777..4865e59c4 100644 --- a/cmd/soroban-rpc/internal/ingest/service.go +++ b/cmd/soroban-rpc/internal/ingest/service.go @@ -211,11 +211,11 @@ func (s *Service) fillEntriesFromCheckpoint(ctx context.Context, archive history } transactionCommitted := false defer func() { - if transactionCommitted == false { + 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 err := tx.Rollback(); err != nil && err != supportdb.ErrAlreadyRolledback { - s.logger.WithError(err).Warn("could not rollback fillEntriesFromCheckpoint write transactions") + if rollbackErr := tx.Rollback(); rollbackErr != nil && rollbackErr != supportdb.ErrAlreadyRolledback { + s.logger.WithError(rollbackErr).Warn("could not rollback fillEntriesFromCheckpoint write transactions") } } }()