cleanup logging
This commit is contained in:
parent
0fabb5a35d
commit
a80ce5abcf
29
service.go
29
service.go
@ -272,10 +272,10 @@ func (sds *Service) writeLoopWorker(params workerParams) {
|
|||||||
defer params.wg.Done()
|
defer params.wg.Done()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case chainEvent := <-params.chainEventCh:
|
case event := <-params.chainEventCh:
|
||||||
log.Debug("Chain event received", "event", chainEvent)
|
block := event.Block
|
||||||
|
log.Debug("Chain event received", "number", block.Number(), "hash", event.Hash)
|
||||||
|
|
||||||
block := chainEvent.Block
|
|
||||||
parent := sds.BlockCache.getParentBlock(block, sds.BlockChain)
|
parent := sds.BlockCache.getParentBlock(block, sds.BlockChain)
|
||||||
if parent == nil {
|
if parent == nil {
|
||||||
log.Error("Parent block is nil, skipping this block", "number", block.Number())
|
log.Error("Parent block is nil, skipping this block", "number", block.Number())
|
||||||
@ -287,14 +287,14 @@ func (sds *Service) writeLoopWorker(params workerParams) {
|
|||||||
sds.writeGenesisStateDiff(parent, log)
|
sds.writeGenesisStateDiff(parent, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("Writing state diff", "number", block.Number().Uint64())
|
log.Info("Writing state diff", "number", block.Number())
|
||||||
sds.writeLoopParams.RLock()
|
sds.writeLoopParams.RLock()
|
||||||
err := sds.writeStateDiffWithRetry(block, parent.Root(), sds.writeLoopParams.Params)
|
err := sds.writeStateDiffWithRetry(block, parent.Root(), sds.writeLoopParams.Params)
|
||||||
sds.writeLoopParams.RUnlock()
|
sds.writeLoopParams.RUnlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("failed to write state diff",
|
log.Error("failed to write state diff",
|
||||||
"number", block.Number().Uint64(),
|
"number", block.Number(),
|
||||||
"hash", block.Hash().String(),
|
"hash", block.Hash(),
|
||||||
"error", err.Error())
|
"error", err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -329,13 +329,13 @@ func (sds *Service) PublishLoop(chainEventCh chan core.ChainEvent) {
|
|||||||
log.Debug("Chain event received", "number", block.Number(), "hash", event.Hash)
|
log.Debug("Chain event received", "number", block.Number(), "hash", event.Hash)
|
||||||
// if we don't have any subscribers, do not process a statediff
|
// if we don't have any subscribers, do not process a statediff
|
||||||
if atomic.LoadInt32(&sds.subscribers) == 0 {
|
if atomic.LoadInt32(&sds.subscribers) == 0 {
|
||||||
log.Debug("Currently no subscribers; processing is halted")
|
log.Debug("Currently no subscribers, skipping block")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
parent := sds.BlockCache.getParentBlock(block, sds.BlockChain)
|
parent := sds.BlockCache.getParentBlock(block, sds.BlockChain)
|
||||||
if parent == nil {
|
if parent == nil {
|
||||||
log.Error("Parent block is nil, skipping this block", "number", block.Number())
|
log.Error("Parent block is nil, skipping block", "number", block.Number())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,13 +371,14 @@ func (sds *Service) streamStateDiff(currentBlock *types.Block, parentRoot common
|
|||||||
// create payload for this subscription type
|
// create payload for this subscription type
|
||||||
payload, err := sds.processStateDiff(currentBlock, parentRoot, params)
|
payload, err := sds.processStateDiff(currentBlock, parentRoot, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("statediff processing error", "number", currentBlock.Number().Uint64(), "parameters", params, "error", err.Error())
|
log.Error("statediff processing error",
|
||||||
|
"number", currentBlock.Number(), "parameters", params, "error", err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for id, sub := range subs {
|
for id, sub := range subs {
|
||||||
select {
|
select {
|
||||||
case sub.PayloadChan <- *payload:
|
case sub.PayloadChan <- *payload:
|
||||||
log.Debug("sending statediff payload at head", "height", currentBlock.Number(), "sub.id", id)
|
log.Debug("sending statediff payload at head", "number", currentBlock.Number(), "sub.id", id)
|
||||||
default:
|
default:
|
||||||
log.Info("unable to send statediff payload; channel has no receiver", "sub.id", id)
|
log.Info("unable to send statediff payload; channel has no receiver", "sub.id", id)
|
||||||
}
|
}
|
||||||
@ -390,7 +391,7 @@ func (sds *Service) streamStateDiff(currentBlock *types.Block, parentRoot common
|
|||||||
// This operation cannot be performed back past the point of db pruning; it requires an archival
|
// This operation cannot be performed back past the point of db pruning; it requires an archival
|
||||||
// node for historical data
|
// node for historical data
|
||||||
func (sds *Service) StateDiffAt(blockNumber uint64, params Params) (*Payload, error) {
|
func (sds *Service) StateDiffAt(blockNumber uint64, params Params) (*Payload, error) {
|
||||||
log.Info("sending state diff", "number", blockNumber)
|
log.Info("Sending state diff", "number", blockNumber)
|
||||||
|
|
||||||
currentBlock := sds.BlockChain.GetBlockByNumber(blockNumber)
|
currentBlock := sds.BlockChain.GetBlockByNumber(blockNumber)
|
||||||
parentRoot := common.Hash{}
|
parentRoot := common.Hash{}
|
||||||
@ -404,7 +405,7 @@ func (sds *Service) StateDiffAt(blockNumber uint64, params Params) (*Payload, er
|
|||||||
// This operation cannot be performed back past the point of db pruning; it requires an archival
|
// This operation cannot be performed back past the point of db pruning; it requires an archival
|
||||||
// node for historical data
|
// node for historical data
|
||||||
func (sds *Service) StateDiffFor(blockHash common.Hash, params Params) (*Payload, error) {
|
func (sds *Service) StateDiffFor(blockHash common.Hash, params Params) (*Payload, error) {
|
||||||
log.Info("sending state diff", "hash", blockHash)
|
log.Info("Sending state diff", "hash", blockHash)
|
||||||
|
|
||||||
currentBlock := sds.BlockChain.GetBlockByHash(blockHash)
|
currentBlock := sds.BlockChain.GetBlockByHash(blockHash)
|
||||||
parentRoot := common.Hash{}
|
parentRoot := common.Hash{}
|
||||||
@ -445,7 +446,7 @@ func (sds *Service) processStateDiff(currentBlock *types.Block, parentRoot commo
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Debug("statediff RLP payload for block",
|
log.Debug("statediff RLP payload for block",
|
||||||
"number", currentBlock.Number().Uint64(), "byte size", len(stateDiffRlp))
|
"number", currentBlock.Number(), "byte size", len(stateDiffRlp))
|
||||||
return sds.newPayload(stateDiffRlp, currentBlock, params)
|
return sds.newPayload(stateDiffRlp, currentBlock, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,7 +739,7 @@ func (sds *Service) writeStateDiffWithRetry(block *types.Block, parentRoot commo
|
|||||||
if err != nil && strings.Contains(err.Error(), pgDeadlockDetected) {
|
if err != nil && strings.Contains(err.Error(), pgDeadlockDetected) {
|
||||||
// Retry only when the deadlock is detected.
|
// Retry only when the deadlock is detected.
|
||||||
if i+1 < sds.maxRetry {
|
if i+1 < sds.maxRetry {
|
||||||
log.Warn("dead lock detected while writing statediff", "error", err, "retry number", i)
|
log.Warn("deadlock detected while writing statediff", "error", err, "retry number", i)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user