I have a multithreaded Windows Service I've developed with VS 2010 (.NET 4.0) which can have anywhere from a few to a few dozen threads, each retrieving data from a slow server over the Internet and then using a local database to record this data (so the process is Internet-bound, not LAN or CPU bound).
With some regularity, I am getting a flood/flurry/burst of the following error from several threads simultaneously:
System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
The call stack for this error is typically:
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
I'm not specifying a Connection Timeout in the connection string, and there are other applications and processes working in this database. Has anyone come across this kind of behavior and if so what was done to prevent it?
The most commonly-called method in my data access layer looks like this, and all my other DAL methods follow the same approach:
using (SqlConnection con = new SqlConnection(GetConnectionString()))
using (SqlCommand cmd = new SqlCommand("AddGdsMonitorLogEntry", con))
{
cmd.CommandType = CommandType.StoredProcedure;
/* setting cmd.Parameters [snipped] */
// We have been getting some timeouts writing to the log; wait a little longer than the default.
cmd.CommandTimeout *= 4;
con.Open();
cmd.ExecuteNonQuery();
}
Thanks very much!
EDIT
Given comments about this occurring in mirrored environments, I should indeed mention that the database in question is mirrored. It's marked in SSMS as "Principal, Synchronized", in "High safety without automatic failover (synchronous)" mode.
EDIT 5/26/11
I am seeing nothing in the SQL Server logs to indicate any problems. (I don't have access to the Windows Event Viewer on that server, but I've asked for someone to look for me.)
According to the MSDN Blog post just created today (hooray for Google!):
Microsoft has confirmed that this is a problem in the current release of ADO.NET. This issue will be fixed in ADO.NET version, ships with Visual Studio 2011.
In the meantime, we request to use the following workarounds:
Increase the connection string timeout to 150 sec. This will give the first attempt enough time to connect( 150* .08=12 sec)
Add MinPool Size=20 in the connection string. This will always maintain a minimum of 20 connections in the pool and there will be less chances of creating new connection, thus reducing the chance of this error.
Improve the network performance. Update your NIC drivers to the latest firmware version. We have seen network latency when your NIC card is not compatible with certain Scalable Networking Pack settings. If you are on Windows Vista SP1 or above you may also consider disabling Receive Window Auto-Tuning. If you have NIC teaming enabled, disabling it would be a good option.
The post itself is an interesting read, talking about a TCP/IP connection retry algorithm. And kudos to all the folks who said "hey this looks like it's related to mirroring..."! And note the comment about this being "because of slow response from SQL Server or due to network delays".
UGH!!!
Thanks to everyone who posted. Now we must all ask for a patch to the .NET Framework (or some other ADO.NET patching mechanism), so we don't have to wait for (and buy) Visual Studio 11...
Connection timeout is a different thing than command timeout. Command timeout applies to situation when you have connection established, but due to some internal reasons server cannot return any results within required time. Default command timeout is 30 seconds.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx
Try to specify connection timeout in the connection string. Default value is 15 seconds what may be the reason of the issue you see.
You can also specify connection timeout in code:
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx
I get this every once in a while on this old database server that we have (coming up on 10 years old now). When it does happen though it's because something is hammering that thing with connections/queries constantly. My guess is that you'll find that when it happens the database server is under load (or a high number of connections or something along those lines) Anyway, in my experience if you can optimize the code, optimize the database, getting a beefier database server, etc. all helps. Another thing you can do, which Piotr suggests, is simply up the timeout for the connection. I'd still go through and optimize some stuff though (should help in the long run).
I have been able to somewhat reliably reproduce this problem. I have a service that when a processing job is requested it kicks off processing in a new appdomain / thread. This thread will execute 10 to 16 database queries simultaneously. When I run 30 of these jobs one after another then a random one or two of the jobs will crash with the timeout error.
I changed the connection string to turn off Connection Pooling with Pooling=false and then the error changed to the following. This gets thrown 3 or 4 times inside an aggregate exception, since the connections are happening inside a Parallel.For
System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
at System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean& marsCapable)
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginWithFailover(Boolean useFailoverHost, ServerInfo primaryServerInfo, String failoverHost, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at Tps.PowerTools.CoreEngine.V5.DataAccess.DataContext.ExecuteQuery(PtQuery query, ValueStore`1 store, String readerDescription) in C:\SourceCode\Tps.PowerToolsV1\Trunk\Libraries\CoreEngine\CoreEngine.V5\DataAccess\DataContext.cs:line 326
at Tps.PowerTools.CoreEngine.V5.DataAccess.DataContext.<StockHistoricalData>b__15(PtQuery query) in C:\SourceCode\Tps.PowerToolsV1\Trunk\Libraries\CoreEngine\CoreEngine.V5\DataAccess\DataContext.cs:line 302
at System.Threading.Tasks.Parallel.<>c__DisplayClass32`2.<PartitionerForEachWorker>b__30()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass7.<ExecuteSelfReplicating>b__6(Object )
Optimizing the queries you are executing on the remote server will always help. Time each query and look for long running ones. If you are just doing reads then use the (NOLOCK) hint on the SELECT statements. This was a life saver for me. Just read up on it to make sure it is appropriate in your application. If you have access to the remote database make sure the indexes are not to fragmented. This will cause a major slow down in query execution. Make sure indexes are rebuilt/reorganized as part of the SQL maintenance plan. Add new indexes where appropriate.
Extending the timeout may make matters worse. If you let queries run longer then, potentially, more queries will time out. The timeout is there to protect the server and other clients accessing it. Bumping it up a little is not a huge deal but you don't want queries running for a long time killing the server.
Related
Ok, in an attempt to move my app to the cloud I've moved a local SQL database to Azure SQL. The problem is that the connection to that new Azure SQL database is so 'flakey' I'm about to bring it back in house.
The task is to loop and create a a total of about 481K records in the database.
The connection string is
"Server=tcp:xxx,1433;Initial Catalog=xx;Persist Security Info=False;User ID=xx;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;ConnectRetryCount=255;"
The SQL query it is running each time is not complicated. Just inserting three values into three columns. (column and values changed to protect some internal workings)
Insert Into TheTable (C1, C2, C3) VALUES ('V1', 'V2', 'V3')
but at random points it throws this.
System.ComponentModel.Win32Exception (0x80004005): The wait operation timed outExecution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at XX in D:\PATHOFTHEFILE:line 420
Note that
1) I'm opening and closing the connection each time I create a record and closing it in the next step.
2) There's no one else hitting the database except me.
3) The database service is set for S1.
4) Yeah - I get the irony that the program is crashing on line 420. I'm trying to find ways to drug test the code.
Questions
1) Is there anything wrong with my connection string? The documentation says that I should use a Timeout of 30 when connecting to an Azure SQL database. Frankly the code ran better (or at least lived longer) when I had the timeout set for 0.
2) At first I tried using a single connection to handle the loop through the entire 481K INSERT statements. Is that a bad design? How long will Azure SQL reliability hold a connection?
3) I'm not getting a warm fuzzy feeling about the ability to build rock solid apps on Azure SQL. Can someone point me to a good reference about the difference between building for local SQL vs Azure SQL. I've gone through everything I can find and there just didn't seem to be that much out there.
4) I like the fact that I can connect to Azure SQL with MMC. But there are (generically speaking) all kinds of monitoring info I can't get from MMC anymore. Anyone have a link to something that can help me really understand what's going on in the database without using that dreadful Azure Portal
UPDATE #1
Guilty as charged
public static void RunSQL(string SQLString)
{
int a = 0;
SqlCommand Command = new SqlCommand(SQLString, TheConnection);
try
{
a = Command.ExecuteNonQuery();
}
catch (Exception ex)
{
Notifications.EventLogging.ProcessEvent(SQLString + " go boom " + ex.InnerException + ex.Message + ex.StackTrace);
Notifications.EventLogging.ProcessEvent("Time Of Death" + DateTime.Now);
Console.ReadKey();
}
Azure SQL instances are hosted on shared infrastructure. Azure will throttle requests to ensure that all instances on a server can meet the minimum SLA. In this life, death and taxes are guaranteed, but Azure SQL Connections are not.
To deal with this, you need to have automatic retry. Microsoft has provided a few options over the years, beginning with the now deprecated ReliableSqlConnection class. The preferred way to talk to Azure SQL these days is with Entity Framework 6.x, which has automatic retry built in.
In practice, an Azure SQL database that sees light and sporadic traffic rarely sees a throttle event. I've had developer friends who have deployed production code hitting an Azure SQL database, used raw SqlConnections and SqlCommands, and seemed genuinely surprised when I told them that connections aren't guaranteed. They'd never run across it! But if you're hitting the hell out of a server (as you are doing), I've seen it happen enough to be noticeable.
EDIT 12-6-2018: I have experienced this problem myself in the last few months. After combing through the logs, the culprit was spikes in database traffic that maxed out the DTU limit for my SQL Server. Retry is not necessarily a sufficient solution in this case because automatic retry effectively helps choke your SQL DB. To check and see if you are falling victim to DTU throttling, go to your Azure SQL DB's Overview tab, look at the resource utilization graph, and make SURE you select Max as the metric. It defaults to Avg, and this can hide spikes in DTU traffic.
Edit 8-6-2019: If you're maxing out DTUs and want to know what's causing it, there are a few places to look on the Azure SQL Management blade in the Azure Portal:
Query performance insights. You can use the tools here to find your top resource-consuming queries that have run in a given time period. This is a good place to start. Make sure to check through all metrics.
Performance recommendations. If you're missing an index, it's probably listed here.
Metrics. Check through all listed. Make sure to set your aggregation to Max.
This should give you good (or even great) indicators of what's going wrong.
Upgrade to higher level of Premium version, migrate and then downgrade accordingly. This will help you get around timeout errors.
I have azure cloud service - 2 web instances, serving about 500,000 requests per day. Using Azure business database. There is one issue with it - sometimes (avg. once per day, but not in the same time) there is 2-3 minutes long interval while i am unable to query DB, the error message is like this:
System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: Connection Timeout Expired. The timeout period elapsed during the post-login phase. The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=1; handshake=12; [Login] initialization=0; authentication=0; [Post-Login] complete=14004; ---> System.ComponentModel.Win32Exception: The wait operation timed out
--- End of inner exception stack trace ---
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Entity.Infrastructure.DbExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
--- End of inner exception stack trace ---
at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClassb.<GetResults>b__9()
at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at MyProject.MyRepository.GetItems(Boolean includePremium, Int32 a, Int32 b, Int32 c)
at MyProject.Controllers.MyController.GetItems(String Id, String device)
Numbers in the message - [Pre-Login] initialization=1; handshake=12; [Login] initialization=0; authentication=0; [Post-Login] complete=14004 - are always the same, not some random wait times or something...
Of course I tried to google this error, but all I could find was related to wrong connection management with plain ADO.NET etc. I am using Entity Framework 6, with code-first model, linq to entities queries, queries are not heavy (few ms, always under 1s).
There is this question on SO : Connection timeout in SQL Azure with answer like "this is transient error, just try again" - but this wont solve it for me, I got hundreds of these errors within this interval, I am pretty sure every request fail, so "wait 5 sec and try again" policy wont help here.
Is there something special about Azure DB which I must do about connection lifetime management in EF? Or you think this can be error message for "throttling" DB?
Well, after some time and some refactoring, it seems this error is indeed indicating throttling. We managed to reduce number of requests per minute, and without any other changes these errors disappeared entirely.
Its a shame that SQL Azure dont give more helpful messages about limits/resources.
I was able to fix this issue by disabling the Auto-Pause option. In my case, Auto pause option was enabled with 1 hour as its value and so the database was paused after 1 hour of idle time. So either you can increase this Auto Pause value or can disable it completely.
CAUTION: This will impact your monthly charges
Before reading please note that I've googled this and read a ton of articles on SO and elsewhere, no suggestions have worked as of yet.
I'm randomly getting a timeout error that occurs when logging into my MVC 3 application. It happens well over half of the time - all other times the application logs on just fine. When it doesn't work, it tries for about 10 seconds then errors.
The error:
Exception: "An error occurred while executing the command definition. See the inner exception for details."
Inner Exception: {"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.\r\nTimeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."}
This happens inside my repository class that directly interacts with entity framework.
It seems to happen when logging in and simply pulling a quick check from the database, such as:
return entities.Users.SingleOrDefault(user => user.UserName == userName);
return (entities.Users.SingleOrDefault(u => u.UserId == user.UserId || u.UserName == user.UserName) != null);
Things I've tried:
SQL Server validation
Integrated Security (I even gave every possible account full database access)
Running outside of IIS
Setting Connect Timeout extremely high (Connect Timeout=50000) in the connection string. (I do not have Default Command Timeout set here)
Setting the CommandTimeout to 0, 5000, 100000, whatever, on my entity connection: entities.CommandTieout = 100000;
Setting the CommandTimeout inside every using statement where I use an instance of the repository.
Flipping SingleOrDefault to FirstOrDefault etc.
Enabling/Disabling Lazy Loading (Why not?)
If it helps:
I am using a custom role and membership provider.
I'm just making calls from my controller inside a using statement (AccountRepository bleh = new AccountRepository()) and the AccountRepository implements IDisposable etc.
The entity model is in a separate project.
I'm running the site in IIS. It's setup with the 4.0 integrated app pool.
All accounts have full database access.
When the error occurs, it doesn't take no where near as long as I have set in the web config (50000 I think) or for the commandtimeout in the repository.
It's not doing much on the login, just validating user, getting user role then loading up some small amount data, but the error always occurs when getting the user data on login.
When I try it outside of debugging it repeats the error four or five times (with custom errors off).
Here is the full exception from the event log:
Exception information:
Exception type: SqlException
Exception message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
You could examine the problem from the database server by setting up a SQL Server Profiler.
You can find lots of info about SQL Profiler by just googling around. Here's a site with a video that might help you get started.
Edit: While this did indeed help me it was not the solution. The problem still exists for anyone reading in the future.
Just to let everyone know - I believe that I have found the issue. Through the SQL Profiler, I saw that the account being used to access SQL was in fact the local system account. I then realized that in an attempt to fix an issue prior, I had changed the ASP.NET v4.0 app pool to use the local system account. I went and changed the Identity back to 'ApplicationPoolIdentity', added the IIS APPPOOL\ASP.NET v4.0 user to the database and so far everything has been working great. #DOK - Thank you much for the information on SQL Profiler, it helped tremendously! Thanks everyone else also!
We have an Nant build script that we are running through SSH (Cygwin & Open SSH) to remotely upgrade our databases. When the Nant script is launched through an SSH session, the following error is thrown when it attempts to make a database connection. However, if I log in to the server directly (using the same account as the service) and run the Nant scripts by hand, the script executes successfully.
Error Message:
System.InvalidOperationException: The
.Net Framework Data Providers require
Microsoft Data Access
Components(MDAC). Please install
Microsoft Data Access Components(MDAC)
version 2.6 or later.
---> System.IO.FileNotFoundException: Retrieving the COM class factory for
component with CLSID
{2206CDB2-19C1-11D1-89E0-00C04FD7A829}
failed due to the following error:
8007007e.
Stack Trace:
System.InvalidOperationException: The .Net Framework Data Providers require Microsoft Data Access Components(MDAC). Please install Microsoft Data Access Components(MDAC) version 2.6 or later.
---> System.IO.FileNotFoundException: Retrieving the COM class factory for component with CLSID {2206CDB2-19C1-11D1-89E0-00C04FD7A829} failed due to the following error: 8007007e.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Data.OleDb.OleDbConnectionInternal.CreateInstanceDataLinks()
at System.Data.OleDb.OleDbConnectionInternal.GetObjectPool()
--- End of inner exception stack trace ---
at System.Data.OleDb.OleDbConnectionInternal.GetObjectPool()
at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at UpgradeDatabases.UpgradeDatabase.Execute()
After spending lots of time trying to track down the cause, I am stuck. Here are some observations I have made:
The script runs perfectly when I run it manually on the same machine (without SSH). I can even run the script manually, with the same user that the SSH service is running under.
Since the Nant script is running under the context of a service, the issue seems to be related to the User Profile.
The script is executing on a Windows 2008 Server with .NET 3.5 installed. I wouldn't assume that MDAC would be a problem here as the exception indicates
One site states that it might be related to UPHClean (which is a part of the User Profile Service in Windows Server 2008). I haven't been able to confirm that this is actually the problem. I looked in the Event Viewer for Event ID 1530 and there are a few occurrences, but they don't correlate with each execution of the build script.
I installed the native OleDb providers for SQL Server 2008 and the same error occurs.
Does anyone have any advice on how I can track down the root cause of this issue? It really seems to be related to the fact that the code is running under the context of a service. I've used Procmon to try to trace through the execution, but I haven't had any luck finding the culprit. Thanks in advance!
I also had the "The .Net Framework Data Providers require Microsoft Data Access Components(MDAC). Please install Microsoft Data Access Components(MDAC) version 2.6 or later." error when trying to invoke my Windows program over ssh, but not when running the same program directly in a cygwin terminal on the server (Windows Server 2008 R2 Enterprise). I felt sure this could be made to work using openssh in cygwin. Eventually I found that it could be made to work if you sent the following environment variable in the ssh call:
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
So if you logged in like so:
$ ssh myuser#myserver -o SendEnv='CommonProgramFiles(x86)'
Then you should be able to run your program successfully. Note this assumes you have already configured sshd on the server to accept the environment variable. You can do that by adding the following line to /etc/sshd_config and then restarting sshd (net stop sshd followed by net start sshd):
AcceptEnv CommonProgramFiles(x86)
When AccessDatabaseEngine.exe (Microsoft Office Access database engine 2007) is installed (download it from http://www.microsoft.com/en-us/download/confirmation.aspx?id=23734) it puts some files under C:\Program Files (x86)\Common Files.
The problem was definitely related to Cygwin + OpenSSH. I ended up installing WinSSHD and my issue was resolved. So for future reference, be wary of Cygwin + OpenSSH running on Windows Server 2008. I hope this helps!
Same issue on Windows 7 + OpenSSH (OpenSSH_6.5p1, OpenSSL 1.0.1f 6 Jan 2014) while running C# program connecting Access database.
I've added
export CommonProgramFiles="C:\Program Files\Common Files"
in /etc/profile file.
Hope this help.
I'm currently getting the following error when editing and deleting scheduled reports in SSRS: "Only members of sysadmin role are allowed to update or delete jobs owned by a different login."
I've tried changing the owner of the jobs to the Service account used by SSRS, I've added that users as a sysadmin and I've checked the user and password for the limited account for the Reporting Services itself. Nothing is making a difference.
The reporting services log just shows:
w3wp!library!a!06/03/2009-01:23:42:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ;
Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.Data.SqlClient.SqlException: Only members of sysadmin role are allowed to update or delete jobs owned by a different login.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.ReportingServices.Library.InstrumentedSqlCommand.ExecuteNonQuery()
at Microsoft.ReportingServices.Library.SqlAgentScheduler.DeleteTask(Guid id)
at Microsoft.ReportingServices.Library.SchedulingDBInterface.UpdateTaskProperties(Task task, Boolean updateSqlAgentSchedule)
at Microsoft.ReportingServices.Library.TimedSubscriptionHandler.ValidateSubscriptionData(Subscription subscription, String subscriptionData, UserContext userContext)
at Microsoft.ReportingServices.Library.SubscriptionManager.ValidateSubscriptionData(Subscription subscription, String eventType, String subscriptionData)
at Microsoft.ReportingServices.Library.SubscriptionManager.SetSubscriptionProperties(Guid id, String eventType, String matchData, ExtensionSettings extensionSettings, String description, ParameterValueOrFieldReference[] parameters, DataRetrievalPlan dataSettings)
at Microsoft.ReportingServices.Library.SetSubscriptionPropertiesAction.PerformActionNow()
at Microsoft.ReportingServices.Library.RSSoapAction`1.Execute()
--- End of inner exception stack trace ---
I found the problem. The SSRS application pool in IIS for the Reports Manager is running as the Network Service user, which was being used as the connection context even though the application using the service is loging in as the limited user.
Solutions:
Change the application pool to a user that has SysAdmin rights or ownership of the jobs in the DB
Or add the Network Service user as a SQL user and SysAdmin
I have same issue with SSRS 2005.
Not all reports are like this but have struck the odd subscription that cannot be updated/removed.
IIS runs on one server as builtin network and the tables are on a separate clustered server. I cannot grant the IIS builtin account rights to the tables on the remote database server.
I have had some luck with finding the itemid of the report in the catalog, matching the report_oid in the subscriptions table and deleting the row with the affected subscription itemid.
Sounds awful but after this I can recreate the subscription and all is good in the world.