Resource with specified id or name already exists.
Closed this issue · 2 comments
Hi,
I am using CosmosDBSessionStateProviderAsync v1.1.0 and I am getting the following exception given below.
It does not generate always but It generates daily 4 to 5 time in a production system.
Exception:
Microsoft.Azure.Documents.BadRequestException: Message: {"Errors":["Encountered exception while executing function. Exception = Error: {\"Errors\":[\"Resource with specified id or name already exists.\"]}\r\nStack trace: Error: {\"Errors\":[\"Resource with specified id or name already exists.\"]}\n at Anonymous function (script.js:25:33)\n at Anonymous function (script.js:687:29)"]} ActivityId: c2829176-9f82-4a0e-9a16-a9e0edf8945a, Request URI: /apps/57f1228c-d8b9-4bf2-be41-e9da51d45f07/services/953d4d07-d8c0-44b6-bd8d-1b17bc9e4434/partitions/43321ed7-501e-463b-b725-4d89eec2d268/replicas/132623386751280989p/, RequestStats: RequestStartTime: 2021-06-17T09:45:00.5346518Z, RequestEndTime: 2021-06-17T09:45:01.0417537Z, Number of regions attempted: 1 ResponseTime: 2021-06-17T09:45:01.0417537Z, StoreResult: StorePhysicalAddress: rntbd://cdb-ms-prod-northeurope1-fd43.documents.azure.com:14077/apps/57f1228c-d8b9-4bf2-be41-e9da51d45f07/services/953d4d07-d8c0-44b6-bd8d-1b17bc9e4434/partitions/43321ed7-501e-463b-b725-4d89eec2d268/replicas/132623386751280989p/, LSN: 686114, GlobalCommittedLsn: 686114, PartitionKeyRangeId: 0, IsValid: True, StatusCode: 400, SubStatusCode: 409, RequestCharge: 2.63, ItemLSN: -1, SessionToken: 3#686114, UsingLocalLSN: False, TransportException: null, ResourceType: StoredProcedure, OperationType: ExecuteJavaScript , SDK: documentdb-dotnet-sdk/2.4.1 Host/64-bit MicrosoftWindowsNT/10.0.19043.0 at Microsoft.Azure.Documents.TransportClient.ThrowServerException(String resourceAddress, StoreResponse storeResponse, Uri physicalAddress, Guid activityId, DocumentServiceRequest request) IL_04EE at Microsoft.Azure.Documents.Rntbd.TransportClient.<InvokeStoreAsync>d__8.MoveNext() IL_03E9 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) IL_0028 at Microsoft.Azure.Documents.ConsistencyWriter.<WritePrivateAsync>d__17.MoveNext() IL_0000 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) IL_0028 at Microsoft.Azure.Documents.ConsistencyWriter.<WriteAsync>d__16.MoveNext() IL_00A1 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) IL_0028 at Microsoft.Azure.Documents.ReplicatedResourceClient.<>c__DisplayClass24_0.<<InvokeAsync>b__0>d.MoveNext() IL_0181 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at Microsoft.Azure.Documents.RequestRetryUtility.<ProcessRequestAsync>d__2
2.MoveNext() IL_0000
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C
at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException) IL_0011
at Microsoft.Azure.Documents.RequestRetryUtility.d__22.MoveNext() IL_01EE --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) IL_0028 at Microsoft.Azure.Documents.StoreClient.<ProcessMessageAsync>d__19.MoveNext() IL_029D --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) IL_0028 at Microsoft.Azure.Documents.ServerStoreModel.<ProcessMessageAsync>d__15.MoveNext() IL_0165 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) IL_0028 at Microsoft.Azure.Documents.Client.DocumentClient.<ProcessRequestAsync>d__144.MoveNext() IL_0110 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) IL_0028 at Microsoft.Azure.Documents.Client.DocumentClient.<ExecuteStoredProcedurePrivateAsync>d__278
1.MoveNext() IL_0285
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C
at Microsoft.Azure.Documents.BackoffRetryUtility1.<ExecuteRetryAsync>d__5.MoveNext() IL_0000 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException) IL_0011 at Microsoft.Azure.Documents.BackoffRetryUtility
1.d__5.MoveNext() IL_0149
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) IL_0028
at Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.d__961.MoveNext() IL_00A0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) IL_0028 at Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.<CreateSessionStateItemAsync>d__97.MoveNext() IL_00DF --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) IL_0028 at Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.<CreateUninitializedItemAsync>d__68.MoveNext() IL_00C4 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at Microsoft.AspNet.SessionState.SessionStateModuleAsync.<GetSessionStateItemAsync>d__74.MoveNext() IL_02DE --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) IL_0028 at Microsoft.AspNet.SessionState.SessionStateModuleAsync.<AcquireStateAsync>d__65.MoveNext() IL_0241 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() IL_000C at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) IL_0028 at Microsoft.AspNet.SessionState.TaskAsyncHelper.EndTask(IAsyncResult ar) IL_0034 at System.Web.HttpApplication.AsyncEventExecutionStep.InvokeEndHandler(IAsyncResult ar) IL_0081 at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) IL_0022
Workaround by modifying the stored procedures - use upsertDocument
instead of createDocument
. This does not solve the question why it happened in the first place, but at least avoids exceptions.
Fixed by #81