Description
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Couchbase;
using Couchbase.Core;
namespace CouchTest2
{
class Program
{
static void Main(string[] args)
{
var s = new Stopwatch();
s.Start();
var result = Parallel.For(0, 10000, ctr =>
);
s.Stop();
Console.WriteLine(s.Elapsed);
Console.Read();
}
}
[Serializable]
public sealed class CouchbaseClient
{
public static readonly CouchbaseClient Instance = new CouchbaseClient();
public IBucket Bucket;
private CouchbaseClient()
{ Bucket = new Cluster("couchbaseClients/couchbase").OpenBucket("default"); } }
}
The parallel loop does run randomly 20-30 times before the exception.
The error:
Unhandled Exception: System.AggregateException: One or more errors occurred. —
System.AggregateException: One or more errors occurred. ---> System.AggregateE xception: One or more errors occurred. ---> System.ArgumentOutOfRangeException: Index and count must refer to a location within the buffer. Parameter name: bytes at System.Text.UTF8Encoding.GetString(Byte[] bytes, Int32 index, Int32 count)
at Couchbase.IO.Converters.AutoByteConverter.ToString(Byte[] buffer, Int32 of fset, Int32 length) in c:\jenkins\workspace-net2\couchbase-net-client\Src\Couchb ase\IO\Converters\AutoByteConverter.cs:line 83 at Couchbase.IO.Operations.Observe.GetValue() in c:\jenkins\workspace-net2\co uchbase-net-client\Src\Couchbase\IO\Operations\Observe.cs:line 49
at Couchbase.IO.Operations.OperationBase1.GetResult() in
c:\jenkins\workspac
e-net2\couchbase-net-client\Src\Couchbase\IO\Operations\OperationBase'.cs:line
2 84 at Couchbase.Core.Server.Send[T](IOperation1 operation) in c:\jenkins\worksp ace-net2\couchbase-net-client\Src\Couchbase\Core\Server.cs:line 97
at Couchbase.Core.Buckets.KeyObserver.<>c_DisplayClass12.b_10 () in c:\jenkins\workspace-net2\couchbase-net-client\Src\Couchbase\Core\Buckets\ KeyObserver.cs:line 204 at System.Threading.Tasks.Task1.InnerInvoke() at
System.Threading.Tasks.Task.Execute()
— End of stack trace from previous location where exception was thrown — at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task) at
Couchbase.Core.Buckets.KeyObserver.<CheckReplica>d__14.MoveNext() in
c:\je
nkins\workspace-net2\couchbase-net-client\Src\Couchbase\Core\Buckets\KeyObserver
.cs:line 0 — End of inner exception stack trace — at
System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32
millisecondsTimeou t, CancellationToken cancellationToken) at
Couchbase.Core.Buckets.KeyObserver.<>c_DisplayClass6.<Observe>b_1(Observ
eParams p) in
c:\jenkins\workspace-net2\couchbase-net-client\Src\Couchbase\Core\
Buckets\KeyObserver.cs:line 162 at
Couchbase.Core.Buckets.KeyObserver.<ObserveEvery>d__18.MoveNext() in
c:\je
nkins\workspace-net2\couchbase-net-client\Src\Couchbase\Core\Buckets\KeyObserver
.cs:line 233 — End of inner exception stack trace — at
System.Threading.Tasks.Task.ThrowIfExceptional(Boolean
includeTaskCanceled Exceptions) at
System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout,
CancellationTo ken cancellationToken) at
Couchbase.Core.Buckets.KeyObserver.Observe(String key, UInt64 cas,
Boolean deletion, ReplicateTo replicateTo, PersistTo persistTo) in
c:\jenkins\workspace
-net2\couchbase-net-client\Src\Couchbase\Core\Buckets\KeyObserver.cs:line
169 at Couchbase.CouchbaseBucket.Observe(String key, UInt64 cas,
Boolean deletion , ReplicateTo replicateTo, PersistTo persistTo) in
c:\jenkins\workspace-net2\cou
chbase-net-client\Src\Couchbase\CouchbaseBucket.cs:line 281 at
Couchbase.CouchbaseBucket.SendWithDurability[T](IOperation1 operation, Bo olean deletion, ReplicateTo replicateTo, PersistTo persistTo) in c:\jenkins\work space-net2\couchbase-net-client\Src\Couchbase\CouchbaseBucket.cs:line 299 at Couchbase.CouchbaseBucket.Insert[T](String key, T value, ReplicateTo repli cateTo, PersistTo persistTo) in c:\jenkins\workspace-net2\couchbase-net-client\S rc\Couchbase\CouchbaseBucket.cs:line 832 at CouchTest2.Program.b_0(Int32 ctr) at System.Threading.Tasks.Parallel.<>cDisplayClassf1.<ForWorker>b_c()
at System.Threading.Tasks.Task.InnerInvoke() at
System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask) at
System.Threading.Tasks.Task.<>c_DisplayClass11.<ExecuteSelfReplicating>b
_10(Object param0) — End of inner exception stack trace — at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean
includeTaskCanceled Exceptions) at
System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout,
CancellationTo ken cancellationToken) at
System.Threading.Tasks.Task.Wait() at
System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive,
Int 32 toExclusive, ParallelOptions parallelOptions, Action1 body, Action2 bodyWit hState, Func4 bodyWithLocal, Func1 localInit,
Action1 localFinally) at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive , Action`1 body) at CouchTest2.Program.Main(String[] args)