Exemple #1
0
        public async Task RunConflictResolversOnce(ConflictSolver solver, long index)
        {
            // update to larger index;
            if (ThreadingHelper.InterlockedExchangeMax(ref _processedRaftIndex, index) == false)
            {
                return;
            }

            try
            {
                using (await RunOnceAsync())
                {
                    if (Interlocked.Read(ref _processedRaftIndex) > index)
                    {
                        return;
                    }

                    UpdateScriptResolvers(solver);

                    if (ConflictsCount > 0 && solver?.IsEmpty() == false)
                    {
                        await ResolveConflictsInBackground(solver);
                    }
                }
            }
            catch (OperationCanceledException)
            {
                // shutdown
            }
            catch (ObjectDisposedException)
            {
                // shutdown
            }
            catch (Exception e)
            {
                if (_log.IsInfoEnabled)
                {
                    _log.Info("Failed to wait for a previous task of automatic conflict resolution", e);
                }
            }
        }