I am inserting a lot of data into a RavenDB database; about 2500000 records. That needs to be completed in less time as possible.
I use a list to hold Task object returned by SaveChangesAsync:
session.Store(loc);
splitter++;
if (splitter % 2048 == 0)
{
var t = session.SaveChangesAsync();
tasks.Add(t);
if (tasks.Count == 2)
{
Task.WaitAll(tasks.ToArray());
tasks.Clear();
}
}
This code is running on machine with an i7 (8 core) and 12 GB ram. It works if the number of Task objects I hold is 2 (as you see in the code) but if I increase this number to 8 (number of cores) I receive a System.IndexOutOfRangeException (and sometimes an System.AggregateException which says: “Raven.Abstractions.Exceptions.ConcurrencyException: PUT attempted on document ‘X/I’ using a non current etag”).
What is the problem here?
Thanks
You can have only a single async pending operation per sessions.