1
votes

Periodically we receive the following error when saving to a Raven Database. The client and database are v3.5. The solution thus far has been to restart the servers and after that things appear to settle down. The user can go to a different server and can go back into the site and retrieved what was saved. However when we see 1 error like this on a server the server starts to report 100's of them. We cannot reproduce this in QA. So I am leaning towards load or our Raven Sessions are not being closed properly.

Calling the Raven OpenSessionAsync() as the point of creating the class

IAsyncDocumentSession

public async Task<bool> SaveChangesAsync()
{
using (_session)
{
await _session.SaveChangesAsync();
}

return true;
}

This is the area in our code that starts the error when saving should we also be doing something more?

Message: Token PropertyName in state Property would result in an invalid JSON object. Path ''. Raven.Imports.Newtonsoft.Json.JsonWriter.AutoComplete(JsonToken tokenBeingWritten) in C:\Builds\RavenDB-Stable-3.5\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonWriter.cs:779 Raven.Json.Linq.RavenJTokenWriter.WritePropertyName(String name) in C:\Builds\RavenDB-Stable-3.5\Raven.Abstractions\Json\Linq\RavenJTokenWriter.cs:51 Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in C:\Builds\RavenDB-Stable-3.5\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalWriter.cs:428 Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) in C:\Builds\RavenDB-Stable-3.5\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalWriter.cs:101 Raven.Imports.Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType) in C:\Builds\RavenDB-Stable-3.5\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonSerializer.cs:949 Raven.Json.Linq.RavenJToken.FromObjectInternal(Object o, JsonSerializer jsonSerializer) in C:\Builds\RavenDB-Stable-3.5\Raven.Abstractions\Json\Linq\RavenJToken.cs:91 Raven.Json.Linq.RavenJObject.FromObject(Object o, JsonSerializer jsonSerializer) in C:\Builds\RavenDB-Stable-3.5\Raven.Abstractions\Json\Linq\RavenJObject.cs:174 Raven.Client.Document.EntityToJson.GetObjectAsJson(Object entity) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\EntityToJson.cs:72 Raven.Client.Document.EntityToJson.ConvertEntityToJson(String key, Object entity, RavenJObject metadata) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\EntityToJson.cs:44 Raven.Client.Document.InMemoryDocumentSessionOperations.EntityChanged(Object entity, DocumentMetadata documentMetadata, IDictionary2 changes) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:1218 Raven.Client.Document.InMemoryDocumentSessionOperations.<PrepareForEntitiesPuts>b__110_0(KeyValuePair2 pair) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:1025 System.Linq.Enumerable+WhereEnumerableIterator1.MoveNext():55 System.Linq.Buffer1..ctor(IEnumerable1 source):114 System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source):20

Raven.Client.Document.InMemoryDocumentSessionOperations.PrepareForEntitiesPuts(SaveChangesData result) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:1025 Raven.Client.Document.InMemoryDocumentSessionOperations.PrepareForSaveChanges() in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:986 Raven.Client.Document.Async.AsyncDocumentSession+d__73.MoveNext() in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\Async\AsyncDocumentSession.cs:928 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw():12 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task):46

ApplicantCenter.Services.ApplicationService+d__9.MoveNext() in d:\a\1\s\Project\Services\ApplicationService_Helpers.cs:207 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw():12 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task):46

ApplicantCenter.Controllers.ApplicationController+d__10.MoveNext() in d:\a\1\s\Project\Controllers\ApplicationController.cs:117 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw():12 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task):46 System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass8_0.b__1(IAsyncResult asyncResult) System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters.b__11_0():19 System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass11_1.b__2():134 System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass11_1.b__2():134 System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass11_1.b__2():134 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass3_6.b__3() System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass3_1.b__5(IAsyncResult asyncResult)

1

1 Answers

0
votes

The problem here is that you are disposing the session that maybe used by others. You put a global _session inside an using block, the _session resources will be disposed after the using block end, and other parts of code that are using the same global _session will become invalid.