Skip to content

Commit e1c0831

Browse files
committed
fix deadlock
1 parent 2e821f5 commit e1c0831

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

engine/access/access_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ func (suite *Suite) TestGetSealedTransaction() {
738738
require.NoError(suite.T(), bdb.WithReaderBatchWriter(func(rw storage.ReaderBatchWriter) error {
739739
return all.Blocks.BatchStore(lctx, rw, block)
740740
}))
741+
lctx.Release()
741742
require.NoError(suite.T(), err)
742743

743744
fctx := manager.NewContext()
@@ -815,16 +816,17 @@ func (suite *Suite) TestGetTransactionResult() {
815816

816817
bdb := badgerimpl.ToDB(db)
817818
manager, lctx := unittest.LockManagerWithContext(suite.T(), storage.LockInsertBlock)
818-
defer lctx.Release()
819819
require.NoError(suite.T(), bdb.WithReaderBatchWriter(func(rw storage.ReaderBatchWriter) error {
820820
return all.Blocks.BatchStore(lctx, rw, block)
821821
}))
822+
lctx.Release()
823+
822824
lctx2 := manager.NewContext()
823-
defer lctx2.Release()
824825
require.NoError(suite.T(), lctx2.AcquireLock(storage.LockInsertBlock))
825826
require.NoError(suite.T(), bdb.WithReaderBatchWriter(func(rw storage.ReaderBatchWriter) error {
826827
return all.Blocks.BatchStore(lctx2, rw, blockNegative)
827828
}))
829+
lctx2.Release()
828830

829831
suite.state.On("AtBlockID", blockId).Return(suite.sealedSnapshot)
830832

@@ -971,10 +973,11 @@ func (suite *Suite) TestGetTransactionResult() {
971973
}
972974
}
973975
fctx2 := manager.NewContext()
974-
defer fctx2.Release()
976+
require.NoError(suite.T(), fctx2.AcquireLock(storage.LockFinalizeBlock))
975977
require.NoError(suite.T(), bdb.WithReaderBatchWriter(func(rw storage.ReaderBatchWriter) error {
976978
return operation.IndexBlockHeight(fctx2, rw, block.Header.Height, block.ID())
977979
}))
980+
fctx2.Release()
978981
finalSnapshot.On("Head").Return(block.Header, nil)
979982

980983
processExecutionReceipts(block, collection, enNodeIDs, originID, ingestEng)

0 commit comments

Comments
 (0)