I'm trying to import large amout of data to a Voron database.
Server Build #30115
Client Build #30115
Enabled bundles: Periodic Export, Replication
Incremental Backup option enabled
There are no indexes except the default Raven/DocumentsByEntityName index.
I create 3 entities for each data entry, two types of entities are about 2 kB in size, the third entity is up to 1 kB in size. Most of the documents already exist in the database, as the import sometimes fails (some documents are changed, some not).
The file scratch.0000000000.buffers grows during the import, but not steadily. After it hits the size limit, the import fails (this last occurred after processing around 530k data entries, 1590k documents):
System.AggregateException: Error when executing write ---> Voron.Exceptions.ScratchBufferSizeLimitException: Cannot allocate more space for the scratch buffer.
Current file size is: 3,136 KB.
Requested size for current file: 2,496 KB.
Requested total size for all files: 6,291,460 KB.
Limit: 6,291,456 KB.
Already flushed and waited for 5,002 ms for read transactions to complete.
Do you have a long running read transaction executing?
Debug info:
Current transaction id: 191182
Requested number of pages: 1 (adjusted size: 1 == 4 KB)
Oldest active transaction: 191181 (snapshot: 191181)
Oldest active transaction when flush was forced: -1
Next write transaction id: 191183
Active transactions:
Id: 191182 - ReadWrite
Id: 191181 - Read
Scratch files usage:
scratch.0000000000.buffers - size: 6,291,520 KB, in active use: 6,288,964 KB
scratch.0000000001.buffers - size: 3,136 KB, in active use: 2,492 KB
Most available free pages:
scratch.0000000000.buffers
Size:1, ValidAfterTransactionId: -1
Size:2, ValidAfterTransactionId: 186151
scratch.0000000001.buffers
Compression buffer size: 24,640 KB
at Voron.Impl.Scratch.ScratchBufferPool.Allocate(Transaction tx, Int32 numberOfPages)
at Voron.Impl.Transaction.AllocatePage(Int32 numberOfPages, PageFlags flags, Nullable`1 pageNumber)
at Voron.Impl.Transaction.ModifyPage(Int64 num, Tree tree, Page page)
at Voron.Trees.Tree.DirectAdd(MemorySlice key, Int32 len, NodeFlags nodeType, Nullable`1 version)
at Voron.Trees.Tree.Add(Slice key, Stream value, Nullable`1 version)
at Voron.Impl.TransactionMergingWriter.HandleOperations(Transaction tx, List`1 writes, CancellationToken token)
at Voron.Impl.TransactionMergingWriter.HandleActualWrites(OutstandingWrite mine, CancellationToken token)
--- End of inner exception stack trace ---
at Voron.Impl.TransactionMergingWriter.Write(WriteBatch batch)
at Raven.Database.Storage.Voron.Impl.TableStorage.Write(WriteBatch writeBatch)
at Raven.Storage.Voron.TransactionalStorage.ExecuteBatch(Action`1 action)
at Raven.Storage.Voron.TransactionalStorage.Batch(Action`1 action)
at Raven.Database.DocumentDatabase.Batch(IList`1 commands, CancellationToken token)
at Raven.Database.Server.Controllers.DocumentsBatchController.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.TaskHelpersExtensions.d__3`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at System.Web.Http.Controllers.ExceptionFilterResult.d__0.MoveNext()
---> (Inner Exception #0) Voron.Exceptions.ScratchBufferSizeLimitException: Cannot allocate more space for the scratch buffer.
Current file size is: 3,136 KB.
Requested size for current file: 2,496 KB.
Requested total size for all files: 6,291,460 KB.
Limit: 6,291,456 KB.
Already flushed and waited for 5,002 ms for read transactions to complete.
Do you have a long running read transaction executing?
Debug info:
Current transaction id: 191182
Requested number of pages: 1 (adjusted size: 1 == 4 KB)
Oldest active transaction: 191181 (snapshot: 191181)
Oldest active transaction when flush was forced: -1
Next write transaction id: 191183
Active transactions:
Id: 191182 - ReadWrite
Id: 191181 - Read
Scratch files usage:
scratch.0000000000.buffers - size: 6,291,520 KB, in active use: 6,288,964 KB
scratch.0000000001.buffers - size: 3,136 KB, in active use: 2,492 KB
Most available free pages:
scratch.0000000000.buffers
Size:1, ValidAfterTransactionId: -1
Size:2, ValidAfterTransactionId: 186151
scratch.0000000001.buffers
Compression buffer size: 24,640 KB
at Voron.Impl.Scratch.ScratchBufferPool.Allocate(Transaction tx, Int32 numberOfPages)
at Voron.Impl.Transaction.AllocatePage(Int32 numberOfPages, PageFlags flags, Nullable`1 pageNumber)
at Voron.Impl.Transaction.ModifyPage(Int64 num, Tree tree, Page page)
at Voron.Trees.Tree.DirectAdd(MemorySlice key, Int32 len, NodeFlags nodeType, Nullable`1 version)
at Voron.Trees.Tree.Add(Slice key, Stream value, Nullable`1 version)
at Voron.Impl.TransactionMergingWriter.HandleOperations(Transaction tx, List`1 writes, CancellationToken token)
at Voron.Impl.TransactionMergingWriter.HandleActualWrites(OutstandingWrite mine, CancellationToken token)<---
at Raven.Client.Connection.Implementation.HttpJsonRequest.d__29.MoveNext() in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Connection\Implementation\HttpJsonRequest.cs:line 389
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Raven.Client.Connection.Implementation.HttpJsonRequest.<>c__DisplayClassf.<b__e>d__11.MoveNext() in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Connection\Implementation\HttpJsonRequest.cs:line 200
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Raven.Client.Connection.Implementation.HttpJsonRequest.d__16`1.MoveNext() in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Connection\Implementation\HttpJsonRequest.cs:line 241
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Raven.Client.Connection.Async.AsyncServerClient.<>c__DisplayClass1f8.<b__1f6>d__1fb.MoveNext() in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Connection\Async\AsyncServerClient.cs:line 1515
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Raven.Client.Connection.ReplicationInformerBase`1.d__29`1.MoveNext() in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Connection\ReplicationInformerBase.cs:line 439
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Raven.Client.Connection.ReplicationInformerBase`1.d__19`1.MoveNext() in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Connection\ReplicationInformerBase.cs:line 334
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Raven.Client.Connection.Async.AsyncServerClient.d__2b3`1.MoveNext() in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Connection\Async\AsyncServerClient.cs:line 0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Raven.Abstractions.Util.AsyncHelpers.<>c__DisplayClassb`1.<b__8>d__d.MoveNext() in c:\Builds\RavenDB-Stable-3.0\Raven.Abstractions\Util\AsyncHelpers.cs:line 75
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Raven.Abstractions.Util.AsyncHelpers.RunSync[T](Func`1 task) in c:\Builds\RavenDB-Stable-3.0\Raven.Abstractions\Util\AsyncHelpers.cs:line 90
at Raven.Client.Connection.ServerClient.Batch(IEnumerable`1 commandDatas) in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Connection\ServerClient.cs:line 318
at Raven.Client.Document.DocumentSession.SaveChanges() in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Document\DocumentSession.cs:line 728
at [my code]
The import processes around 15000 records/minute, so around 750 documents/s (15000*3/60) are stored.
The import is done in batches of 256 records (that's 768 documents), each batch saved in its own session.
What can I do to make the import run more reliably?
Thanks
Andrej