// Token: 0x060002DA RID: 730 RVA: 0x0000FFC0 File Offset: 0x0000E1C0 protected override void RunInternal() { Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1) { this.CheckIfOperationIsAllowedOnCurrentRole(); AmDbStateInfo amDbStateInfo = AmSystemManager.Instance.Config.DbState.Read(base.Database.Guid); if (!amDbStateInfo.IsAdminDismounted) { AmTrace.Debug("AmDbDismountAdminDismountedOperation skipped since database is not marked as admin dismounted anymore", new object[0]); return; } MountStatus storeDatabaseMountStatus = AmStoreHelper.GetStoreDatabaseMountStatus(null, base.Database.Guid); if (storeDatabaseMountStatus == MountStatus.Mounted) { AmDbAction amDbAction = base.PrepareDbAction(this.ActionCode); ReplayCrimsonEvents.DismountingAdminDismountRequestedDatabase.Log <string, Guid, AmServerName>(base.Database.Name, base.Database.Guid, amDbStateInfo.ActiveServer); amDbAction.Dismount(UnmountFlags.None); return; } AmTrace.Debug("AmDbDismountAdminDismountedOperation skipped since database is not mounted (db={0}, mountStatus={1})", new object[] { base.Database.Name, storeDatabaseMountStatus }); }); base.LastException = lastException; }
internal static bool WriteStateSyncMountStatus(AmConfig amConfig, AmDbStateInfo stateInfo, Guid databaseGuid, AmServerName activeServer, MountStatus mountStatus) { bool flag = false; if (mountStatus == MountStatus.Mounted) { stateInfo.UpdateActiveServerAndIncrementFailoverSequenceNumber(activeServer); stateInfo.LastMountedServer = activeServer; stateInfo.IsAdminDismounted = false; stateInfo.MountStatus = mountStatus; stateInfo.IsAutomaticActionsAllowed = true; stateInfo.LastMountedTime = DateTime.UtcNow; flag = true; } else if (stateInfo.IsEntryExist) { stateInfo.MountStatus = mountStatus; if (stateInfo.IsMountSucceededAtleastOnce) { stateInfo.UpdateActiveServerAndIncrementFailoverSequenceNumber(activeServer); stateInfo.LastMountedServer = activeServer; } flag = true; } if (flag && AmDbAction.WriteState(amConfig, stateInfo, false)) { AmDatabaseStateTracker databaseStateTracker = AmSystemManager.Instance.DatabaseStateTracker; if (databaseStateTracker != null) { databaseStateTracker.UpdateActive(databaseGuid, activeServer); } } return(flag); }
// Token: 0x060002F5 RID: 757 RVA: 0x00011688 File Offset: 0x0000F888 protected override void MountInternal(MountFlags storeFlags, AmMountFlags amMountFlags, DatabaseMountDialOverride mountDialoverride, ref AmDbOperationDetailedStatus mountStatus) { Exception ex = null; bool isSuccess = false; AmServerName activeServer = base.State.ActiveServer; AmServerName serverToMount = AmServerName.LocalComputerName; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); try { ReplayCrimsonEvents.DirectMountInitiated.LogGeneric(base.PrepareSubactionArgs(new object[] { serverToMount, storeFlags, false, amMountFlags })); ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1) { this.ReportStatus(AmDbActionStatus.StoreMountInitiated); this.WriteStateMountStart(serverToMount); AmDbAction.MountDatabaseDirect(serverToMount, this.State.LastMountedServer, this.DatabaseGuid, storeFlags, amMountFlags, this.ActionCode); isSuccess = true; }); } finally { stopwatch.Stop(); if (isSuccess) { base.DbTrace.Debug("Database is now mounted on {0}", new object[] { serverToMount }); SharedDependencies.WritableADHelper.ResetAllowFileRestoreDsFlag(base.DatabaseGuid, activeServer, serverToMount); ReplayCrimsonEvents.DirectMountSuccess.LogGeneric(base.PrepareSubactionArgs(new object[] { serverToMount, stopwatch.Elapsed })); base.WriteStateMountSuccess(); base.ReportStatus(AmDbActionStatus.StoreMountSuccessful); } else { string text = (ex != null) ? ex.Message : ReplayStrings.UnknownError; ReplayCrimsonEvents.DirectMountFailed.LogGeneric(base.PrepareSubactionArgs(new object[] { serverToMount, stopwatch.Elapsed, text })); base.WriteStateMountFailed(true); base.ReportStatus(AmDbActionStatus.StoreMountFailed); } } AmHelper.ThrowDbActionWrapperExceptionIfNecessary(ex); }
protected override void RunInternal() { Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1) { AmDbAction.DismountIfMismounted(base.Database, this.ActionCode, this.MismountedNodes); }); base.LastException = lastException; }
protected override void RunInternal() { Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1) { AmDbAction amDbAction = base.PrepareDbAction(this.ActionCode); amDbAction.Remount(this.Flags, this.MountDialOverride, this.FromServer); }); base.LastException = lastException; }
// Token: 0x060002E0 RID: 736 RVA: 0x00010040 File Offset: 0x0000E240 protected override void RunInternal() { Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1) { this.CheckIfOperationIsAllowedOnCurrentRole(); AmDbAction.SyncDatabaseOwningServerAndLegacyDn(base.Database, this.ActionCode); }); base.LastException = lastException; }
// Token: 0x060002A9 RID: 681 RVA: 0x0000F8DC File Offset: 0x0000DADC protected override void RunInternal() { AmDbOperationDetailedStatus mountStatus = null; Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1) { AmDbAction amDbAction = this.PrepareDbAction(this.ActionCode); amDbAction.Mount(this.StoreMountFlags, this.AmMountFlags, this.MountDialOverride, ref mountStatus); }); base.DetailedStatus = mountStatus; base.LastException = lastException; }
// Token: 0x060002C2 RID: 706 RVA: 0x0000FCD8 File Offset: 0x0000DED8 protected override void RunInternal() { AmDbOperationDetailedStatus moveStatus = null; Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1) { AmDbAction amDbAction = this.PrepareDbAction(this.Arguments.ActionCode); amDbAction.Move(this.Arguments.MountFlags, this.Arguments.DismountFlags, this.Arguments.MountDialOverride, this.Arguments.SourceServer, this.Arguments.TargetServer, this.Arguments.TryOtherHealthyServers, this.Arguments.SkipValidationChecks, this.Arguments.MoveComment, this.Arguments.ComponentName, ref moveStatus); }); base.DetailedStatus = moveStatus; base.LastException = lastException; }
protected AmDbAction PrepareDbAction(AmDbActionCode actionCode) { this.CheckIfOperationIsAllowedOnCurrentRole(); AmConfig config = AmSystemManager.Instance.Config; AmDbAction amDbAction; if (config.IsPAM) { amDbAction = new AmDbPamAction(config, this.Database, actionCode, this.UniqueId); } else { amDbAction = new AmDbStandaloneAction(config, this.Database, actionCode, this.UniqueId); } AmDbAction amDbAction2 = amDbAction; amDbAction2.StatusCallback = (AmReportStatusDelegate)Delegate.Combine(amDbAction2.StatusCallback, new AmReportStatusDelegate(this.ReportStatus)); return(amDbAction); }
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); } } }
internal bool WriteState(bool isBestEffort) { return(AmDbAction.WriteState(this.Config, this.State, isBestEffort)); }
internal bool AttemptDismount(AmServerName serverName, UnmountFlags flags, bool isIgnoreKnownExceptions, out Exception exception) { bool result = false; exception = null; bool isNodeup = true; if (this.Config.IsPamOrSam && !this.Config.DagConfig.IsNodePubliclyUp(serverName)) { isNodeup = false; } TimeSpan bestEffortDismountTimeout = this.DetermineDismountTimeout(this.ActionCode, isNodeup); this.DbTrace.Debug("Attempting dismount (server={0}, flags={1}, actionCode={2}, dismountTimeout={3}ms, ignoreException={4})", new object[] { serverName, flags, this.ActionCode, bestEffortDismountTimeout.TotalMilliseconds, isIgnoreKnownExceptions }); AmDbAction.DismountMode modeOfDismount = AmDbAction.DismountMode.None; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); bool flag = true; MountStatus mountStatus = this.State.MountStatus; try { ReplayCrimsonEvents.StoreDismountInitiated.LogGeneric(this.PrepareSubactionArgs(new object[] { serverName, flags, bestEffortDismountTimeout })); if (AmServerName.IsEqual(this.State.ActiveServer, serverName)) { this.WriteStateDismounting(false); } ExTraceGlobals.FaultInjectionTracer.TraceTest(3152424253U); exception = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1) { InvokeWithTimeout.Invoke(delegate() { if (isNodeup && AmHelper.IsReplayRunning(serverName)) { this.DbTrace.Debug("Attempting Dismount through active manager", new object[0]); modeOfDismount = AmDbAction.DismountMode.ThroughReplayService; AmDbAction.DismountDatabaseDirect(serverName, this.DatabaseGuid, flags, this.ActionCode); return; } this.DbTrace.Debug("Attempting dismount by directly RPCing to store", new object[0]); modeOfDismount = AmDbAction.DismountMode.DirectlyToStore; AmStoreHelper.RemoteDismount(serverName, this.DatabaseGuid, flags, true); }, bestEffortDismountTimeout); this.DbTrace.Debug("Database is possibly dismounted at server {0}", new object[] { serverName }); }); if (exception != null) { this.DbTrace.Debug("Dismount failed with error: {0}", new object[] { exception }); } flag = false; } finally { stopwatch.Stop(); string text = null; if (flag) { text = ReplayStrings.UnknownError; } else if (exception != null) { text = exception.Message; } if (string.IsNullOrEmpty(text)) { result = true; ReplayCrimsonEvents.StoreDismountSuccess.LogGeneric(this.PrepareSubactionArgs(new object[] { serverName, modeOfDismount, stopwatch.Elapsed })); if (AmServerName.IsEqual(this.State.ActiveServer, serverName)) { this.WriteStateDismountFinished(true, MountStatus.Dismounted, false); } } else { ReplayCrimsonEvents.StoreDismountFailed.LogGeneric(this.PrepareSubactionArgs(new object[] { serverName, modeOfDismount, stopwatch.Elapsed, text })); if (AmServerName.IsEqual(this.State.ActiveServer, serverName)) { this.WriteStateDismountFinished(true, mountStatus, false); } } } return(result); }
internal static void SyncClusterDatabaseState(IADDatabase db, AmDbActionCode actionCode) { AmConfig config = AmSystemManager.Instance.Config; if (config.IsUnknown) { AmTrace.Error("SyncClusterDatabaseState: Invalid configuration (db={0})", new object[] { db }); throw new AmInvalidConfiguration(config.LastError); } AmDbStateInfo amDbStateInfo = config.DbState.Read(db.Guid); AmServerName amServerName; if (amDbStateInfo.IsActiveServerValid) { amServerName = amDbStateInfo.ActiveServer; } else { amServerName = new AmServerName(db.Server.Name); } MountStatus mountStatus = MountStatus.Dismounted; if ((config.IsStandalone || (config.IsPamOrSam && config.DagConfig.IsNodePubliclyUp(amServerName))) && AmStoreHelper.IsMounted(amServerName, db.Guid)) { mountStatus = MountStatus.Mounted; AmSystemManager.Instance.DbNodeAttemptTable.ClearFailedTime(db.Guid); } MountStatus mountStatus2 = amDbStateInfo.MountStatus; if (mountStatus != mountStatus2 || !AmServerName.IsEqual(amDbStateInfo.LastMountedServer, amDbStateInfo.ActiveServer)) { if (mountStatus != mountStatus2) { AmTrace.Debug("Mounted state reported by STORE is different from persistent state. (Database:{0}, PersistentState: {1}, StoreIsReporting: {2})", new object[] { db.Name, mountStatus2, mountStatus }); } else { AmTrace.Debug("State is in transit. (Database:{0}, LastMountedServer: {1},ActiveServer: {2})", new object[] { db.Name, amDbStateInfo.LastMountedServer, amDbStateInfo.ActiveServer }); } AmDbAction.WriteStateSyncMountStatus(config, amDbStateInfo, db.Guid, amServerName, mountStatus); ReplayCrimsonEvents.DatabaseMountStatusSynchronized.Log <string, Guid, MountStatus, MountStatus, AmServerName>(db.Name, db.Guid, mountStatus2, mountStatus, amServerName); return; } AmTrace.Debug("Ignored persistent state sync for {0} since nothing is out of sync", new object[] { db.Name }); }
private void RunMountDatabaseDirect(AmServerName serverToMount, MountFlags storeMountFlags, AmMountFlags amMountFlags, bool fLossyMountEnabled, TimeSpan mountTimeout, ref bool isMasterChanged) { bool flag = false; bool flag2 = false; isMasterChanged = false; AmDbNodeAttemptTable dbNodeAttemptTable = AmSystemManager.Instance.DbNodeAttemptTable; AmServerName activeServer = base.State.ActiveServer; try { isMasterChanged = this.UpdateMaster(serverToMount, false); base.ReportStatus(AmDbActionStatus.StoreMountInitiated); if (fLossyMountEnabled) { storeMountFlags |= MountFlags.AllowDatabasePatch; } ExTraceGlobals.FaultInjectionTracer.TraceTest(2229677373U); try { InvokeWithTimeout.Invoke(delegate() { AmDbAction.MountDatabaseDirect(serverToMount, this.State.LastMountedServer, this.DatabaseGuid, storeMountFlags, amMountFlags, this.ActionCode); ExTraceGlobals.FaultInjectionTracer.TraceTest(2441489725U); }, mountTimeout); } catch (TimeoutException ex) { base.DbTrace.Error("Mount timeout on {0}: {1}", new object[] { base.DatabaseName, ex }); AmMountTimeoutException ex2 = new AmMountTimeoutException(base.DatabaseName, serverToMount.NetbiosName, (int)mountTimeout.TotalSeconds, ex); this.HandleMountTimeout(serverToMount, ex2); throw ex2; } flag = true; dbNodeAttemptTable.ClearFailedTime(base.DatabaseGuid); try { base.WriteStateMountSuccess(); } catch (AmRoleChangedWhileOperationIsInProgressException ex3) { base.DbTrace.Warning("Mount AmRoleChanged exception (error={0})", new object[] { ex3 }); } base.ReportStatus(AmDbActionStatus.StoreMountSuccessful); } catch (TransientException ex4) { base.DbTrace.Error("Mount transient exception (error={0})", new object[] { ex4 }); flag2 = true; throw; } catch (AmReplayServiceDownException ex5) { base.DbTrace.Error("Mount transient RPC exception (error={0})", new object[] { ex5 }); flag2 = true; throw; } finally { if (flag) { SharedDependencies.WritableADHelper.ResetAllowFileRestoreDsFlag(base.DatabaseGuid, activeServer, serverToMount); } else { base.WriteStateMountFailed(true); if (base.ActionCode.IsAutomaticFailureItem && !flag2) { dbNodeAttemptTable.MarkFailedTime(base.DatabaseGuid, serverToMount, base.ActionCode); } base.ReportStatus(AmDbActionStatus.StoreMountFailed); } if (isMasterChanged && AmSystemManager.Instance.Config.IsPAM) { this.SendReplicaNotifications(); } } }