dgarage / NBXplorer

NBitcoin Explorer
MIT License
320 stars 213 forks source link

Error while saving block in database: minimumBufferSize was out of the range of valid values #303

Closed farukterzioglu closed 2 years ago

farukterzioglu commented 3 years ago

Getting this exception lots of time recently NBXplorer running with lates commit.

warn: Explorer:       BTC: Error while saving block in database, retrying in 1 seconds (Specified argument was out of the range of valid values. (Parameter 'minimumBu
fferSize'))
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'minimumBufferSize')
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument)
   at System.Buffers.ArrayMemoryPool`1.Rent(Int32 minimumBufferSize)
   at DBTrie.TrieModel.LTrie.FetchNodeFromStruct(LTrieNodeStruct nodeStruct, Int32 minKeyLength)
   at DBTrie.TrieModel.LTrie.ToLTrieNodeObject(LTrieNodeStruct nodeStruct, Int32 minKeyLength)
   at DBTrie.TrieModel.LTrie.CreateMatchResult(Int32 minKeyLength, Link valueLink, LTrieNodeStruct gn, LTrieNodeStruct prev)
   at DBTrie.TrieModel.LTrie.FindBestMatch(ReadOnlyMemory`1 key)
   at DBTrie.TrieModel.LTrie.SetValue(ReadOnlyMemory`1 key, ReadOnlyMemory`1 value, Boolean replace)
   at DBTrie.TrieModel.LTrie.SetValue(String key, ReadOnlyMemory`1 value, Boolean replace)
   at DBTrie.Table.Insert(String key, ReadOnlyMemory`1 value, Boolean replace)
   at NBXplorer.Repository.Index.Insert(String key, Byte[] value, Boolean replace) in /NBXplorer/NBXplorer/Repository.cs:line 355
   at NBXplorer.Repository.Index.Insert(Int64 key, Byte[] value) in /NBXplorer/NBXplorer/Repository.cs:line 350
   at NBXplorer.Repository.SaveEvent(NewEventBase evt) in /NBXplorer/NBXplorer/Repository.cs:line 558
   at NBXplorer.ExplorerBehavior.SaveMatches(TrackedTransaction[] matches, uint256 blockHash, DateTimeOffset now, Boolean fireEvents) in /NBXplorer/NBXplorer/Explorer
Behavior.cs:line 387
   at NBXplorer.ExplorerBehavior.SaveMatches(Block block) in /NBXplorer/NBXplorer/ExplorerBehavior.cs:line 296
farukterzioglu commented 2 years ago

When I ran from master with --dbtrie I am still getting an error as below;

warn: Explorer:       BTC: Error while saving block in database, retrying in 60 seconds (Specified argument was out of the range of valid values. (Parameter 'minimumBufferSize'))
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'minimumBufferSize')
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument)
   at System.Buffers.ArrayMemoryPool`1.Rent(Int32 minimumBufferSize)
   at DBTrie.TrieModel.LTrie.FetchNodeFromStruct(LTrieNodeStruct nodeStruct, Int32 minKeyLength)
   at DBTrie.TrieModel.LTrie.ToLTrieNodeObject(LTrieNodeStruct nodeStruct, Int32 minKeyLength)
   at DBTrie.TrieModel.LTrie.CreateMatchResult(Int32 minKeyLength, Link valueLink, LTrieNodeStruct gn, LTrieNodeStruct prev)
   at DBTrie.TrieModel.LTrie.FindBestMatch(ReadOnlyMemory`1 key)
   at DBTrie.TrieModel.LTrie.SetValue(ReadOnlyMemory`1 key, ReadOnlyMemory`1 value, Boolean replace)
   at DBTrie.TrieModel.LTrie.SetValue(String key, ReadOnlyMemory`1 value, Boolean replace)
   at DBTrie.Table.Insert(String key, ReadOnlyMemory`1 value, Boolean replace)
   at NBXplorer.Backends.DBTrie.Repository.Index.Insert(String key, Byte[] value, Boolean replace) in /NBXplorer/NBXplorer/Backends/DBTrie/Repository.cs:line 434
   at NBXplorer.Backends.DBTrie.Repository.Index.Insert(Int64 key, Byte[] value) in /NBXplorer/NBXplorer/Backends/DBTrie/Repository.cs:line 430
   at NBXplorer.Backends.DBTrie.Repository.SaveEvent(NewEventBase evt) in /NBXplorer/NBXplorer/Backends/DBTrie/Repository.cs:line 698
   at NBXplorer.Backends.DBTrie.ExplorerBehavior.SaveMatches(TrackedTransaction[] matches, SlimChainedBlock slimBlock, DateTimeOffset now, Boolean fireEvents) in /NBXplorer/NBXplorer/Backends/DBTrie/ExplorerBehavior.cs:line 258
   at NBXplorer.Backends.DBTrie.ExplorerBehavior.SaveMatches(Block block) in /NBXplorer/NBXplorer/Backends/DBTrie/ExplorerBehavior.cs:line 187

I need to to comment out lines; https://github.com/dgarage/NBXplorer/blob/7d44d4cb740d3d3d112c416d7e2e2bc1728c7ebd/NBXplorer/Backends/DBTrie/Repository.cs#L695

I will also check this with Postgres.