RavenDb Embedded backup fails on Windows Azure Web Site with “Cannot create a file when that file already exists” even though it used to work

75 views
Skip to first unread message

Christophe Gijbels

unread,
Apr 14, 2014, 5:30:56 PM4/14/14
to rav...@googlegroups.com

Hi 
I'm running RavenDb.Embedded v2.0.2370 inside an Azure Web site. 
All of this is working as expected except for the backup. The backup routine initiated with EmbeddableDocumentStore.DocumentDatabase.StartBackup(...) used to work perfectly until I noticed that the last successful backup dates from around the 30th of January (don't ask :-)) around 6 PM UTC0 and that the next backup initiated on the 11th of February around 8 AM UTC0 failed, as do all the other ones initiated afterwards up until now. There have been no changes or deployments since May 2013.
Further investigation points the issue into the direction of the Raven.Database.Backup.DirectoryBackup.Prepare method that makes a call to CreateHardLink inside kernel32.dll 
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] 
private static extern bool CreateHardLink(string lpFileName, string lpExistingFileName, IntPtr lpSecurityAttributes); 
Which then results in the Win32Exception  “Cannot create a file when that file already exists” even though it used to work
I have more details in the original Stack Overflow question which I did not post in here due to formatting 
So basically this seems to be an Azure specific issue with the CreateHardLink, but on the other hand it is being triggered by the RavenDb backup routine. 

So the question is, why has this stopped working and more importantly what can I do to make the backups work again on my Azure Web site?


Thanks for any feedback

Christophe

Oren Eini (Ayende Rahien)

unread,
Apr 15, 2014, 2:09:00 PM4/15/14
to ravendb
I think that you need to talk with Azure support about this.
CreateHardLink is a Win32 api and should be supported.
The docs don't mention any exemption for Azure.




Oren Eini

CEO

Mobile: + 972-52-548-6969

Office:  + 972-4-674-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.

Christophe Gijbels

unread,
Apr 16, 2014, 5:31:21 PM4/16/14
to rav...@googlegroups.com
Hi Oren

The SO question got answered and it seems like a bug in Azure Web Sites.

In short: you can't use a relative path like ~\App_Data\RavenDb as datadir as it will be mapped to a folder starting with D:\Home , but that folder doesn't actually exist on the machine;  Azure Websites fakes it for convenience and that seems to be causing the issue with the CreateHardLink function. 

The solution is to set the datadir to  C:\DWASFiles\Sites\sitename\VirtualDirectory0\site\wwwroot\App_Data\RavenDb although the question remains how stable that path will remain until they fix (if at all) the bug.

Cheers,
Christophe

Op dinsdag 15 april 2014 20:09:00 UTC+2 schreef Oren Eini:

Jahmai Lay

unread,
Apr 17, 2014, 12:04:11 AM4/17/14
to rav...@googlegroups.com

FYI back when I was hosting Raven inside an Azure Worker role I would go through the RavenDB system database force set all the DataDir paths because occasionally it would change from E: to F: and so on, which worked fine.
I believe there are a few environment variables that define site root etc in Azure websites that you could use.
Reply all
Reply to author
Forward
0 new messages