1

バッチ処理を使用して、WCF (N 層) 経由で同期フレームワーク 2.1 を使用して、2 つのリモート データベース (Sql Express と Sql Compact) を同期します。

最近このログファイルを受け取りました。これはごくまれに発生するエラーですが、発生すると多くの問題が発生します (失敗したこの同期スコープに含まれるデータのテーブルが削除されたようです)。誰もBatchingDirectoryをいじっていないので、そこにあり、すべてのデータが含まれているはずです。以下のエラーは、私が持っているという事実に関連している可能性があります

CleanupBatchingDirectory = true

これは、変更が適用される前に削除されますか?

11/06/2012 14:16:49 Error ** :PosPosSync:ThreadId=7: **: 
SyncScope ErpProduct  failed
Message: An unexpected error occurred when applying batch file C:\Documents and Settings\kasse6\Application Data\POSSyncDataClient\PosSync_5b009e9008c14d0ba6a9e47726d8d620\4e77ef8c-3045-4c55-809f-014ae2b96155.batch. See the inner exception for more details.
Type   : Microsoft.Synchronization.Data.DbSyncException
Stack  :    at Microsoft.Synchronization.Data.DbSyncBatchConsumer.ApplyBatches(DbSyncScopeMetadata scopeMetadata, DbSyncSession syncSession, SyncSessionStatistics sessionStatistics)
   at Microsoft.Synchronization.Data.RelationalSyncProvider.ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, Object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics)
   at Microsoft.Synchronization.KnowledgeProviderProxy.ProcessChangeBatch(CONFLICT_RESOLUTION_POLICY resolutionPolicy, ISyncChangeBatch pSourceChangeManager, Object pUnkDataRetriever, ISyncCallback pCallback, _SYNC_SESSION_STATISTICS& pSyncSessionStatistics)
   at Microsoft.Synchronization.CoreInterop.ISyncSession.Start(CONFLICT_RESOLUTION_POLICY resolutionPolicy, _SYNC_SESSION_STATISTICS& pSyncSessionStatistics)
   at Microsoft.Synchronization.KnowledgeSyncOrchestrator.DoOneWaySyncHelper(SyncIdFormatGroup sourceIdFormats, SyncIdFormatGroup destinationIdFormats, KnowledgeSyncProviderConfiguration destinationConfiguration, SyncCallbacks DestinationCallbacks, ISyncProvider sourceProxy, ISyncProvider destinationProxy, ChangeDataAdapter callbackChangeDataAdapter, SyncDataConverter conflictDataConverter, Int32& changesApplied, Int32& changesFailed)
   at Microsoft.Synchronization.KnowledgeSyncOrchestrator.DoOneWayKnowledgeSync(SyncDataConverter sourceConverter, SyncDataConverter destinationConverter, SyncProvider sourceProvider, SyncProvider destinationProvider, Int32& changesApplied, Int32& changesFailed)
   at Microsoft.Synchronization.KnowledgeSyncOrchestrator.Synchronize()
   at Microsoft.Synchronization.SyncOrchestrator.Synchronize()
   at PosPosSync.Local.PosPosSyncService.SynchronizeProviders(KnowledgeSyncProvider localProvider, KnowledgeSyncProvider remoteProvider, SyncDirectionOrder syncDirectionOrder)
   at PosPosSync.Local.PosPosSyncService.SyncronizeData(String scopeName, SyncDirectionOrder syncDirectionOrder)
Source : Microsoft.Synchronization
Target : Void Start(CONFLICT_RESOLUTION_POLICY, _SYNC_SESSION_STATISTICS ByRef)
------- Inner Exception ------
    Message: Could not find a part of the path 'C:\Documents and Settings\kasse6\Application Data\POSSyncDataClient\PosSync_5b009e9008c14d0ba6a9e47726d8d620\4e77ef8c-3045-4c55-809f-014ae2b96155.batch'.
    Type   : System.IO.DirectoryNotFoundException
    Stack  :    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)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode)
   at Microsoft.Synchronization.Data.DbSyncBatchInfoFactory.Deserialize(String batchFileName, Boolean deserializeData)
   at Microsoft.Synchronization.Data.DbSyncBatchConsumer.ReadBatchFile(UInt32 lookupLocation, UInt32 expectedNumber)
   at Microsoft.Synchronization.Data.DbSyncBatchConsumer.ReadBatchFile(UInt32 expectedNumber, String& batchFileName)
   at Microsoft.Synchronization.Data.DbSyncBatchConsumer.ApplyBatches(DbSyncScopeMetadata scopeMetadata, DbSyncSession syncSession, SyncSessionStatistics sessionStatistics)
    Source : mscorlib
    Target : Void WinIOError(Int32, System.String)

しばらくすると、すべてのデータを再度同期しようとし、私が持っているログ情報に基づいて、クライアントからサーバーにすべてをダウンロードしているようです:

11/06/2012 14:26:02 Info ** :PosPosSync:ThreadId=7: **: 
EndSync: ScopeName: ErpProduct
DownloadChanges: Applied - Failed: 122363 - 0
UploadChanges: Applied - Failed:  0 - 0
FinishedSync: ElapsedTime, sec: 545,0086488
4

2 に答える 2

0

クライアントでSqlSyncProvider.MemoryDataCacheSize (バッチ サイズ) を変更してみてください。

バッチ サイズを 100kb に設定すると、クライアントの Synchronize がDirectoryNotFoundExceptionをスローしていました。通常は 500kb を実行します。これは、大規模な同期 (大規模なデータベースの初期同期など) でのみ見られました。後続の同期は、小さいほど正常に機能しました)。

アップデート

MS Documentationによると、問題はデータベース行がMemoryDataCacheSizeの 110% を超えていることが原因である可能性があります。

アプリケーションは、同期セッションに参加している各プロバイダのメモリ データ キャッシュ サイズを指定します。両方のプロバイダーでキャッシュ サイズが指定されている場合、Sync Framework は両方のプロバイダーに対して小さい方の値を使用します。実際のキャッシュ サイズは、指定された最小サイズの 110% 以下になります。同期セッション中に、1 つの行がサイズの 110% を超えると、セッションは例外で終了します。

于 2014-05-14T14:11:25.887 に答える
0

同様の問題と数年間戦った後、ようやく解決策を見つけたと思います。

この「パスの一部が見つからない」問題は、複数のスコープが定義されている場合 (およびスコープがバッチ処理を使用するのに十分な大きさである場合) にも発生する可能性があります。これは、MS のサンプル コードにマイナーなバグがあるためです。問題は SqlWebSyncService の Dispose にあります。このセッションのバッチ フォルダーが削除されていますが、ディレクトリ情報変数が null に設定されていません (これは、次のスコープがフォルダーを作成しているかどうかを確認するために使用するテストです)。バッチ ディレクトリを null に設定すると、この問題が修正されます。CheckAndCreateBatchingDirectory を実行すると、バッチ ディレクトリが null として検出され、その作成が行われるためです。

private void Dispose(bool disposing)
{
try
{
    if (!this.m_disposed)
    {
        if (disposing)
        {
            if (this.m_ServerProvider != null)
            {
                this.m_ServerProvider.Dispose();
                this.m_ServerProvider = null;
            }
            if (this.m_SessionBatchingDirectory != null)
            {
                this.m_SessionBatchingDirectory.Refresh();
                if (this.m_SessionBatchingDirectory.Exists)
                {
                    try
                    {
                        this.m_SessionBatchingDirectory.Delete(true);
                    }
                    catch
                    {
                    }
                }
                this.m_SessionBatchingDirectory = null;
            }
        }
        this.m_disposed = true;
    }
}
catch (Exception exception)
{
    string message = "SqlWebSyncService Cleanup Exception: " + exception;
    LogWriter.TraceError(message, new object[0]);
    throw new FaultException<WebSyncFaultException>(new WebSyncFaultException(message, exception));
}
}

クライアントでも同様に SqlSyncProviderProxy.EndSession

...
if (this.m_LocalBatchingDirectory != null) 
{
    this.m_LocalBatchingDirectory.Refresh();
    if (this.m_LocalBatchingDirectory.Exists) 
    {
       this.m_LocalBatchingDirectory.Delete(true);
    }
    this.m_LocalBatchingDirectory = null;
}
...

この動作は、バッチ サイズを変更したときに現れます。バッチ サイズを 70000 に大きく設定したところ、問題が解決したことがわかりました。後から考えると、これは最初のスコープがすべて 1 つのバッチに収まるため、ばらばらになってバッチ処理を実装することはありませんでした。サイズを小さく設定すると、最初のスコープ (1/3) でバッチ処理が使用され、スコープ 2 が起動したときにこれが表示されます。

于 2016-07-26T20:30:06.977 に答える