fix: properly release pipeline stages (#783)

This commit is contained in:
Ömer Faruk Irmak 2024-05-29 23:46:03 +03:00 committed by GitHub
parent 34162effbc
commit e6cc960f2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 3 deletions

View file

@ -401,7 +401,7 @@ func (w *worker) collectPendingL1Messages(startIndex uint64) []types.L1MessageTx
func (w *worker) startNewPipeline(timestamp int64) { func (w *worker) startNewPipeline(timestamp int64) {
if w.currentPipeline != nil { if w.currentPipeline != nil {
w.currentPipeline.Kill() w.currentPipeline.Release()
w.currentPipeline = nil w.currentPipeline = nil
} }
@ -586,6 +586,7 @@ func (w *worker) handlePipelineResult(res *pipeline.Result) error {
if res != nil && res.FinalBlock != nil { if res != nil && res.FinalBlock != nil {
w.updateSnapshot(res.FinalBlock) w.updateSnapshot(res.FinalBlock)
} }
w.currentPipeline.Release()
w.currentPipeline = nil w.currentPipeline = nil
return nil return nil
} }
@ -750,6 +751,7 @@ func (w *worker) commit(res *pipeline.Result) error {
// Broadcast the block and announce chain insertion event // Broadcast the block and announce chain insertion event
w.mux.Post(core.NewMinedBlockEvent{Block: block}) w.mux.Post(core.NewMinedBlockEvent{Block: block})
w.currentPipeline.Release()
w.currentPipeline = nil w.currentPipeline = nil
return nil return nil
} }

View file

@ -24,7 +24,7 @@ import (
const ( const (
VersionMajor = 5 // Major version component of the current release VersionMajor = 5 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release VersionMinor = 3 // Minor version component of the current release
VersionPatch = 27 // Patch version component of the current release VersionPatch = 28 // Patch version component of the current release
VersionMeta = "mainnet" // Version metadata to append to the version string VersionMeta = "mainnet" // Version metadata to append to the version string
) )

View file

@ -165,9 +165,11 @@ func (p *Pipeline) TryPushTxn(tx *types.Transaction) (*Result, error) {
} }
} }
func (p *Pipeline) Kill() { // Release releases all resources related to the pipeline
func (p *Pipeline) Release() {
if p.txnQueue != nil { if p.txnQueue != nil {
close(p.txnQueue) close(p.txnQueue)
p.txnQueue = nil
} }
select { select {