Re: [RavenDB] "Secondary index is corrupt. The database must be defragmented"

911 views
Skip to first unread message

Oren Eini (Ayende Rahien)

unread,
Nov 8, 2012, 6:33:01 AM11/8/12
to rav...@googlegroups.com
esentutl /d Data

From the ravendb data directory should resolve it.

On Thu, Nov 8, 2012 at 1:31 PM, Darren Bruning <dar...@bruning.net.nz> wrote:
Hi,

I recently got back to my computer after 2 weeks away, upgraded the computer to Windows 8, and then tried to run my app. 
I get the following exception:

A critical error occurred while starting the server. Please see the exception details bellow for more details:
System.InvalidOperationException: Could not open transactional storage: C:\Program Files\RavenDB\Server\Database\System\Data ---> Microsoft.Isam.Esent.Interop.E
sentSecondaryIndexCorruptedException: Secondary index is corrupt. The database must be defragmented
   at Raven.Storage.Esent.TransactionalStorage.EnsureDatabaseIsCreatedAndAttachToDatabase() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Storage\Esent\Tran
sactionalStorage.cs:line 385
   at Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection`1 documentCodecs) in c:\Builds\RavenDB-Unstable-v1
.2\Raven.Database\Storage\Esent\TransactionalStorage.cs:line 296
   --- End of inner exception stack trace ---
   at Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection`1 documentCodecs) in c:\Builds\RavenDB-Unstable-v1
.2\Raven.Database\Storage\Esent\TransactionalStorage.cs:line 309
   at Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\DocumentDatabase.cs:line
 201
   at Raven.Server.RavenDbServer..ctor(RavenConfiguration settings)
   at Raven.Server.Program.RunServerInDebugMode(RavenConfiguration ravenConfiguration, Boolean lauchBrowser)
   at Raven.Server.Program.RunInDebugMode(Nullable`1 anonymousUserAccessMode, RavenConfiguration ravenConfiguration, Boolean launchBrowser)
   at Raven.Server.Program.<>c__DisplayClass24.<InteractiveRun>b__11()
   at Raven.Server.Program.InteractiveRun(String[] args)
   at Raven.Server.Program.Main(String[] args)

I can quite easily recreate the database from scratch since it's just my own demo data at the moment, but I wondered if you would be interested in troubleshooting the failure anyway, in case it happens to someone's production data?

If so - let me know what I can provide to help.

Cheers,
Darren. 

Darren Bruning

unread,
Nov 8, 2012, 7:55:59 AM11/8/12
to rav...@googlegroups.com
Yep that did the trick.

For any harried sysadmins reading this post in the future, I had to :
1) stop the Raven service
2) run command prompt as administrator
3) cd C:\Program Files\RavenDB\Server\Database\System
4) esentutl /d Data

System database was very quickly defragmented (<1s), and I could then restart Raven.Server and use the Raven Studio - but my application database had the same issue, so I also had repeat steps 1-4 but with my application's data directory (C:\Program Files\RavenDB\Server\Database\Databases\<appname>)

Thanks for the quick reply Oren.

Chris Marisic

unread,
Nov 8, 2012, 8:08:56 AM11/8/12
to rav...@googlegroups.com
Ayende, you might want to package a small util either app or even powershell file that will iterate all databases instead of a user manually having to invoke it. Perhaps even prompting for each database whether you want it to defrag it, along with an optional flag to run silent and just do it.

Oren Eini (Ayende Rahien)

unread,
Nov 8, 2012, 8:40:24 AM11/8/12
to rav...@googlegroups.com
Can you create an issue for that?

Chris Marisic

unread,
Nov 8, 2012, 8:59:15 AM11/8/12
to rav...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages