Backport fixes for issue #367 to v4. #394
@ -84,13 +84,13 @@ func (tx *DelayedTx) Commit(ctx context.Context) error {
|
||||
for _, item := range tx.cache {
|
||||
switch item := item.(type) {
|
||||
case *copyFrom:
|
||||
_, err := base.CopyFrom(ctx, item.tableName, item.columnNames, item.rows)
|
||||
_, err = base.CopyFrom(ctx, item.tableName, item.columnNames, item.rows)
|
||||
if err != nil {
|
||||
log.Error("COPY error", "table", item.tableName, "err", err)
|
||||
return err
|
||||
}
|
||||
case cachedStmt:
|
||||
_, err := base.Exec(ctx, item.sql, item.args...)
|
||||
_, err = base.Exec(ctx, item.sql, item.args...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -39,18 +39,19 @@ func countStateDiffBegin(block *types.Block) (time.Time, log.Logger) {
|
||||
return start, logger
|
||||
}
|
||||
|
||||
func countStateDiffEnd(start time.Time, logger log.Logger, err error) time.Duration {
|
||||
func countStateDiffEnd(start time.Time, logger log.Logger, err *error) time.Duration {
|
||||
duration := time.Since(start)
|
||||
defaultStatediffMetrics.underway.Dec(1)
|
||||
if nil == err {
|
||||
defaultStatediffMetrics.succeeded.Inc(1)
|
||||
} else {
|
||||
failed := nil != err && nil != *err
|
||||
if failed {
|
||||
defaultStatediffMetrics.failed.Inc(1)
|
||||
} else {
|
||||
defaultStatediffMetrics.succeeded.Inc(1)
|
||||
}
|
||||
defaultStatediffMetrics.totalProcessingTime.Inc(duration.Milliseconds())
|
||||
|
||||
logger.Debug(fmt.Sprintf("writeStateDiff END (duration=%dms, err=%t) [underway=%d, succeeded=%d, failed=%d, total_time=%dms]",
|
||||
duration.Milliseconds(), nil != err,
|
||||
duration.Milliseconds(), failed,
|
||||
defaultStatediffMetrics.underway.Count(),
|
||||
defaultStatediffMetrics.succeeded.Count(),
|
||||
defaultStatediffMetrics.failed.Count(),
|
||||
|
@ -884,7 +884,7 @@ func (sds *Service) writeStateDiff(block *types.Block, parentRoot common.Hash, p
|
||||
var err error
|
||||
var tx interfaces.Batch
|
||||
start, logger := countStateDiffBegin(block)
|
||||
defer countStateDiffEnd(start, logger, err)
|
||||
defer countStateDiffEnd(start, logger, &err)
|
||||
if params.IncludeTD {
|
||||
totalDifficulty = sds.BlockChain.GetTd(block.Hash(), block.NumberU64())
|
||||
}
|
||||
@ -916,7 +916,7 @@ func (sds *Service) writeStateDiff(block *types.Block, parentRoot common.Hash, p
|
||||
BlockNumber: block.Number(),
|
||||
}, params, output, codeOutput)
|
||||
// TODO this anti-pattern needs to be sorted out eventually
|
||||
if err := tx.Submit(err); err != nil {
|
||||
if err = tx.Submit(err); err != nil {
|
||||
return fmt.Errorf("batch transaction submission failed: %w", err)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user