I have the following code in the migration configuration seeding method:
string sqlQuery = // 22 mb file contents
context.Database.ExecuteSqlCommand( sqlQuery );
The ExecuteSqlCommand function is making Azure throw this error:
The service has encountered an error processing your request. Please
try again. Error code 701. A severe error occurred on the current
command. The results, if any, should be discarded.
Why might this be? I really can't find much information on it
SQL error 701 according to my googling is the following:
SQL Server has failed to allocate sufficient memory to run the query.
This can be caused by a variety of reasons including operating system
settings, physical memory availability, or memory limits on the
current workload. In most cases, the transaction that failed is not
the cause of this error.
May be time for an upgrade, or change what your query is pulling back or splitting it out into separate queries.
Related
I've been trying to follow several different tutorials with EFCore and .net core and I've been totally blocked at the point where I try and create a local database.
I've used both the powershell tools and the commandline tools to try and create an initial migration (or do anything, really).
I consistently get the error:
System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseSqlServer' call.
---> Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.)
The database does not currently exist on the system, though local SQL Server appears to be up and running.
Here is the c# code for adding the context:
services.AddDbContextPool<TestDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("TestDb")
)
);
This is the connection string code:
"TestDb": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=TestDb"
I get similar errors whether I run add-migration, dotnet ef migration add, or dotnet ef dbcontext info. (note: with the dotnet calls I am using the -s ..\{webproject}\{webproject}.csproj property
I've also messed with the connection string by adding various combinations of Trusted_Connection=True; MultipleActiveResultSets=True;, and Integrated Security=true.
I've gone into SSMS and ensured the Server authentication is SQL Server and Windows Authentication Mode and that Maximum Connections is set to 0 (unlimited). I've also gone to logins and tried adding the user to pretty much all the server roles.
So, yeah, I'm pretty confused. I've worked with EF for years, though this is my first experience with EFCore and I'm definitely more of a developer than a SQL Admin. This is also my first time trying to use the local db on this particular computer.
Edit: Looking at error.log in AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\mssqllocaldb I see this error:
2020-01-28 10:15:03.50 Logon Error: 18456, Severity: 14, State: 38.
2020-01-28 10:15:03.50 Logon Login failed for user 'LAPTOP-NC6HQ4TB\ripli'. Reason: Failed to open the explicitly specified database 'TestDb'. [CLIENT: <named pipe>]
Which is confusing. Of course I can't open the specified database. The entire point is I want to create a DB that doesn't yet exist.
Found the answer. Sorry to everyone who tried to help, as you wouldn't have had enough information to solve it.
In the DbContext I had tried to add some code to the constructor to try and populate some data to the database as part of a test. This caused several problems. If the Database hadn't yet been created it tried to connect to the DB before it had been created, which caused the problems I described.
Furthermore, if I had created the db manually it would try to access the DbSets (which had not yet been created), and then complain that the set name was invalid (which, at this point it was.
This all might have been fine if the DB had been created in advance, but since I was using the DbContext to construct the database, it understandably caused problems.
And all of this headache would have been avoided had I not violated SRP and not tried to (even temporarily) hijack a context constructor to hack in some test data.
The takeaway here? Don't pollute your constructors with unrelated hacks. Bleh.
I am working on API development project using ASP.NET Core 2.2, GraphQL.NET , CosmosDB, Entity Framework Core (Microsoft.EntityFrameworkCore.Cosmos v2.2.4).
While testing the API method which pulls the data from AzureComosDB, sometime I get this error:
Microsoft.EntityFrameworkCore.Storage.RetryLimitExceededException: 'Maximum number of retries (6) exceeded while executing database operations with 'CosmosExecutionStrategy'. See inner exception for the most recent failure.'
I am not sure why this error is popping up intermittently.
Can anyone help me here by providing some guidance to fix this issue?
I would like to know more information about context file as the error says `
'Maximum number of retries (6) exceeded'
`. It might cause if you are trying to redeploy database on every request, So Considering you have already deployed database in cosmosdb it is recommended to remove Database.EnsureCreated() as will create performance issues.
Refer to this documentation for more information https://learn.microsoft.com/en-us/ef/core/providers/cosmos/?tabs=dotnet-core-cli
First of all, have you checked the inner exception as stated in the error?
Microsoft.EntityFrameworkCore.Storage.RetryLimitExceededException: 'Maximum number of retries (6) exceeded while executing database operations with 'CosmosExecutionStrategy'. See inner exception for the most recent failure.'
it might give a clue as to why it is failing.
Now, this error is caused by the cosmos retry stategy. If an operation failes it will retry it to up to six times.
You can modify this strategy but the default can be found here.
The fact that it is retried indicates it it an error that might be gone when retried. A good example is a glitch in the netwerk connection (like, when the wifi signal is bad). Another one could be the fact that the requests are exceeding the provisioned Request Unit limits.
I was looking around for some tools that help injecting packet capture into a database. I was lucky bu finding one tool from COMMAND FIVE PTY LTD. the tool is called C5 SIGMA, and based on description, it makes possible to get data from capture and put it in a database.
I downloaded files and prepared the environment for run, but when executing, I get a lot of errors
[WARNING] - Unable to convert field value.
Name: frame.time_relative
Value: 6.874690000
Error: Input string was not in a correct format.
[ERROR] - Error processing packet.
Index: 5179
Error: Too many asynchronous failures.
I downlaoded source files, and debug, but i found code normal, and parsing is fine. Here is source files: http://www.commandfive.com/downloads/c5sigma.html
If any one could help, I appreciate.
Thank you
I've just downloaded the same product and I get the Error: Too many asynchronous failures error as well.
I've dropped them an email so if/when I get a response I will let you know.
Just dumped the output to a text file, before all the asynchronous failures is this error:
[ERROR] - Asynchronous write failure. Error: A network-related or instance-specific
error occurred while establishing a connection to SQL Server. The server w
as not found or was not accessible. Verify that the instance name is corre
ct and that SQL Server is configured to allow remote connections. (provide
r: Named Pipes Provider, error: 40 - Could not open a connection to SQL Se
rver)
Might be worth checking to see if your SQL server is expected connections as expected. I'm currently using SQL Express so will try it on a fully fledged SQL server.
Actually, had the same issue. I found by reducing the pcap sizes, C5 Sigma didn't error.
This is the second time I got following error for my website:
Warning: Fatal error 9001 occurred at May 5 2012 1:16AM. Note the
error and time, and contact your system administrator.
I get this error while login to website. However, there is no any problem for connecting database or fetching records.
Last time I just took a backup and restore my database then this issue was resolved. But, I got again similar issue, now I want to know exact cause for this error.
I appreciate your reply.
Check SQL Server logs, seems to be an issue with log being full. "Last time I just took a backup and restore my database then this issue was resolved." seems to be database related. Check https://serverfault.com/questions/238394/diagnosing-microsoft-sql-server-error-9001-the-log-for-the-database-is-not-avai.
The same database and application acts weirdly on our test machine, but it works nice on other computers.
On the test machine:
We get SSL error exception. We fixed that based on an MS KB article, but after that it said
"Server error" or "General network error" and slowed down to 1-2 stored procedures/second.
The profiler said that we have 2000-2500 connections when the application runs. The same application has only 5-10 connection on other machines. I think the random error messages are caused by this huge connection count.
We reinstalled SQL Server, turned off the connection pool, and closed all datareaders.
What else can I do? Is there a "deeper" configuration tool for MSSQL2k? Any hidden component/ini/config/registry key? Or another profiler other than SQL Profiler that I can use?
Yet another possibility(!):
Multiple Fixes for SQL Server .NET Data Provider
When the SQLCommand.CommandTimeout is
set to zero, you expect an infinite
timeout. However, versions 1.1 and 1.0
of the SqlClient provider incorrectly
timeout when a response from SQL
Server is broken into two packets.
Immediately upon receipt of the second
packet, versions 1.1 and 1.0 of the
provider incorrectly timeout. The fix
that is included in this article fixes
this issue so that the command will
have an infinite timeout.
What happens if you turn off OLE DB Resource Pooling?:
'For SQLOLEDB provider
'strConnect = "Provider=SQLOLEDB;server=MyServerName;OLE DB Services = -2;uid=AppUser;pwd=AppUser;initial catalog=northwind"
' For MSDASQL provider
'strConnect = "DSN=SQLNWind;UID=Test;PWD=Test; OLE DB Services= -2"
Another thing to look at is whether you are always specifying the type and direction of stored procedure parameters from ADO.NET.
What happens internally is sqlClient converts the parameters which you have set in ADO.NET to the relevant datatypes in the stored procedure parameters. But this can fail when you are sending nText parameters where it might result in a wrong conversion.
Also, I would check to see if you are sometimes passing very long statements in stored procedure parameters.
Thanx again Mitch, sadly none of those ideas was real solution. No suprise - it seems that those error messages from MSSQL are random.
Random, I mean:
After X[1] concurrent connection MSSQL stops to close connections automatically, and the connection pool grooves huge. Before X, I saw only 5-10 connections[2] / but after that there was 2500 and MSSQL chrased.
In this case, MSSQL throws non deterministic error messages like 'General failure', 'User (null)' etc.
We had unclosed connection in our DAL (hidden since 2 years...brrr), and when we used that to much, it caused this wreid error.
[1] I have no idea about concrete value of X
[2] I've used this query:
SELECT
DB_NAME(dbid) as DBName,
COUNT(dbid) as NumberOfConnections,
loginame as LoginName
FROM
sysprocesses
WHERE
dbid > 0
GROUP BY
dbid, loginame