locked
WebSharing SQL End2End - DbSyncException was unhandled, The process cannot access the file RRS feed

  • Question

  • Hi,

    I ran into a problem in testing out the WebSharing SQL End2End demo. I was able to get batching working from peer1 to peer2 (with peer2 being behind the web service) but when I try to batch updates from peer2 to peer1 I get the following error:

    Microsoft.Synchronization.Data.DbSyncException was unhandled
      Message="An unexpected error occurred when applying batch file C:\\TempBatchTest\\WebSync_8c834a1a43a04745b3890545bc985e8f\\5a406e41-2c10-437d-b5fd-2078687e79cc.batch. See the inner exception for more details."

    Inner exception:

    The process cannot access the file 'C:\\TempBatchTest\\WebSync_8c834a1a43a04745b3890545bc985e8f\\5a406e41-2c10-437d-b5fd-2078687e79cc.batch' because it is being used by another process.

    The debugger stops at the SyncOrchestrator.Synchronize() line.

    Any help is appreciated!

    Thanks


    * Note: I have no formal CS education, so take all advice with caution :)
    Thursday, March 18, 2010 8:38 PM

Answers

  • Hi,

    I can repro this failure on my test environment as well. It is a bug in the sample code. Thanks for finding it, and we will update the sample with the fix.

    In the meantime, you can fix it in the sample with just one line change:

    In file RelationalProviderProxy.cs, Change below line in method GetChangeBatch(...)

    From

                    if (!localFileInfo.Exists)

    To

                    if (localFileInfo.Exists)

    Thanks,
    Dong

     


    This posting is provided AS IS with no warranties, and confers no rights.
    Wednesday, March 24, 2010 12:21 AM

All replies

  • I also just noticed that I get the same error if all I do is simply swap peers (on the drop down make peer1 peer2 etc) and add a batch size.
    * Note: I have no formal CS education, so take all advice with caution :)
    Friday, March 19, 2010 1:05 PM
  • Could it be because I am running this all on one computer? Perhaps if I deploy the web services to another machine it will work. The only problem is that for this example I am able to deploy the WCF service but I cannot figure out how to point my local copy to the newly deployed web service.
    * Note: I have no formal CS education, so take all advice with caution :)
    Friday, March 19, 2010 1:34 PM
  • you can modify the url for the WCF service in the CommonUtils project->SqlCreationUtilities.cs->SyncUtils class

    modify the http://localhost entries to point to your new WCF service location.

    Friday, March 19, 2010 2:08 PM
  • Thanks, just did that and now getting this error:


    {"Security Support Provider Interface (SSPI) authentication failed. The server may not be running in an account with identity 'host/wbohdecomcr01'. If the server is running in a service account (Network Service for example), specify the account's ServicePrincipalName as the identity in the EndpointAddress for the server. If the server is running in a user account, specify the account's UserPrincipalName as the identity in the EndpointAddress for the server."}

    trying to work through it now... If I look in the task manager of the server I deployed it to it says the service is running as me.

     


    * Note: I have no formal CS education, so take all advice with caution :)
    Friday, March 19, 2010 2:24 PM
  • how did you deploy the service on the other machine?
    Friday, March 19, 2010 3:04 PM
  • I used click once and it published it as a console app. I'm not sure how else to do it as there are no .svc file in the service project.
    * Note: I have no formal CS education, so take all advice with caution :)
    Friday, March 19, 2010 3:12 PM
  • try this:

    open the app.config of the service, locate <identity><dns value="localhost" /> </identity>, replace <dns value="localhost"/> with <UserPrincipalName/>

    Friday, March 19, 2010 3:20 PM
  • I tried that, plus a few different ways but no dice. Did it work for you?

     


    * Note: I have no formal CS education, so take all advice with caution :)
    Friday, March 19, 2010 3:39 PM
  • cant really test it, am running Win7/64bit and am having all these weird issues now with VS, IIS and other 64bit stuff after installing some beta products.

    have you tried passing including a username in the userPrincipalName? or tried using servicePrinciplaName instead?

     

     

    Friday, March 19, 2010 3:45 PM
  • I just came off a SL project using all beta 4.0/WCF RIA services stuff so I can relate.

    Yes, I tried all sorts of things for the userPrincipalName, but wil ltry again maybe I missed soemthing.


    * Note: I have no formal CS education, so take all advice with caution :)
    Friday, March 19, 2010 3:48 PM
  • if you're in a hurry to test SyncFx, you can simply change way it connects to SQL to use SQL Authentication instead of Windows authentication.
    Friday, March 19, 2010 3:58 PM
  • I suspect it's not even reading the app.config because the service is created via code.

            protected override void CreateProxy()
            {
                WSHttpBinding binding = new WSHttpBinding();
                binding.ReaderQuotas.MaxArrayLength = 1000000;
                binding.MaxReceivedMessageSize = 10485760;
                ChannelFactory<ISqlSyncContract> factory = new ChannelFactory<ISqlSyncContract>(binding, new EndpointAddress(SyncUtils.SqlSyncServiceUri));
                base.proxy = factory.CreateChannel();
                this.dbProxy = base.proxy as ISqlSyncContract;
            }

    * Note: I have no formal CS education, so take all advice with caution :)
    Friday, March 19, 2010 4:00 PM
  • No wonder the  changes in app.config dont get picked up. you can just modify it to specify a credentials then.
    Friday, March 19, 2010 4:11 PM
  • I'm very much at a loss... cant get this working. It seems like every time I fix a problem with this SDK another one crops up.

    One thing I may have misunderstood is deployment. Now that I think about it is this solution meant to be deployed in it's entirety to each peer? For example if I have 450 computers that need to sync would they all be running thier own WCF service?


    * Note: I have no formal CS education, so take all advice with caution :)
    Friday, March 19, 2010 7:49 PM
  • Hi,

    I tried the WebSharing SQL End2End sample following your steps, but it worked well and cannot repro your failure. Please check if you can repro it on different machines. One possible cause is that this particular machine has some anti-virus or local disk file scan tool running such as Etrust. This kind of software will hold the new created files for a short period time that may block following file read. You may want to check which process is holding the batch file.

    Also, the batching directory (c:\TempBatchTest) on your WCF service side is not the default current user temp directory. I wonder if you made some code changes in the sample. Please make sure that you didn't introduce any bugs as well.

    To deployment this application on two machines, you need to ensure that your WCF wsHttpBinding can pass the authentication check. One easy way to do it is to logon both machines with the exact same login and password.

    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Saturday, March 20, 2010 12:07 AM
  • I checked and the only process with a handle on the file is the app itself. I've been changing it to that temp directory through the UI so no problem there. I also just tried it on a testing virtual machine we use with the same error. I am running win XP pro SP3 on my local workstation and Windows Server 2008 Std SP2 on the virtual machines. I appreciate all the help but were going to shelf this SDK for now as we ran out of time and go back to working on the offline mode POC.

    As a side note we were discussing the different batching models between offline and collaboration and although it seems that the file based caching with collaboration is better but we don’t like that it is all handled by one transaction. With offline mode the batched are measured by rows and each batch has its own transaction so when something fails it doesn't have to start over from scratch.


    * Note: I have no formal CS education, so take all advice with caution :)
    Monday, March 22, 2010 3:12 PM
  • Hi,

    If you just changed the temp directory through the UI, only local batching files will be written to this temp directory. You should see new Folders like "sync_***" be created. For your error, you mentioned that folder named as "Websync_***" were created under this temp folder instead. It means the remote WCF Service wrote batching files to this directory. If you didn't change the code, have you reset your default temp directory path?  Unfortunately, I cann't repro your failures with the same sample. If you can share me your sample project and the exact repro steps, I will try it again.

    Regarding the all changes in one transaction, thanks for your feedback, and we are current working the next release that enables multiple transactions in one sync.

     

    Thanks,

    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Monday, March 22, 2010 6:17 PM
  • Thanks Dong,

    I started from scratch on the alternate machine and literally the only thing I changed was the following:

            /// <summary>
            ///  Gererate a SQL Connection string.
            /// </summary>
            /// <param name="hostName"></param>
            /// <param name="databaseName"></param>
            /// <param name="userName"></param>
            /// <param name="password"></param>
            /// <param name="useTrustConnection"></param>
            /// <returns></returns>
            public static string GenerateSqlConnectionString(string hostName, string databaseName, string userName, string password, bool useTrustConnection)
            {
                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
                builder.DataSource = hostName + \\SQLEXPRESS;

     And:

            //[OperationContract(IsOneWay = true)]
            [OperationContract]
            void UploadBatchFile(string batchFileid, byte[] batchFile, string remotePeerId);

    To reproduce I just click on the Add Sql Peer to provision a new DB, fill in a batch size (that I know will actually require batches) then on the bottom switch the source provider from Peer1 to Peer2.

    And thanks about the transactions, that would be really great!

     


    * Note: I have no formal CS education, so take all advice with caution :)
    Monday, March 22, 2010 9:48 PM
  • Hi,

    I can repro this failure on my test environment as well. It is a bug in the sample code. Thanks for finding it, and we will update the sample with the fix.

    In the meantime, you can fix it in the sample with just one line change:

    In file RelationalProviderProxy.cs, Change below line in method GetChangeBatch(...)

    From

                    if (!localFileInfo.Exists)

    To

                    if (localFileInfo.Exists)

    Thanks,
    Dong

     


    This posting is provided AS IS with no warranties, and confers no rights.
    Wednesday, March 24, 2010 12:21 AM
  • Thanks Dong,

    This was a great help. Sorry it took me so long to respond as we got a new architect and he would rather we use MSMQ to do the sync so I have been looking into that. I'm a sync fan and the support is terrific so I was dissapointed to say the least. btw - this was to be used for a retail point of sale application with about 450 stores.

     

     


    * Note: I have no formal CS education, so take all advice with caution :)
    Friday, March 26, 2010 2:56 PM