public void UpdateLastLogGeneratedAndEndOfLogInfo(long highestLogGen)
        {
            ActiveManagerCore.SetLastLogGenerationNumber(this.DatabaseGuid, highestLogGen);
            MonitoredDatabase monitoredDatabase = MonitoredDatabase.FindMonitoredDatabase(this.ServerName, this.DatabaseGuid);

            if (monitoredDatabase != null)
            {
                monitoredDatabase.UpdateCurrentEndOfLog(highestLogGen, true);
            }
        }
        public static void MarkRedeliveryRequired(ReplayConfiguration configuration, DateTime failoverTimeUtc, DateTime startTimeUtc, DateTime endTimeUtc, long lastLogGenBeforeActivation, long numLogsLost)
        {
            SafetyNetRedelivery.Tracer.TraceDebug(0L, "MarkRedeliveryRequired() for {0}({1}) called: failoverTimeUtc={2}, startTimeUtc={3}, endTimeUtc={4}, lastLogGenBeforeActivation={5}, numLogsLost={6}", new object[]
            {
                configuration.Name,
                configuration.Identity,
                failoverTimeUtc,
                startTimeUtc,
                endTimeUtc,
                lastLogGenBeforeActivation,
                numLogsLost
            });
            if (endTimeUtc < startTimeUtc)
            {
                SafetyNetRedelivery.Tracer.TraceError <string, string>(0L, "MarkRedeliveryRequired() for {0}({1}) failed because endTimeUtc should not be less than startTimeUtc", configuration.Name, configuration.Identity);
                DiagCore.AssertOrWatson(false, "endTimeUtc ({0}) should not be less than startTimeUtc ({1}) !", new object[]
                {
                    endTimeUtc,
                    startTimeUtc
                });
                throw new DumpsterInvalidResubmitRequestException(configuration.DatabaseName);
            }
            TimeSpan timeSpan  = endTimeUtc.Subtract(startTimeUtc);
            TimeSpan timeSpan2 = TimeSpan.FromSeconds((double)RegistryParameters.DumpsterRedeliveryMaxTimeRangeInSecs);

            if (timeSpan > timeSpan2)
            {
                SafetyNetRedelivery.Tracer.TraceError(0L, "MarkRedeliveryRequired() for {0}({1}) failed because the request window ({2}) is larger than the maximum allowed of {3}", new object[]
                {
                    configuration.Name,
                    configuration.Identity,
                    timeSpan,
                    timeSpan2
                });
                throw new DumpsterInvalidResubmitRequestException(configuration.DatabaseName);
            }
            string text;

            ActiveManagerCore.GetDatabaseMountStatus(configuration.IdentityGuid, out text);
            SafetyNetInfo      safetyNetInfo  = new SafetyNetInfo(text, lastLogGenBeforeActivation, numLogsLost, failoverTimeUtc, startTimeUtc, endTimeUtc);
            SafetyNetInfoCache safetyNetTable = configuration.ReplayState.GetSafetyNetTable();

            safetyNetTable.Update(safetyNetInfo);
            ReplayEventLogConstants.Tuple_DatabaseDumpsterRedeliveryRequired.LogEvent(null, new object[]
            {
                configuration.DatabaseName,
                startTimeUtc,
                endTimeUtc
            });
            ReplayCrimsonEvents.DumpsterRedeliveryRequired.Log <string, Guid, string, long, long, DateTime, DateTime, DateTime, bool, bool>(configuration.DatabaseName, configuration.IdentityGuid, text, lastLogGenBeforeActivation, numLogsLost, failoverTimeUtc, startTimeUtc, endTimeUtc, false, true);
        }
        internal static void HandleSourceLogCorruption(IADDatabase database, string from)
        {
            Exception            ex = null;
            AmDatabaseMoveResult amDatabaseMoveResult = null;

            DatabaseTasks.Trace("HandleSourceLogCorruption for Database '{0}' from '{1}'", new object[]
            {
                database.Name,
                from
            });
            ReplayEventLogConstants.Tuple_CorruptLogRecoveryIsAttempted.LogEvent(null, new object[]
            {
                database.Name
            });
            try
            {
                AmDbActionCode actionCode = new AmDbActionCode(AmDbActionInitiator.Automatic, AmDbActionReason.FailureItem, AmDbActionCategory.Move);
                string         text;
                AmRpcClientHelper.MoveDatabaseEx(database, 0, 0, RegistryParameters.MaxAutoDatabaseMountDial, from, null, true, 0, actionCode, "HandleSourceLogCorruption", out text, ref amDatabaseMoveResult);
            }
            catch (AmServerException ex2)
            {
                ex = ex2;
            }
            catch (AmServerTransientException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                DatabaseTasks.Tracer.TraceError <Exception>(0L, "HandleSourceLogCorruption: Move failed: {0}", ex);
            }
            bool      flag = false;
            Exception ex4  = null;

            try
            {
                string text2;
                ActiveManagerCore.GetDatabaseMountStatus(database.Guid, out text2);
                if (!string.IsNullOrEmpty(text2) && !Cluster.StringIEquals(text2, Dependencies.ManagementClassHelper.LocalMachineName))
                {
                    flag = true;
                }
            }
            catch (ClusterException ex5)
            {
                ex4 = ex5;
            }
            catch (AmServerException ex6)
            {
                ex4 = ex6;
            }
            if (ex4 != null)
            {
                DatabaseTasks.Tracer.TraceError <Exception>(0L, "HandleSourceLogCorruption: Determine active failed: {0}", ex4);
                if (ex == null)
                {
                    ex = ex4;
                }
            }
            if (flag)
            {
                Exception ex7 = DatabaseTasks.ResumeLocalDatabaseCopy(database);
                if (ex7 != null)
                {
                    DatabaseTasks.Tracer.TraceError <Exception>(0L, "HandleSourceLogCorruption: Resume failed: {0}", ex7);
                    ReplayEventLogConstants.Tuple_ResumeFailedDuringFailureItemProcessing.LogEvent(database.Name, new object[]
                    {
                        database.Name,
                        ex7.Message
                    });
                }
            }
            if (ex != null)
            {
                throw new DatabaseLogCorruptRecoveryException(database.Name, ex.ToString(), ex);
            }
        }
Exemple #4
0
 public void TriggerShutdownSwitchover()
 {
     ActiveManagerCore.AttemptServerSwitchoverOnShutdown();
 }