We are developing a group chat application and using PostgreSQL to store chat messages.
CREATE TABLE public.chatmessage
(
chatmessageid uuid NOT NULL DEFAULT uuid_generate_v4(),
text character varying COLLATE pg_catalog."default",
planid uuid NOT NULL,
userid uuid NOT NULL,
createdat timestamp with time zone NOT NULL DEFAULT timezone('utc'::text, now()),
updatedat timestamp with time zone,
deleted boolean NOT NULL DEFAULT false,
viewedallstatus boolean,
vieweduserids uuid[],
alloweduserids uuid[],
CONSTRAINT chatmessage_pkey PRIMARY KEY (chatmessageid)
)
To manage read status, we are storing the userIds of viewed participants in vieweduserIds column.
While heavily using the group chat with 5 or more participants, we are getting the following exception,
Npgsql.PostgresException (0x80004005): 40P01: deadlock detected
at Npgsql.NpgsqlConnector.<DoReadMessage>d__157.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
at Npgsql.NpgsqlConnector.<ReadMessage>d__156.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Npgsql.NpgsqlConnector.<ReadMessage>d__156.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
at Npgsql.NpgsqlDataReader.<NextResult>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlDataReader.<<NextResultAsync>b__31_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlCommand.<Execute>d__71.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
at Npgsql.NpgsqlCommand.<ExecuteNonQuery>d__84.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlCommand.<>c__DisplayClass83_0.<<ExecuteNonQueryAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Dapper.SqlMapper.<ExecuteImplAsync>d__37.MoveNext() in C:\projects\dapper\Dapper\SqlMapper.Async.cs:line 646
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
I feel since the application simultaneously updates the same column this issue is coming. The query which updates vieweduserIds column is as follows,
"Update ChatMessage Set ViewedUserIds = ViewedUserIds || #UserId Where PlanId = #PlanId And #UserId = Any(AllowedUserIds) And Not (#UserId = Any(ViewedUserIds)) And Deleted = False;"
How can we resolve this issue?
A deadlock is no problem unless it happens frequently.
The correct solution is for the application not to panic, but simply to retry the database transaction.
If deadlocks happen too frequently, you need to investigate and remedy the cause. Usually that means to keep your transactions short and small and to always lock objects in a certain order.
If you need specific help, read the PostgreSQL log file to find out which queries are involved. You'll have to understand which locks conflict to determine the root cause.
Related
The command I'm executing:
var feature = await container.ReadItemAsync<CosmosNormalizedFeatureModel>(guid, new Microsoft.Azure.Cosmos.PartitionKey(partitionKey));
Throws an exception:
Response status code does not indicate success: Unauthorized (401); Substatus: 0; ActivityId: ; Reason: ();
I don't believe this is true, but I don't see anything wrong either.
when I use GetItemLinqQueryable I have no issues connecting to Cosmos
I've verified the partition key exists + set to correct property and returns data
I've verified the guid/id exists and returns data
I've verified the container is set to the correct container
Microsoft.Azure.Cosmos 3.20.1
Not sure what else I can check to troubleshoot the issue. Thanks!
Stack trace
at Microsoft.Azure.Cosmos.ResponseMessage.EnsureSuccessStatusCode()
at Microsoft.Azure.Cosmos.CosmosResponseFactoryCore.ProcessMessage[T](ResponseMessage responseMessage, Func`2 createResponse)
at Microsoft.Azure.Cosmos.CosmosResponseFactoryCore.CreateItemResponse[T](ResponseMessage responseMessage)
at Microsoft.Azure.Cosmos.ContainerCore.<ReadItemAsync>d__56`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Azure.Cosmos.ClientContextCore.<RunWithDiagnosticsHelperAsync>d__38`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.Azure.Cosmos.ClientContextCore.<OperationHelperWithRootTraceAsync>d__29`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at xxx.<GetFeatureByGuid>d__7.MoveNext() in D:\xxx.cs:line 183
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at xxx.<GetNormalizedILIReportFeatureByGuid>d__10.MoveNext() in D:\xxx.cs:line 280
Based on comments - you are using Bulk mode.
When using Bulk mode, operations are packed together to improve network performance (the operation type is not relevant, read operations can be packed with write operations) and sent as a single payload to the backend.
The payload is of a different type calling a different API (so the backend can unpack them and process them and return a packed response).
This API uses the Write keys (because inside the package there could be any type of operation). The fact that you are using the Read-only keys is what is causing the 401. Ideally the backend should be more explicit in the error it returns though.
The key being used to connect to cosmos is a read key, it appears that the point read requires a read/write key.
I am trying to upgrade the app version for one our SF solutions. But failed multiple times as one of the services is reporting an issue during start with the new version.
Here is what I see as 2 exceptions happening almost at the same time:
OnApply
Unexpected service exception. Type: System.TypeInitializationException Message: The type initializer for 'MyCompany.MyService.Interfaces.Models.MyUser' threw an exception. HResult: 0x80131534
Log record. Type: BeginTransaction LSN: 103498
at System.Fabric.Store.TStore`5.OnApplyAdd(TransactionBase txn, MetadataOperationData metadataOperationData, RedoUndoOperationData operationRedoUndo, Boolean isIdempotent, String applyType)
at System.Fabric.Store.TStore`5.<OnRecoveryApplyAsync>d__299.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Fabric.Store.TStore`5.<Microsoft-ServiceFabric-Replicator-IStateProvider2-ApplyAsync>d__237.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Replicator.DynamicStateManager.<OnApplyAsync>d__106.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Replicator.DynamicStateManager.<OnApplyAsync>d__105.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Replicator.OperationProcessor.<ApplyCallback>d__36.MoveNext().
And
Exception in OpenAsync. Type: System.TypeInitializationException Message: The type initializer for 'MyCompany.MyService.Interfaces.Models.MyUser' threw an exception. HResult: 0x80131534. Stack Trace: at Microsoft.ServiceFabric.Replicator.RecoveryManager.<PerformRecoveryAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Replicator.LoggingReplicator.<PerformRecoveryAsync>d__137.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Replicator.DynamicStateManager.<OpenAsync>d__109.MoveNext().
I would expect to see this kind of error in case any changes happened to the "MyUser" model, but it was not changed at all.
Not sure if it has to do with some kind of an issue with the SF version we are using: 5.7.198 as this is not the latest one.
Anyone faced something similar or have good ideas for a work around?
P.S. This is a production system with real customers. Being able to make upgrades and not loosing their data is a must. Hence re-creation of the SF/cluster is not an option.
I'm catching the following exception on my cluster, randomly when an actor calls another one via ActorProxy:
System.Fabric.FabricObjectClosedException: The object is closed. ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80071BFE
at System.Fabric.Interop.NativeRuntime.IFabricKeyValueStoreReplica6.CreateTransaction()
at System.Fabric.KeyValueStoreReplica.CreateTransactionHelper(KeyValueStoreTransactionSettings settings)
at System.Fabric.Interop.Utility.WrapNativeSyncInvoke[TResult](Func1 func, String functionTag, String functionArgs)
--- End of inner exception stack trace ---
at System.Fabric.Interop.Utility.WrapNativeSyncInvoke[TResult](Func1 func, String functionTag, String functionArgs)
at Microsoft.ServiceFabric.Actors.Runtime.KvsActorStateProvider.<>c__DisplayClass14.b__13()
at Microsoft.ServiceFabric.Actors.Runtime.ActorStateProviderHelper.d__61.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 Microsoft.ServiceFabric.Actors.Runtime.ActorStateManager.<ContainsStateAsync>d__17.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 PosteItaliane.Sin.StateManagement.ObservableState.SingleValueWrapper1.d__2.MoveNext() in C:\Users\maurosag\Source\Repos\Equitalia3\SIN\PI.Sin.StateManagement\ObservableState\SingleValueWrapper.cs:line 21
--- 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 PosteItaliane.Sin.Utility.ServiceFabric.StatefulActor`1.get_State() ....
Searching on the web, i cannot figure out how to resolve it; the only discussions concern with Powershell exec:
“This means that this replica got demoted from primary to secondary. The client will re-resolve and reconnect to the new primary if you let the exception bubble up. The existing processing will drain on the primary. I am resolving the issue as "By Design". Please feel free to reopen if you still have question.”
Anyone can help me?
Thanks in advance.
I am currently running into a error upon deploying to Azure.
I took the connection string directly from my web config file, which works when testing locally, and i modified it to fit my deployment to Azure, but then i get an error.
Below is the original connection string that works on my local machine:
<add name="DataEntities" connectionString="metadata=res://*/Models.FirearmModels.csdl|res://*/Models.FirearmModels.ssdl|res://*/Models.FirearmModels.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\Data.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Below is the modified connection string for Azure:
<add name="DataEntities" connectionString="metadata=res://*/Models.FirearmModels.csdl|res://*/Models.FirearmModels.ssdl|res://*/Models.FirearmModels.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:owm5115h08.database.windows.net,1433;Initial Catalog=diafirearmserver;User ID=userid;Password=userpass;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Could someone please tell me what i am doing wrong, what i am missing, in getting this to work?
Thanks in advance.
PS: Here's a screenshot of the error i get when i run it in Azure:
http://i693.photobucket.com/albums/vv293/saturobi360/EntityConnString_Error_zpsyrt1f9jg.jpg
My apologies on the quality of the image.
My apologies:
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
An error occurred while executing the command definition. See the inner exception for details.
</ExceptionMessage>
<ExceptionType>
System.Data.Entity.Core.EntityCommandExecutionException
</ExceptionType>
<StackTrace>
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.<ExecuteStoreCommandsAsync>d__c.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.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.<ExecuteAsync>d__0`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.Data.Entity.Utilities.TaskExtensions.CultureAwaiter`1.GetResult() at System.Data.Entity.Core.Objects.ObjectContext.<ExecuteInTransactionAsync>d__3d`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.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<ExecuteAsyncImplementation>d__9`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.Data.Entity.Utilities.TaskExtensions.CultureAwaiter`1.GetResult() at System.Data.Entity.Core.Objects.ObjectQuery`1.<GetResultsAsync>d__e.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.Data.Entity.Utilities.TaskExtensions.CultureAwaiter`1.GetResult() at System.Data.Entity.Internal.LazyAsyncEnumerator`1.<FirstMoveNextAsync>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.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.<FirstOrDefaultAsync>d__25`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 DIA_FirearmsAPIversion2.Controllers.FirearmsController.<GetFirearm>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.Threading.Tasks.TaskHelpersExtensions.<CastToObject>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.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>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.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>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.Web.Http.Controllers.AuthenticationFilterResult.<ExecuteAsync>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.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
</StackTrace>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>Invalid object name 'dbo.Firearms'.</ExceptionMessage>
<ExceptionType>System.Data.SqlClient.SqlException</ExceptionType>
<StackTrace>
at System.Data.SqlClient.SqlCommand.<>c__DisplayClass16.<ExecuteDbDataReaderAsync>b__17(Task`1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.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.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.<ExecuteStoreCommandsAsync>d__c.MoveNext()
</StackTrace>
</InnerException>
My original connection string for local:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-DIA_FirearmsAPIversion2-20151118042347.mdf;Initial Catalog=aspnet-DIA_FirearmsAPIversion2-20151118042347;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="DataEntities" connectionString="metadata=res://*/Models.FirearmModels.csdl|res://*/Models.FirearmModels.ssdl|res://*/Models.FirearmModels.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\Data.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="DIA_FirearmsAPIversion2Context" connectionString="Data Source=(localdb)\v11.0; Initial Catalog=DIA_FirearmsAPIversion2Context-20151118164215; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|DIA_FirearmsAPIversion2Context-20151118164215.mdf" providerName="System.Data.SqlClient" />
My connection string to Azure:
<add name="DefaultConnection" connectionString="Data Source=tcp:owm5115h08.database.windows.net,1433;Initial Catalog=diafirearmserver;User Id=username;Password=userpassword" providerName="System.Data.SqlClient" />
<add name="DataEntities" connectionString="metadata=res://*/Models.FirearmModels.csdl|res://*/Models.FirearmModels.ssdl|res://*/Models.FirearmModels.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:owm5115h08.database.windows.net,1433;Initial Catalog=diafirearmserver;User ID=username;Password=userpassword;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="DIA_FirearmsAPIversion2Context" connectionString="Data Source=tcp:owm5115h08.database.windows.net,1433;Initial Catalog=diafirearmserver;User Id=username;Password=userpassword" providerName="System.Data.SqlClient" />
This error seems to suggest that you don't have automatic migrations/database migrations have not been run on your azure version of the database.
Mainly you added a "Firearms" table but the azure table doesn't contain this table
I have a ASP.NET 5 NuGet package called Boilerplate.Web.Mvc6. I am unable to to reference the NuGet package in my ASP.NET 5 website. Here is my project.json file referencing "Boilerplate.Web.Mvc6": "1.0.11".
{
// Omitted
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta6",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta6",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta6",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta6",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta6",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta6",
"Microsoft.Framework.Configuration.EnvironmentVariables": "1.0.0-beta6",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta6",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta6",
"Microsoft.Framework.Logging": "1.0.0-beta6",
"Microsoft.Framework.Logging.Console": "1.0.0-beta6",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta6",
"Newtonsoft.Json": "7.0.1",
"System.Runtime": "4.0.20-beta-23109",
"Boilerplate.Web.Mvc6": "1.0.11"
},
// Omitted
}
When I add the package above, the references in the project shows an error and I get the following printed in the output window:
PATH=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\git
C:\Users\Rehan Saeed\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta7-12364\bin\dnx.exe "C:\Users\Rehan Saeed\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta7-12364\bin\lib\Microsoft.Dnx.Tooling\Microsoft.Dnx.Tooling.dll" restore "C:\Temp\WebApplication2\WebApplication2" -f "C:\Program Files (x86)\Microsoft Web Tools\DNU"
Microsoft .NET Development Utility CLR-x86-1.0.0-beta7-12364
Restoring packages for C:\Temp\WebApplication2\WebApplication2\project.json
CACHE https://api.nuget.org/v3/index.json
CACHE http://MyGet.org/aspnetmaster/
CACHE https://az320820.vo.msecnd.net/v3-flatcontainer/boilerplate.web.mvc6/index.json
GET http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6'
Warning: FindPackagesById: Boilerplate.Web.Mvc6
Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
GET http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6'
Warning: FindPackagesById: Boilerplate.Web.Mvc6
Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
GET http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6'
Error: FindPackagesById: Boilerplate.Web.Mvc6
Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
----------
System.IO.InvalidDataException: Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response. ---> System.Xml.XmlException: 'doctype' is an unexpected token. The expected token is 'DOCTYPE'. Line 2, position 3.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(String expectedToken1, String expectedToken2)
at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options)
at Microsoft.Dnx.Tooling.Restore.NuGet.NuGetv2Feed.EnsureValidFindPackagesResponse(Stream stream, String uri)
--- End of inner exception stack trace ---
at Microsoft.Dnx.Tooling.Restore.NuGet.NuGetv2Feed.EnsureValidFindPackagesResponse(Stream stream, String uri)
at Microsoft.Dnx.Tooling.Restore.NuGet.NuGetv2Feed.<>c__DisplayClass25_0.<FindPackagesByIdAsyncCore>b__0(Stream stream)
at Microsoft.Dnx.Tooling.Restore.NuGet.HttpSource.<GetAsync>d__9.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.ValidateEnd(Task task)
at Microsoft.Dnx.Tooling.Restore.NuGet.NuGetv2Feed.<FindPackagesByIdAsyncCore>d__25.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 Microsoft.Dnx.Tooling.RemoteWalkProvider.<FindLibrary>d__6.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 Microsoft.Dnx.Tooling.RestoreOperations.<FindLibrary>d__9.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.ValidateEnd(Task task)
at Microsoft.Dnx.Tooling.RestoreOperations.<FindLibraryByVersion>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.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Dnx.Tooling.RestoreOperations.<FindLibraryMatch>d__6.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 Microsoft.Dnx.Tooling.RestoreOperations.<FindLibraryEntry>d__5.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 Microsoft.Dnx.Tooling.RestoreOperations.<CreateGraphNode>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.ValidateEnd(Task task)
at Microsoft.Dnx.Tooling.RestoreOperations.<CreateGraphNode>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 Microsoft.Dnx.Tooling.RestoreCommand.<CreateGraphNode>d__71.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.ValidateEnd(Task task)
at Microsoft.Dnx.Tooling.RestoreCommand.<RestoreForProject>d__70.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 Microsoft.Dnx.Tooling.RestoreCommand.<>c__DisplayClass69_0.<<Execute>b__1>d.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 Microsoft.Dnx.Tooling.RestoreCommand.<Execute>d__69.MoveNext()
----------
Restore failed
Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
NuGet Config files used:
C:\Users\Rehan Saeed\AppData\Roaming\NuGet\NuGet.Config
Feeds used:
https://az320820.vo.msecnd.net/v3-flatcontainer/
http://MyGet.org/aspnetmaster/
C:\Program Files (x86)\Microsoft Web Tools\DNU
What's going wrong?
UPDATE
These are my NuGet package feeds:
nuget.org - https://api.nuget.org/v3/index.json
My Get - http://MyGet.org/aspnetmaster
Microsoft .NET - https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/
UPDATE 2
I ran dnu restore --ignore-failed-sources and got the following output, where it still can't find my NuGet package. The strange thing is that I can reference 1.0.10 of the same package from my ASP.NET 5 project but not from an ASP.NET 5 class library.
Restoring packages for C:\Temp\WebApplication2\WebApplication2\project.json
GET https://api.nuget.org/v3/index.json
OK https://api.nuget.org/v3/index.json 130ms
GET http://MyGet.org/aspnetmaster/
OK http://MyGet.org/aspnetmaster/ 142ms
GET https://az320820.vo.msecnd.net/v3-flatcontainer/boilerplate.web.mvc6/index.json
GET http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6'
Warning: FindPackagesById: Boilerplate.Web.Mvc6
Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
GET http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6'
OK https://az320820.vo.msecnd.net/v3-flatcontainer/boilerplate.web.mvc6/index.json 103ms
Warning: FindPackagesById: Boilerplate.Web.Mvc6
Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
GET http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6'
Warning: FindPackagesById: Boilerplate.Web.Mvc6
Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
Unable to locate Boilerplate.Web.Mvc6 >= 1.0.11
Writing lock file C:\Temp\WebApplication2\WebApplication2\project.lock.json
Restore complete, 1210ms elapsed
Errors in C:\Temp\WebApplication2\WebApplication2\project.json
Unable to locate Boilerplate.Web.Mvc6 >= 1.0.11
NuGet Config files used:
C:\Users\Rehan Saeed\AppData\Roaming\NuGet\NuGet.Config
Feeds used:
https://az320820.vo.msecnd.net/v3-flatcontainer/
http://MyGet.org/aspnetmaster/
It might be a myget bug. I opened a bug on dnu anyway (see it here) and also pinged the myget folks.
The issue is that http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' returns 200 OK and HTML when the package is not found and we try to parse it as XML.
You can pass --ignore-failed-sources to dnu restore to unblock yourself.
I have tried deleting the project.lock.json file and re-opening Visual Studio which usually solves this problem for me.
I have since retried installing version 1.0.11 of the package and it magically worked. Since previous versions were working and I made no changes to the project or my installation, I suspect this to be a NuGet package on-boarding problem. It has taken three days for NuGet to register the new version of the package.