// Token: 0x06002064 RID: 8292 RVA: 0x00096ABC File Offset: 0x00094CBC
        protected override void ExecuteInternal()
        {
            base.ExecuteInternal();
            AmAcllReturnStatus acllStatus = base.ReplicaInstance.AttemptCopyLastLogsRcr(this.AcllArgs, this.AcllPerfTracker);

            this.AcllStatus = acllStatus;
        }
Exemple #2
0
        // Token: 0x06000463 RID: 1123 RVA: 0x00017604 File Offset: 0x00015804
        public override RpcErrorExceptionInfo AttemptCopyLastLogsDirect(Guid guid, int mountDialOverride, int numRetries, int e00timeoutMs, int networkIOtimeoutMs, int networkConnecttimeoutMs, string sourceServer, int iActionCode, int skipValidationChecks, bool mountPending, string uniqueOperationId, int subactionAttemptNumber, ref AmAcllReturnStatus acllStatus)
        {
            AmTrace.Debug("Running ACLL for database (on behalf of PAM): {0}", new object[]
            {
                guid
            });
            AmAcllReturnStatus tempAcllStatus = null;

            acllStatus = null;
            AmAcllArgs acllArgs = new AmAcllArgs();

            acllArgs.NumRetries              = numRetries;
            acllArgs.E00TimeoutMs            = e00timeoutMs;
            acllArgs.NetworkIOTimeoutMs      = networkIOtimeoutMs;
            acllArgs.NetworkConnectTimeoutMs = networkConnecttimeoutMs;
            acllArgs.SourceServer            = new AmServerName(sourceServer);
            acllArgs.ActionCode              = new AmDbActionCode(iActionCode);
            acllArgs.SkipValidationChecks    = (AmBcsSkipFlags)skipValidationChecks;
            acllArgs.MountPending            = mountPending;
            acllArgs.MountDialOverride       = (DatabaseMountDialOverride)mountDialOverride;
            acllArgs.UniqueOperationId       = uniqueOperationId;
            acllArgs.SubactionAttemptNumber  = subactionAttemptNumber;
            RpcErrorExceptionInfo result = AmRpcExceptionWrapper.Instance.RunRpcServerOperation(delegate()
            {
                AmRpcServer.m_amInstance.AttemptCopyLastLogsDirect(guid, acllArgs, ref tempAcllStatus);
            });

            acllStatus = tempAcllStatus;
            return(result);
        }
Exemple #3
0
 // Token: 0x060001B0 RID: 432 RVA: 0x0000AB10 File Offset: 0x00008D10
 internal void AttemptCopyLastLogsDirect(Guid mdbGuid, AmAcllArgs acllArgs, ref AmAcllReturnStatus acllStatus)
 {
     acllStatus = new AmAcllReturnStatus();
     ThirdPartyManager.PreventOperationWhenTPREnabled("AttemptCopyLastLogsDirect");
     if (!AmHelper.IsDatabaseRcrEnabled(mdbGuid))
     {
         throw new AmDbMoveOperationNotSupportedException(mdbGuid.ToString());
     }
     AmTrace.Debug("AttemptCopyLastLogsDirect: Calling AmAcllCallback ({0})", new object[]
     {
         mdbGuid
     });
     acllStatus = this.m_replicaInstanceManager.AmAttemptCopyLastLogsCallback(mdbGuid, acllArgs);
     if (acllArgs.ActionCode.IsAutomaticShutdownSwitchover)
     {
         if (!acllStatus.NoLoss)
         {
             ReplayCrimsonEvents.AcllFailedOnSwitchover.Log <Guid>(mdbGuid);
             throw new AcllFailedException(acllStatus.LastError);
         }
         ReplayCrimsonEvents.AcllLosslessOnSwitchover.Log <Guid>(mdbGuid);
         return;
     }
     else
     {
         if (!acllStatus.NoLoss && acllStatus.MountAllowed)
         {
             ReplayCrimsonEvents.LossyMountEnabled.Log <Guid>(mdbGuid);
             AmTrace.Warning("AttemptCopyLastLogsDirect: ACLL detected a lossy mount will be allowed for DB {0}.", new object[]
             {
                 mdbGuid
             });
             return;
         }
         if (acllStatus.MountAllowed)
         {
             AmTrace.Debug("AttemptCopyLastLogsDirect: ACLL completed with no loss for DB {0}.", new object[]
             {
                 mdbGuid
             });
             ReplayCrimsonEvents.AcllLosslessOnMoveOrFailover.Log <Guid>(mdbGuid);
             return;
         }
         if (string.IsNullOrEmpty(acllStatus.LastError))
         {
             ReplayCrimsonEvents.MountRejected.Log <Guid>(mdbGuid);
             throw new AmDbMountNotAllowedDueToLossException();
         }
         ReplayCrimsonEvents.MountRejectedAcllError.Log <Guid, string>(mdbGuid, acllStatus.LastError);
         throw new AmDbMountNotAllowedDueToAcllErrorException(acllStatus.LastError, acllStatus.NumberOfLogsLost);
     }
 }
Exemple #4
0
        protected override void RemountInternal(MountFlags mountFlags, DatabaseMountDialOverride mountDialoverride, AmServerName fromServer)
        {
            Exception exception = null;

            base.AttemptDismount(base.State.ActiveServer, UnmountFlags.SkipCacheFlush, true, out exception);
            int num = 0;
            AmDbNodeAttemptTable dbNodeAttemptTable = AmSystemManager.Instance.DbNodeAttemptTable;
            AmAcllReturnStatus   amAcllReturnStatus = null;

            this.AttemptMountOnServer(base.State.ActiveServer, base.State.ActiveServer, mountFlags, AmMountFlags.None, UnmountFlags.SkipCacheFlush, mountDialoverride, AmBcsSkipFlags.None, false, ref num, ref amAcllReturnStatus, out exception);
            base.DbTrace.Debug("AttemptMountOnServer returned AcllStatus: {0}", new object[]
            {
                amAcllReturnStatus
            });
            AmHelper.ThrowDbActionWrapperExceptionIfNecessary(exception);
        }
        // Token: 0x06001BC5 RID: 7109 RVA: 0x00077C40 File Offset: 0x00075E40
        private AmAcllReturnStatus GetReturnStatus()
        {
            AmAcllReturnStatus amAcllReturnStatus = new AmAcllReturnStatus();

            amAcllReturnStatus.NoLoss                    = this.NoLoss;
            amAcllReturnStatus.MountAllowed              = this.MountAllowed;
            amAcllReturnStatus.MountDialOverrideUsed     = this.MountDialOverrideUsed;
            amAcllReturnStatus.LastLogGenerationNotified = this.LastLogNotified;
            amAcllReturnStatus.LastLogGenerationShipped  = this.LastLogShipped;
            amAcllReturnStatus.LastInspectedLogTime      = this.ToNonNullableDateTime(new DateTime?(this.LastLogInspectedTime));
            amAcllReturnStatus.NumberOfLogsLost          = this.NumberOfLogsLost;
            if (!this.ErrorMessage.IsEmpty)
            {
                amAcllReturnStatus.LastError = this.ErrorMessage;
            }
            return(amAcllReturnStatus);
        }
Exemple #6
0
 internal static void AttemptCopyLastLogsDirect(AmServerName serverName, Guid dbGuid, AmAcllArgs acllArgs, ref AmAcllReturnStatus acllStatus)
 {
     acllStatus = null;
     Dependencies.AmRpcClientWrapper.AttemptCopyLastLogsDirect(serverName.Fqdn, dbGuid, acllArgs.MountDialOverride, acllArgs.NumRetries, acllArgs.E00TimeoutMs, acllArgs.NetworkIOTimeoutMs, acllArgs.NetworkConnectTimeoutMs, acllArgs.SourceServer.Fqdn, (int)acllArgs.ActionCode, (int)acllArgs.SkipValidationChecks, acllArgs.MountPending, acllArgs.UniqueOperationId, acllArgs.SubactionAttemptNumber, ref acllStatus);
 }
Exemple #7
0
        private void RunAttemptCopyLastLogsOnServer(AmServerName serverToMount, AmServerName sourceServer, DatabaseMountDialOverride mountDialOverride, AmBcsSkipFlags skipValidationChecks, int numRetries, int e00timeoutMs, int networkIOtimeoutMs, int networkConnecttimeoutMs, out bool fLossyMountEnabled, ref AmAcllReturnStatus acllStatus)
        {
            acllStatus = null;
            bool flag = false;

            fLossyMountEnabled = false;
            try
            {
                base.ReportStatus(AmDbActionStatus.AcllInitiated);
                AmAcllArgs amAcllArgs = new AmAcllArgs();
                amAcllArgs.NumRetries              = numRetries;
                amAcllArgs.E00TimeoutMs            = e00timeoutMs;
                amAcllArgs.NetworkIOTimeoutMs      = networkIOtimeoutMs;
                amAcllArgs.NetworkConnectTimeoutMs = networkConnecttimeoutMs;
                amAcllArgs.SourceServer            = sourceServer;
                amAcllArgs.ActionCode              = base.ActionCode;
                amAcllArgs.MountDialOverride       = mountDialOverride;
                amAcllArgs.SkipValidationChecks    = skipValidationChecks;
                amAcllArgs.UniqueOperationId       = base.UniqueOperationId;
                amAcllArgs.SubactionAttemptNumber  = base.CurrentAttemptNumber;
                if (base.State.IsAdminDismounted && !base.ActionCode.IsAdminMountOperation)
                {
                    amAcllArgs.MountPending = false;
                }
                else
                {
                    amAcllArgs.MountPending = true;
                }
                AmDbAction.AttemptCopyLastLogsDirect(serverToMount, base.DatabaseGuid, amAcllArgs, ref acllStatus);
                fLossyMountEnabled = (!acllStatus.NoLoss && acllStatus.MountAllowed);
                flag = true;
                base.ReportStatus(AmDbActionStatus.AcllSuccessful);
            }
            finally
            {
                if (!flag)
                {
                    base.ReportStatus(AmDbActionStatus.AcllFailed);
                }
            }
        }
Exemple #8
0
        protected override void MountInternal(MountFlags storeMountFlags, AmMountFlags amMountFlags, DatabaseMountDialOverride mountDialOverride, ref AmDbOperationDetailedStatus mountStatus)
        {
            Exception ex = null;
            int       natSkippedServersCount = 0;
            int       num  = 0;
            bool      flag = true;

            if (ThirdPartyManager.IsThirdPartyReplicationEnabled)
            {
                flag = false;
            }
            if (base.ActionCode.IsAdminOperation)
            {
                if (base.State.IsActiveServerValid)
                {
                    flag = false;
                }
                else
                {
                    AmTrace.Debug("Mount issued for the first time on this database. We will try all the available servers. (db={0})", new object[]
                    {
                        base.DatabaseName
                    });
                }
            }
            AmServerName amServerName = base.State.ActiveServer;

            if (AmServerName.IsNullOrEmpty(amServerName))
            {
                amServerName = new AmServerName(base.Database.Server.Name);
            }
            AmBcsSkipFlags skipValidationChecks = AmBcsSkipFlags.SkipAll;

            if (flag)
            {
                skipValidationChecks = AmBcsSkipFlags.None;
            }
            IBestCopySelector    bestCopySelector   = this.ConstructBestCopySelector(flag, skipValidationChecks, null, amServerName, amServerName, mountDialOverride, null);
            AmDbNodeAttemptTable dbNodeAttemptTable = AmSystemManager.Instance.DbNodeAttemptTable;

            if (base.ActionCode.IsAdminOperation)
            {
                dbNodeAttemptTable.ClearFailedTime(base.DatabaseGuid);
            }
            AmServerName       sourceServer       = amServerName;
            AmAcllReturnStatus amAcllReturnStatus = null;
            AmServerName       amServerName2      = bestCopySelector.FindNextBestCopy();

            while (amServerName2 != null)
            {
                num++;
                base.DbTrace.Debug("Attempting mount on server {0}", new object[]
                {
                    amServerName2
                });
                this.AttemptMountOnServer(amServerName2, sourceServer, storeMountFlags, amMountFlags, UnmountFlags.SkipCacheFlush, mountDialOverride, AmBcsSkipFlags.None, flag, ref natSkippedServersCount, ref amAcllReturnStatus, out ex);
                base.DbTrace.Debug("AttemptMountOnServer returned AcllStatus: {0}", new object[]
                {
                    amAcllReturnStatus
                });
                sourceServer = base.State.ActiveServer;
                if (ex == null)
                {
                    break;
                }
                bestCopySelector.ErrorLogger.ReportServerFailure(amServerName2, "CopyHasBeenTriedCheck", ex.Message);
                if (ex is AmRoleChangedWhileOperationIsInProgressException || ex is AmMountTimeoutException)
                {
                    break;
                }
                amServerName2 = bestCopySelector.FindNextBestCopy();
                base.CurrentAttemptNumber++;
            }
            this.CheckActionResultsAndUpdateAdProperties(amServerName, null, bestCopySelector, ex, num, natSkippedServersCount);
        }
Exemple #9
0
        private bool AttemptMountOnServer(AmServerName serverToMount, AmServerName sourceServer, MountFlags storeMountFlags, AmMountFlags amMountFlags, UnmountFlags dismountFlags, DatabaseMountDialOverride mountDialoverride, AmBcsSkipFlags skipValidationChecks, bool tryOtherHealthyServers, ref int natSkippedServersCount, ref AmAcllReturnStatus acllStatus, out Exception lastException)
        {
            bool flag = true;
            bool fLossyMountEnabled    = false;
            bool isSuccess             = false;
            bool isAcllSuccess         = false;
            bool isMasterServerChanged = false;

            lastException = null;
            bool isSuccess2;

            try
            {
                acllStatus = new AmAcllReturnStatus();
                AmDbNodeAttemptTable dbNodeAttemptTable = AmSystemManager.Instance.DbNodeAttemptTable;
                if (!base.ActionCode.IsAdminOperation && base.Config.IsIgnoreServerDebugOptionEnabled(serverToMount))
                {
                    ReplayCrimsonEvents.OperationNotPerformedDueToDebugOption.Log <string, string, string>(serverToMount.Fqdn, AmDebugOptions.IgnoreServerFromAutomaticActions.ToString(), "Mount database");
                    throw new AmDbOperationException("Mount not applicable for a server when debug options are enabled");
                }
                bool flag2 = this.IsAcllRequired(serverToMount, sourceServer);
                if (dbNodeAttemptTable.IsOkayForAction(base.Database, serverToMount, base.ActionCode))
                {
                    if (!flag2)
                    {
                        acllStatus.NoLoss       = true;
                        acllStatus.MountAllowed = true;
                    }
                    else
                    {
                        Stopwatch stopwatch = new Stopwatch();
                        stopwatch.Start();
                        try
                        {
                            ReplayCrimsonEvents.AcllInitiated.LogGeneric(base.PrepareSubactionArgs(new object[]
                            {
                                serverToMount,
                                sourceServer
                            }));
                            AmAcllReturnStatus tempAcllStatus = null;
                            lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                            {
                                this.RunAttemptCopyLastLogsOnServer(serverToMount, sourceServer, mountDialoverride, skipValidationChecks, 1, 15000, 15000, 15000, out fLossyMountEnabled, ref tempAcllStatus);
                                isAcllSuccess = true;
                            });
                            acllStatus = tempAcllStatus;
                        }
                        finally
                        {
                            stopwatch.Stop();
                            if (isAcllSuccess)
                            {
                                ReplayCrimsonEvents.AcllSuccess2.LogGeneric(base.PrepareSubactionArgs(new object[]
                                {
                                    serverToMount,
                                    fLossyMountEnabled,
                                    stopwatch.Elapsed
                                }));
                            }
                            else
                            {
                                ReplayCrimsonEvents.AcllFailed.LogGeneric(base.PrepareSubactionArgs(new object[]
                                {
                                    serverToMount,
                                    stopwatch.Elapsed,
                                    (lastException != null) ? lastException.Message : ReplayStrings.UnknownError
                                }));
                            }
                        }
                        if (lastException == null)
                        {
                            if (base.State.IsAdminDismounted && !base.ActionCode.IsAdminMountOperation)
                            {
                                AmTrace.Debug("Skipping mount for database '{0}' on server '{1}' since it was admin dismounted.", new object[]
                                {
                                    base.DatabaseName,
                                    serverToMount
                                });
                                if (this.UpdateMaster(serverToMount, true))
                                {
                                    this.SendReplicaNotifications();
                                    isMasterServerChanged = true;
                                }
                                isSuccess = true;
                                flag      = false;
                            }
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                    if (!flag)
                    {
                        goto IL_45C;
                    }
                    isSuccess     = false;
                    lastException = null;
                    Stopwatch stopwatch2 = new Stopwatch();
                    stopwatch2.Start();
                    try
                    {
                        ReplayCrimsonEvents.DirectMountInitiated.LogGeneric(base.PrepareSubactionArgs(new object[]
                        {
                            serverToMount,
                            storeMountFlags,
                            fLossyMountEnabled,
                            amMountFlags
                        }));
                        lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                        {
                            TimeSpan mountTimeout = this.DetermineMountTimeout(skipValidationChecks);
                            this.RunMountDatabaseDirect(serverToMount, storeMountFlags, amMountFlags, fLossyMountEnabled, mountTimeout, ref isMasterServerChanged);
                            isSuccess = true;
                        });
                        goto IL_45C;
                    }
                    finally
                    {
                        stopwatch2.Stop();
                        if (isSuccess)
                        {
                            ReplayCrimsonEvents.DirectMountSuccess.LogGeneric(base.PrepareSubactionArgs(new object[]
                            {
                                serverToMount,
                                stopwatch2.Elapsed
                            }));
                        }
                        else
                        {
                            string text = (lastException != null) ? lastException.Message : ReplayStrings.UnknownError;
                            ReplayCrimsonEvents.DirectMountFailed.LogGeneric(base.PrepareSubactionArgs(new object[]
                            {
                                serverToMount,
                                stopwatch2.Elapsed,
                                text
                            }));
                        }
                    }
                }
                natSkippedServersCount++;
                AmTrace.Debug("Mount for database '{0}' skipped server '{1}' since a recent mount operation on this node failed.", new object[]
                {
                    base.DatabaseName,
                    serverToMount
                });
                lastException = new AmDbOperationAttempedTooSoonException(base.DatabaseName);
                ReplayCrimsonEvents.MountServerSkipped.LogGeneric(base.PrepareSubactionArgs(new object[]
                {
                    serverToMount,
                    lastException.Message
                }));
                isSuccess = false;
IL_45C:
                isSuccess2 = isSuccess;
            }
            finally
            {
                if (!isMasterServerChanged)
                {
                    AmTrace.Error("The active server for database '{0}' has not been changed, so we need to rollback the database state tracker information.", new object[]
                    {
                        base.DatabaseName
                    });
                    AmDatabaseStateTracker databaseStateTracker = AmSystemManager.Instance.DatabaseStateTracker;
                    if (databaseStateTracker != null)
                    {
                        databaseStateTracker.UpdateActive(base.DatabaseGuid, sourceServer);
                    }
                }
            }
            return(isSuccess2);
        }
Exemple #10
0
        protected override void MoveInternal(MountFlags storeMountFlags, UnmountFlags dismountFlags, DatabaseMountDialOverride mountDialoverride, AmServerName fromServer, AmServerName targetServer, bool tryOtherHealthyServers, AmBcsSkipFlags skipValidationChecks, string componentName, ref AmDbOperationDetailedStatus moveStatus)
        {
            AmDbNodeAttemptTable dbNodeAttemptTable = AmSystemManager.Instance.DbNodeAttemptTable;
            IBestCopySelector    bestCopySelector   = null;
            Exception            ex = null;
            bool flag = false;
            int  num  = 0;
            int  natSkippedServersCount = 0;

            if (!base.State.IsEntryExist)
            {
                base.DbTrace.Error("Database was never mounted. Move is applicable only if it was mounted at least once", new object[0]);
                throw new AmDatabaseNeverMountedException();
            }
            if (base.State.IsAdminDismounted)
            {
                AmTrace.Diagnostic("Moving a dismounted database {0}. The database will be moved, but won't be mounted", new object[]
                {
                    base.DatabaseName
                });
            }
            moveStatus.InitialDbState = base.State.Copy();
            AmServerName       activeServer       = base.State.ActiveServer;
            AmAcllReturnStatus amAcllReturnStatus = null;
            bool flag2 = true;

            try
            {
                this.CheckIfMoveApplicableForDatabase(base.State.ActiveServer, fromServer, base.ActionCode);
                bestCopySelector = this.ConstructBestCopySelector(tryOtherHealthyServers, skipValidationChecks, null, activeServer, targetServer, mountDialoverride, componentName);
                if (base.ActionCode.IsAutomaticShutdownSwitchover)
                {
                    base.AttemptDismount(base.State.ActiveServer, dismountFlags, true, out ex);
                    flag = true;
                }
                AmServerName amServerName = bestCopySelector.FindNextBestCopy();
                while (amServerName != null)
                {
                    num++;
                    if (!flag)
                    {
                        base.AttemptDismount(activeServer, dismountFlags, true, out ex);
                        flag = true;
                    }
                    AmMountFlags amMountFlags = AmMountFlags.None;
                    if (BitMasker.IsOn((int)skipValidationChecks, 4))
                    {
                        amMountFlags = AmMountFlags.MoveWithSkipHealth;
                    }
                    this.AttemptMountOnServer(amServerName, base.State.ActiveServer, storeMountFlags, amMountFlags, dismountFlags, mountDialoverride, skipValidationChecks, tryOtherHealthyServers, ref natSkippedServersCount, ref amAcllReturnStatus, out ex);
                    base.DbTrace.Debug("AttemptMountOnServer returned AcllStatus: {0}", new object[]
                    {
                        amAcllReturnStatus
                    });
                    moveStatus.AddSubstatus(new AmDbOperationSubStatus(amServerName, amAcllReturnStatus, ex));
                    if (ex == null)
                    {
                        flag2 = false;
                        break;
                    }
                    bestCopySelector.ErrorLogger.ReportServerFailure(amServerName, "CopyHasBeenTriedCheck", ex.Message);
                    if (ex is AmRoleChangedWhileOperationIsInProgressException)
                    {
                        flag2 = false;
                        break;
                    }
                    if (ex is AmMountTimeoutException)
                    {
                        flag2 = false;
                        break;
                    }
                    amServerName = bestCopySelector.FindNextBestCopy();
                    base.CurrentAttemptNumber++;
                }
            }
            finally
            {
                moveStatus.FinalDbState = base.State.Copy();
            }
            if (flag2)
            {
                MountStatus storeDatabaseMountStatus = AmStoreHelper.GetStoreDatabaseMountStatus(base.State.ActiveServer, base.Database.Guid);
                if (storeDatabaseMountStatus != base.State.MountStatus)
                {
                    ReplayCrimsonEvents.MismatchErrorAfterMove.Log <string, Guid, AmServerName, MountStatus, MountStatus>(base.Database.Name, base.Database.Guid, base.State.ActiveServer, base.State.MountStatus, storeDatabaseMountStatus);
                    if (storeDatabaseMountStatus == MountStatus.Dismounted)
                    {
                        base.State.MountStatus = MountStatus.Dismounted;
                        base.WriteState();
                    }
                }
            }
            this.CheckActionResultsAndUpdateAdProperties(activeServer, targetServer, bestCopySelector, ex, num, natSkippedServersCount);
        }
Exemple #11
0
 // Token: 0x06000841 RID: 2113 RVA: 0x00028264 File Offset: 0x00026464
 public void AttemptCopyLastLogsDirect(string serverToRpc, Guid dbGuid, DatabaseMountDialOverride mountDialOverride, int numRetries, int e00timeoutMs, int networkIOtimeoutMs, int networkConnecttimeoutMs, string sourceServer, int actionCode, int skipValidationChecks, bool mountPending, string uniqueOperationId, int subactionAttemptNumber, ref AmAcllReturnStatus acllStatus)
 {
     AmRpcClientHelper.AttemptCopyLastLogsDirect(serverToRpc, dbGuid, mountDialOverride, numRetries, e00timeoutMs, networkIOtimeoutMs, networkConnecttimeoutMs, sourceServer, actionCode, skipValidationChecks, mountPending, uniqueOperationId, subactionAttemptNumber, ref acllStatus);
 }
 // Token: 0x06000205 RID: 517 RVA: 0x0000C90E File Offset: 0x0000AB0E
 public AmDbOperationSubStatus(AmServerName serverAttempted, AmAcllReturnStatus acllStatus, Exception exception)
 {
     this.ServerAttempted  = serverAttempted;
     this.AcllReturnStatus = acllStatus;
     this.LastException    = exception;
 }