RavenDB 3 - EmbeddableDocumentStore - FileNotFoundException "segments.gen"

280 views
Skip to first unread message

Daniel Häfele

unread,
Sep 16, 2014, 8:36:30 AM9/16/14
to rav...@googlegroups.com
I was trying out RavenDB 3 in with the embeddable document store, but on the call to "Initialize" I get a FileNotFoundException for the file "\Databases\MyDatabase\Indexes\1\segments.gen".
It is working on the second run then.

For reference: I'm using the build 3487 of the RavenDB.Database package on MyGet.
This is my code:

var documentStore = new EmbeddableDocumentStore
{
    DefaultDatabase = "MyDatabase"
};
documentStore.Initialize();

And here is the exception:

The file "MyApplicationRoot\bin\Debug\Databases\MyDatabase\Indexes\1\segments.gen" could not be found.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 
at System.IO.FileInfo.Open(FileMode mode, FileAccess access, FileShare share) 
at Raven.Database.Indexing.LuceneCodecDirectory.CodecIndexInput..ctor(FileInfo file, Func`2 applyCodecs, Int32 bufferSize) in c:\Builds\RavenDB-3.0-PreRelease\Raven.Database\Indexing\LuceneCodecDirectory.cs:Line 119. 
at Raven.Database.Indexing.LuceneCodecDirectory.OpenInputInner(String name, Int32 bufferSize) in c:\Builds\RavenDB-3.0-PreRelease\Raven.Database\Indexing\LuceneCodecDirectory.cs:Line 30. 
at Raven.Database.Indexing.LuceneCodecDirectory.OpenInput(String name, Int32 bufferSize) in c:\Builds\RavenDB-3.0-PreRelease\Raven.Database\Indexing\LuceneCodecDirectory.cs:Line 24.
   at Lucene.Net.Store.FSDirectory.OpenInput(String name) 
at Lucene.Net.Index.SegmentInfos.FindSegmentsFile.Run(IndexCommit commit)

Thanks in advance.
Daniel Häfele

Oren Eini (Ayende Rahien)

unread,
Sep 16, 2014, 12:55:10 PM9/16/14
to ravendb
That is expected, and is caught by RavenDB and handled.



Oren Eini

CEO


Mobile: + 972-52-548-6969

Office:  + 972-4-622-7811

Fax:      + 972-153-4622-7811




--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Peterson

unread,
Oct 7, 2015, 5:06:32 PM10/7/15
to RavenDB - 2nd generation document database
Oren,
This exception also seems to be thrown when using the RavenTestBase.NewRemoteDocumentStore method (found in the RavenDB.Tests.Helpers NuGet package). As a team, we typically have Just My Code enabled, and we typically want to break on all user-unhandled exceptions to ensure we don't miss any exceptions that our own application might throw.

Can you provide any more insight as to why this FileNotFoundException for "segments.gen" occurs and what we should do to prevent it?

Thanks,
-- Michael Peterson

PS: The stack trace we are seeing for this exception suggests that it is also unhandled in Raven.Database.dll. When you say that the exception is caught and handled by RavenDB, is it really being handled by ASP.NET's top-level exception handler?

PPS: We are using build 3.0.3800.

Chris Marisic

unread,
Oct 7, 2015, 5:28:55 PM10/7/15
to RavenDB - 2nd generation document database
That sounds like you're breaking on all thrown exceptions. Just exclude that one from thrown exceptions.  If it's unhandled all of raven would be broken. 

Michael Peterson

unread,
Oct 7, 2015, 5:45:31 PM10/7/15
to RavenDB - 2nd generation document database
Chris,
If you are referring to the settings found in Debug -> Exceptions..., I can assure you that I am not breaking on all thrown exceptions. In fact, when we do check the "Thrown" column for the System.IO.FileNotFoundException, it shows that the exception is originally thrown in mscorlib.dll. Is there another setting you are perhaps referring to?

Thanks,
-- Michael Peterson

Oren Eini (Ayende Rahien)

unread,
Oct 8, 2015, 4:17:58 AM10/8/15
to ravendb
What is the stack trace you are seeing?

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--

Michael Peterson

unread,
Oct 8, 2015, 11:42:50 AM10/8/15
to RavenDB - 2nd generation document database
Oren,

The exception actually seems to occur a couple of times during the call to NewRemoteDocumentStore. Here is one of the stack traces:

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileInfo.get_Length()
at Raven.Database.Indexing.LuceneCodecDirectory.CodecIndexInput..ctor(FileInfo file, Func`2 applyCodecs) in c:\Builds\RavenDB-Stable-3.0\Raven.Database\Indexing\LuceneCodecDirectory.cs:line 284
at Raven.Database.Indexing.LuceneCodecDirectory.OpenInputInner(String name) in c:\Builds\RavenDB-Stable-3.0\Raven.Database\Indexing\LuceneCodecDirectory.cs:line 43
at Raven.Database.Indexing.LuceneCodecDirectory.OpenInput(String name, Int32 bufferSize) in c:\Builds\RavenDB-Stable-3.0\Raven.Database\Indexing\LuceneCodecDirectory.cs:line 37

at Lucene.Net.Store.FSDirectory.OpenInput(String name)
at Lucene.Net.Index.SegmentInfos.FindSegmentsFile.Run(IndexCommit commit)

And here is what the Call Stack window shows:

Raven.Database.dll!Raven.Database.Indexing.LuceneCodecDirectory.CodecIndexInput.CodecIndexInput(System.IO.FileInfo file, System.Func<System.IO.Stream,System.IO.Stream> applyCodecs) Line 284
Raven.Database.dll!Raven.Database.Indexing.LuceneCodecDirectory.OpenInputInner(string name) Line 43
Raven.Database.dll!Raven.Database.Indexing.LuceneCodecDirectory.OpenInput(string name, int bufferSize) Line 37
[External Code]
Raven.Database.dll!Raven.Database.Indexing.IndexStorage.OpenOrCreateLuceneDirectory(Raven.Abstractions.Indexing.IndexDefinition indexDefinition, bool createIfMissing) Line 444
Raven.Database.dll!Raven.Database.Indexing.IndexStorage.OpenIndexOnStartup(string indexName) Line 185
Raven.Database.dll!Raven.Database.Indexing.DefaultBackgroundTaskExecuter.ExecuteAllInterleaved<string>(Raven.Database.Indexing.WorkContext context, System.Collections.Generic.IList<string> result, System.Action<string> action) Line 139
Raven.Database.dll!Raven.Database.Indexing.IndexStorage.IndexStorage(Raven.Database.Storage.IndexDefinitionStorage indexDefinitionStorage, Raven.Database.Config.InMemoryRavenConfiguration configuration, Raven.Database.DocumentDatabase documentDatabase) Line 147
Raven.Database.dll!Raven.Database.DocumentDatabase.DocumentDatabaseInitializer.InitializeIndexStorage() Line 1342
Raven.Database.dll!Raven.Database.DocumentDatabase.DocumentDatabase(Raven.Database.Config.InMemoryRavenConfiguration configuration, Raven.Database.Server.Connections.TransportState recievedTransportState) Line 193
Raven.Database.dll!Raven.Database.Server.Tenancy.DatabasesLandlord.TryGetOrCreateResourceStore.AnonymousMethod__8() Line 169
[External Code]

I can provide another stack trace (from the other time the exception is thrown), if you think it would help.

Thanks,
-- Michael Peterson

Oren Eini (Ayende Rahien)

unread,
Oct 8, 2015, 5:19:31 PM10/8/15
to ravendb
Yes, this is handled internally, and you are catching it because we deploy with PDB, probably.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--

Michael Peterson

unread,
Oct 9, 2015, 11:49:14 AM10/9/15
to RavenDB - 2nd generation document database
Oren,
We have confirmed that removing the PDB files out of the NuGet package (which prevents the PDBs from getting into our bin/Debug folder) prevents this exception while debugging. Are you suggesting that if we want to avoid breaking on this exception, while still breaking on our own possible FileNotFoundExceptions, that we need to remember to remove these PDB files any time we update Raven? This is not very convenient, especially when our whole team is considered. Is there no programmatic way to prevent this exception?

-- Michael Peterson

Oren Eini (Ayende Rahien)

unread,
Oct 11, 2015, 5:55:34 AM10/11/15
to ravendb
It isn't preventing the exception, it just stops VS from stopping on it.
The issue is how you define "Just My Code" in VS. See here:

We include PDBs in the build because that make troubleshooting much easier.

Note that the exception is always going to happen, it is how RavenDB works, and it is properly handled internally.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--

Michael Peterson

unread,
Oct 12, 2015, 5:59:08 PM10/12/15
to RavenDB - 2nd generation document database
Oren,
You are right. I misspoke when I said that the exception is prevented (I actually meant to say what you said, which is that removing the PDB files prevents VS from breaking on the exception). Also, thank you for linking that article. It was useful to better understand "Just My Code".

It is unfortunate that the exception is always going to happen though. I suppose I will inform the team I work with that removing the PDB files is the best way (in our case) to prevent VS from breaking on that exception.

Thanks,
-- Michael Peterson
Reply all
Reply to author
Forward
0 new messages