stratisproject / StratisBitcoinFullNode

Bitcoin full node in C#
https://stratisplatform.com
MIT License
787 stars 314 forks source link

[Blockstore] Access to disposed object app crash on shutdown #404

Closed Aprogiena closed 7 years ago

Aprogiena commented 7 years ago
crit: Stratis.Bitcoin.Features.Consensus.ConsensusFeature[0]
      Consensus loop unhandled exception (Tip:97424)
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Microsoft.Extensions.Caching.Memory.MemoryCache'.
   at Microsoft.Extensions.Caching.Memory.MemoryCache.CheckDisposed()
   at Microsoft.Extensions.Caching.Memory.MemoryCache.TryGetValue(Object key, Object& result)
   at Microsoft.Extensions.Caching.Memory.CacheExtensions.TryGetValue[TItem](IMemoryCache cache, Object key, TItem& value)
   at Stratis.Bitcoin.Features.BlockStore.BlockStoreCache.<GetBlockAsync>d__10.MoveNext() in C:\StratisBitcoinFullNode\Stratis.Bitcoin\Features\BlockStore\BlockStoreCache.cs:line 71
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Stratis.Bitcoin.Features.Wallet.WalletSyncManager.ProcessBlock(Block block) in C:\StratisBitcoinFullNode\Stratis.Bitcoin.Features.Wallet\WalletSyncManager.cs:line 111
   at Stratis.Bitcoin.Features.Wallet.Notifications.BlockObserver.OnNextCore(Block block) in C:\StratisBitcoinFullNode\Stratis.Bitcoin.Features.Wallet\Notifications\BlockObserver.cs:line 24
   at System.Reactive.SafeObserver`1.OnNext(TSource value)
   at System.Reactive.Observer`1.OnNext(T value)
   at System.Reactive.SynchronizedObserver`1.OnNextCore(T value)
   at Stratis.Bitcoin.Signals.Signaler`1.Broadcast(T item) in C:\StratisBitcoinFullNode\Stratis.Bitcoin\Signals\Signaler.cs:line 70
   at Stratis.Bitcoin.Signals.Signals.SignalBlock(Block block) in C:\StratisBitcoinFullNode\Stratis.Bitcoin\Signals\Signals.cs:line 74
   at Stratis.Bitcoin.Features.Consensus.ConsensusFeature.RunLoop() in C:\StratisBitcoinFullNode\Stratis.Bitcoin\Features\Consensus\ConsensusFeature.cs:line 165
info: Stratis.Bitcoin.Base.BaseFeature[0]
      Flushing address manager

Unhandled Exception: info: Stratis.Bitcoin.Base.BaseFeature[0]
      Flushing headers chain
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Microsoft.Extensions.Caching.Memory.MemoryCache'.
   at Microsoft.Extensions.Caching.Memory.MemoryCache.CheckDisposed()
   at Microsoft.Extensions.Caching.Memory.MemoryCache.TryGetValue(Object key, Object& result)
   at Microsoft.Extensions.Caching.Memory.CacheExtensions.TryGetValue[TItem](IMemoryCache cache, Object key, TItem& value)
   at Stratis.Bitcoin.Features.BlockStore.BlockStoreCache.<GetBlockAsync>d__10.MoveNext() in C:\StratisBitcoinFullNode\Stratis.Bitcoin\Features\BlockStore\BlockStoreCache.cs:line 71
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Stratis.Bitcoin.Features.Wallet.WalletSyncManager.ProcessBlock(Block block) in C:\StratisBitcoinFullNode\Stratis.Bitcoin.Features.Wallet\WalletSyncManager.cs:line 111
   at Stratis.Bitcoin.Features.Wallet.Notifications.BlockObserver.OnNextCore(Block block) in C:\StratisBitcoinFullNode\Stratis.Bitcoin.Features.Wallet\Notifications\BlockObserver.cs:line 24
   at System.Reactive.SafeObserver`1.OnNext(TSource value)
   at System.Reactive.Observer`1.OnNext(T value)
   at System.Reactive.SynchronizedObserver`1.OnNextCore(T value)
   at Stratis.Bitcoin.Signals.Signaler`1.Broadcast(T item) in C:\StratisBitcoinFullNode\Stratis.Bitcoin\Signals\Signaler.cs:line 70
   at Stratis.Bitcoin.Signals.Signals.SignalBlock(Block block) in C:\StratisBitcoinFullNode\Stratis.Bitcoin\Signals\Signals.cs:line 74
   at Stratis.Bitcoin.Features.Consensus.ConsensusFeature.RunLoop() in C:\StratisBitcoinFullNode\Stratis.Bitcoin\Features\Consensus\ConsensusFeature.cs:line 186
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
Aprogiena commented 7 years ago

BlockStoreCache.cs GetBlockAsync method:

if (this.cache.TryGetValue(blockid, out block))

cache has been disposed here

Aprogiena commented 7 years ago

some logs preceding the crash:

[2017-09-03 13:35:57.6154 1] TRACE: Stratis.Bitcoin.Features.BlockStore.BlockStoreFeature.Stop ()
[2017-09-03 13:35:57.6154 1] INFO: Stratis.Bitcoin.Features.BlockStore.BlockStoreFeature.Stop Flushing BlockStore...
[2017-09-03 13:35:57.6154 19] TRACE: Stratis.Bitcoin.Features.BlockStore.BlockStoreCache.GetBlockAsync (blockid:'7889249c8064adfe53adee522bbf7b4702abd13fe1df5075b54decc36ba5b7ef')
[2017-09-03 13:35:57.6154 19] TRACE: Stratis.Bitcoin.Features.BlockStore.BlockRepository.GetAsync (hash:'7889249c8064adfe53adee522bbf7b4702abd13fe1df5075b54decc36ba5b7ef')
[2017-09-03 13:35:57.6154 19] TRACE: Stratis.Bitcoin.Features.BlockStore.BlockRepository.GetAsync (-)
[2017-09-03 13:35:57.6154 15] TRACE: Stratis.Bitcoin.Features.BlockStore.BlockRepository+<>c__DisplayClass36_0.<GetAsync>b__0 ()
[2017-09-03 13:35:57.6154 15] TRACE: Stratis.Bitcoin.Features.BlockStore.BlockRepository+<>c__DisplayClass36_0.<GetAsync>b__0 (-):NBitcoin.Block
[2017-09-03 13:35:57.6154 9] TRACE: Stratis.Bitcoin.Features.BlockStore.BlockStoreCache+<GetBlockAsync>d__10.MoveNext (-)[CACHE_MISS]:'NBitcoin.Block'
[2017-09-03 13:35:57.6154 19] TRACE: Stratis.Bitcoin.Features.Wallet.WalletManager.ProcessBlock block notification - height: 14147, hash: 7889249c8064adfe53adee522bbf7b4702abd13fe1df5075b54decc36ba5b7ef, coin: Stratis
[2017-09-03 13:35:57.6154 19] TRACE: Stratis.Bitcoin.Features.Wallet.WalletManager.ProcessTransaction transaction received - hash: 7ea780a76f7936671ad27f9418445a5615eca508093a6c8da4346e555eb42323, coin: Stratis
[2017-09-03 13:35:57.6154 1] TRACE: Stratis.Bitcoin.Features.BlockStore.BlockStoreLoop.DownloadAndStoreBlocks (disposeMode:True)
[2017-09-03 13:35:57.6154 19] TRACE: Stratis.Bitcoin.Features.Wallet.WalletManager.ProcessTransaction transaction received - hash: 21a85fe20089f79311f081b3b45b5c8fbc749c1089021f01d309f43562223021, coin: Stratis
[2017-09-03 13:35:57.6154 1] TRACE: Stratis.Bitcoin.Features.BlockStore.BlockStoreLoop.DownloadAndStoreBlocks (-)
[2017-09-03 13:35:57.6154 19] TRACE: Stratis.Bitcoin.Features.BlockStore.BlockStoreCache.GetBlockAsync (blockid:'1922647433b7b20bec333a0db324e0201d0a668881574b97f0197490f24c92e1')
[2017-09-03 13:35:57.6310 1] TRACE: Stratis.Bitcoin.Features.BlockStore.BlockStoreFeature.Stop (-)
[2017-09-03 13:35:57.6310 1] INFO: Stratis.Bitcoin.Features.Consensus.ConsensusFeature.Stop Flushing Cache CoinView...
[2017-09-03 13:35:57.6310 1] TRACE: Stratis.Bitcoin.Features.Consensus.CoinViews.CachedCoinView.FlushAsync ()
[2017-09-03 13:35:57.6310 1] TRACE: Stratis.Bitcoin.Features.Consensus.StakeChainStore.Flush (disposeMode:True)
[2017-09-03 13:35:57.6467 14] TRACE: Stratis.Bitcoin.Features.Consensus.CoinViews.DBreezeCoinView+<>c__DisplayClass18_0.<PutStake>b__0 (stakeEntries.Count():1)
[2017-09-03 13:35:57.7248 14] TRACE: Stratis.Bitcoin.Features.Consensus.CoinViews.DBreezeCoinView+<>c__DisplayClass18_0.<PutStake>b__0 (-)
[2017-09-03 13:35:57.7248 14] TRACE: Stratis.Bitcoin.Features.Consensus.CoinViews.DBreezeCoinView+<>c__DisplayClass15_0.<SaveChangesAsync>b__0 (unspentOutputs.Count():3,originalOutputs.Count():3,oldBlockHash:'ee6c473b8f444f917708aed192ee517fb5b1f2e3090f983c81aee129a866d29d',nextBlockHash:'9e8c1675aa0256e171edb8a13d41d422662a93d631c5f3db7eb98bc5aa185a6f')
[2017-09-03 13:35:57.7248 14] TRACE: Stratis.Bitcoin.Features.Consensus.CoinViews.DBreezeCoinView.SetBlockHash (nextBlockHash:'9e8c1675aa0256e171edb8a13d41d422662a93d631c5f3db7eb98bc5aa185a6f')
[2017-09-03 13:35:57.7248 14] TRACE: Stratis.Bitcoin.Features.Consensus.CoinViews.DBreezeCoinView.SetBlockHash (-)
[2017-09-03 13:35:57.7248 14] TRACE: Stratis.Bitcoin.Features.Consensus.CoinViews.DBreezeCoinView+<>c__DisplayClass15_0.<SaveChangesAsync>b__0 Outputs of transaction ID '11359caa924d8a71993286d7601d32c513974862d0208416f83f27ea48dcdbc0' are NOT PRUNABLE and will be inserted to the database.
[2017-09-03 13:35:57.7248 14] TRACE: Stratis.Bitcoin.Features.Consensus.CoinViews.DBreezeCoinView+<>c__DisplayClass15_0.<SaveChangesAsync>b__0 Outputs of transaction ID '52cfa74deca6e93d51715be3a6c6714d4311aa6523f2eb6c27b7f4c5c0a5fe4e' are NOT PRUNABLE and will be inserted to the database.
[2017-09-03 13:35:57.7248 14] TRACE: Stratis.Bitcoin.Features.Consensus.CoinViews.DBreezeCoinView+<>c__DisplayClass15_0.<SaveChangesAsync>b__0 Outputs of transaction ID 'f3647764c8a17ffcdc54027dd01a8812b63a5766ca27ec3c5f1d3f7487c7bc95' are NOT PRUNABLE and will be inserted to the database.
[2017-09-03 13:35:57.7248 14] TRACE: Stratis.Bitcoin.Features.Consensus.CoinViews.DBreezeCoinView+<>c__DisplayClass15_0.<SaveChangesAsync>b__0 Rewind state #1436 created.
[2017-09-03 13:35:57.8029 19] DEBUG: Stratis.Bitcoin.Features.Consensus.ConsensusFeature.RunLoop Exception occurred in consensus loop: System.ObjectDisposedException: Cannot access a disposed object.
Aprogiena commented 7 years ago

seems to be reproducible when you delete the wallet file and then recover from breeze.ui, then the wallet starts syncing when you run the node, hit ctrl+c before it sync

bokobza commented 7 years ago

https://trello.com/c/tWAJXbz9/189-blockstore-access-to-disposed-object-app-crash-on-shutdown

fassadlr commented 7 years ago

[Blockstore] Access to disposed object app crash on shutdown

bokobza commented 7 years ago

closed with https://github.com/stratisproject/StratisBitcoinFullNode/pull/450