We are running RavenDB 2.5 build 2956 as a windows service on a Windows Server 2012 R2 VM in Windows Azure (a DS12 - with premium SSD storage). We have about 500 tenant databases on this server - only about 150 of which are actively used. Each has about 50 indexes in them - none of which have Reduce's on them. This server has master-master replication to another identical server with an identical setup. I know we are on an old Raven build at this point and we are researching upgrade paths - but until then it would be nice to understand what is going on or if there is something we could do differently. We'd also like to know, of course, if this is an issue resolved in the newer versions.
When we attempt to stop the Raven windows service (either via the Windows Services UI or using the command line), Raven never stops. It just logs the following warning over and over again forever.
2016-10-05 04:19:11.1516,Raven.Storage.Esent.StorageActions.DocumentStorageActions,Warn,,Error when trying to open a new DocumentStorageActions,"Microsoft.Isam.Esent.Interop.EsentInvalidInstanceException: Invalid instance handle
at Microsoft.Isam.Esent.Interop.Api.Check(Int32 err) in C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:line 2739
at Microsoft.Isam.Esent.Interop.Api.JetBeginSession(JET_INSTANCE instance, JET_SESID& sesid, String username, String password) in C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:line 823
at Raven.Storage.Esent.StorageActions.DocumentStorageActions..ctor(JET_INSTANCE instance, String database, TableColumnsCache tableColumnsCache, OrderedPartCollection`1 documentCodecs, IUuidGenerator uuidGenerator, IDocumentCacher cacher, EsentTransactionContext transactionContext, TransactionalStorage transactionalStorage) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Storage\Esent\StorageActions\General.cs:line 76"
Well, we've never waited forever of course, but we've waited for over an hour. Raven seems to be stuck in an infinite loop that it never gets out of. So, eventually, we reboot the server and when Raven comes back online, as the databases start replicating again, the server seems to get very busy (both CPU and RAM). This happens for several hours - churning CPU and RAM - until things finally stabilize. It appears that all of the indexes are marked as stale and it needs to rebuild all indexes in all of the tenant databases - hence the churn while it is doing that. When it gets done, things seem to return to normal (meaning the CPU and RAM seem to stabilize and stop churning).
I've found some other posts on this board with regards to the above error, but nothing in this particular context. This only seems to affect us when shutting down a raven instance - and it happens to both our primary and secondary instances (the secondary usually has nothing going on except replication - so no queries and no streaming results).
Now, one more wrinkle. We did this process last night and this time we had 5 databases that became inaccessible. When the primary tries to replicate to these 5 databases, we now get these errors:
2016-10-05 16:37:21.9394,Raven.Database.Server.HttpServer,Warn,,Could not open database named: pms_bac1d117-93fc-4b0a-a944-b3df7cc70a7e,"System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Could not open transactional storage: f:\RavenDb\Databases\db_xxxx\Data ---> Microsoft.Isam.Esent.Interop.EsentTempPathInUseException: Temp path already used by another database instance
at Microsoft.Isam.Esent.Interop.Api.Check(Int32 err) in C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:line 2739
at Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection`1 documentCodecs) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Storage\Esent\TransactionalStorage.cs:line 431
--- End of inner exception stack trace ---
at Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection`1 documentCodecs) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Storage\Esent\TransactionalStorage.cs:line 445
at Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration, TransportState transportState) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\DocumentDatabase.cs:line 215
at Raven.Database.Server.HttpServer.<>c__DisplayClass43.<TryGetOrCreateResourceStore>b__41() in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Server\HttpServer.cs:line 1112
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait(TimeSpan timeout)
at Raven.Database.Server.HttpServer.SetupRequestToProperDatabase(IHttpContext ctx) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Server\HttpServer.cs:line 977
---> (Inner Exception #0) System.InvalidOperationException: Could not open transactional storage: f:\RavenDb\Databases\db_xxxx\Data ---> Microsoft.Isam.Esent.Interop.EsentTempPathInUseException: Temp path already used by another database instance
at Microsoft.Isam.Esent.Interop.Api.Check(Int32 err) in C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:line 2739
at Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection`1 documentCodecs) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Storage\Esent\TransactionalStorage.cs:line 431
--- End of inner exception stack trace ---
at Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection`1 documentCodecs) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Storage\Esent\TransactionalStorage.cs:line 445
at Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration, TransportState transportState) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\DocumentDatabase.cs:line 215
at Raven.Database.Server.HttpServer.<>c__DisplayClass43.<TryGetOrCreateResourceStore>b__41() in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Server\HttpServer.cs:line 1112
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()<---
"
2016-10-05 16:37:22.9863,Raven.Database.Server.HttpServer,Warn,,Error on request,"System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Could not open transactional storage: f:\RavenDb\Databases\db_xxxx\Data ---> Microsoft.Isam.Esent.Interop.EsentTempPathInUseException: Temp path already used by another database instance
at Microsoft.Isam.Esent.Interop.Api.Check(Int32 err) in C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:line 2739
at Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection`1 documentCodecs) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Storage\Esent\TransactionalStorage.cs:line 431
--- End of inner exception stack trace ---
at Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection`1 documentCodecs) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Storage\Esent\TransactionalStorage.cs:line 445
at Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration, TransportState transportState) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\DocumentDatabase.cs:line 215
at Raven.Database.Server.HttpServer.<>c__DisplayClass43.<TryGetOrCreateResourceStore>b__41() in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Server\HttpServer.cs:line 1112
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Raven.Database.Server.HttpServer.SetupRequestToProperDatabase(IHttpContext ctx) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Server\HttpServer.cs:line 1014
at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Server\HttpServer.cs:line 783
at Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Server\HttpServer.cs:line 678
---> (Inner Exception #0) System.InvalidOperationException: Could not open transactional storage: f:\RavenDb\Databases\db_xxxx\Data ---> Microsoft.Isam.Esent.Interop.EsentTempPathInUseException: Temp path already used by another database instance
at Microsoft.Isam.Esent.Interop.Api.Check(Int32 err) in C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:line 2739
at Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection`1 documentCodecs) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Storage\Esent\TransactionalStorage.cs:line 431
--- End of inner exception stack trace ---
at Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection`1 documentCodecs) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Storage\Esent\TransactionalStorage.cs:line 445
at Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration, TransportState transportState) in c:\Builds\RavenDB-Stable-2.5\Raven.Database\DocumentDatabase.cs:line 215
at Raven.Database.Server.HttpServer.<>c__DisplayClass43.<TryGetOrCreateResourceStore>b__41() in c:\Builds\RavenDB-Stable-2.5\Raven.Database\Server\HttpServer.cs:line 1112
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()<---