Esempio n. 1
0
        // Token: 0x06001962 RID: 6498 RVA: 0x00069DC8 File Offset: 0x00067FC8
        private Exception ExecuteAssignSpare(AutoReseedWorkflowState state)
        {
            Exception ex = null;

            try
            {
                bool flag = true;
                MountedFolderPath mountedFolderPath;
                if (!MountedFolderPath.IsNullOrEmpty(this.m_volumeForMissingMountPoint))
                {
                    this.LogBeginExecute(state);
                    flag = false;
                    string            name           = base.Context.Database.Name;
                    DatabaseSpareInfo dbInfo         = new DatabaseSpareInfo(name, new MountedFolderPath(Path.Combine(base.Context.Dag.AutoDagDatabasesRootFolderPath.PathName, name)));
                    ExchangeVolume    exchangeVolume = base.Context.VolumeManager.FixupMountPointForDatabase(dbInfo, this.m_volumeForMissingMountPoint);
                    this.UpdateVolumeInfoCopyState(base.Context.Database.Guid);
                    ReplayCrimsonEvents.AutoReseedWorkflowDbMountPointMissing.Log <string, Guid, string, string, MountedFolderPath, MountedFolderPath>(name, base.Context.Database.Guid, base.WorkflowName, base.WorkflowLaunchReason, exchangeVolume.ExchangeVolumeMountPoint, exchangeVolume.VolumeName);
                }
                else if (this.IsVolumeRecentlyAssigned(this.m_targetDbSet, out mountedFolderPath))
                {
                    flag = false;
                    base.TraceDebug("Skipping assigning a new volume since a volume was recently assigned. ReseedRecoveryActionRetryCount: {0}", new object[]
                    {
                        state.ReseedRecoveryActionRetryCount
                    });
                    state.AssignedVolumeName = mountedFolderPath.Path;
                }
                if (flag)
                {
                    this.LogBeginExecute(state);
                    DatabaseSpareInfo[] dbInfos = (from status in this.m_targetDbSet
                                                   select new DatabaseSpareInfo(status.CopyStatus.DBName, new MountedFolderPath(Path.Combine(base.Context.Dag.AutoDagDatabasesRootFolderPath.PathName, status.CopyStatus.DBName)))).ToArray <DatabaseSpareInfo>();
                    ExchangeVolume exchangeVolume2 = base.Context.VolumeManager.AssignSpare(dbInfos);
                    base.TraceDebug("Assigned spare volume: {0}", new object[]
                    {
                        exchangeVolume2.VolumeName.Path
                    });
                    foreach (CopyStatusClientCachedEntry copyStatusClientCachedEntry in this.m_targetDbSet)
                    {
                        this.UpdateVolumeInfoCopyState(copyStatusClientCachedEntry.DbGuid);
                    }
                    ReplayCrimsonEvents.AutoReseedWorkflowDbFailedAssignSpareSucceeded.Log <string, Guid, string, string, MountedFolderPath, MountedFolderPath>(base.Context.Database.Name, base.Context.Database.Guid, base.WorkflowName, base.WorkflowLaunchReason, exchangeVolume2.ExchangeVolumeMountPoint, exchangeVolume2.VolumeName);
                    state.AssignedVolumeName = exchangeVolume2.VolumeName.Path;
                }
                else
                {
                    base.TraceDebug("Re-using previously assigned volume: {0}", new object[]
                    {
                        state.AssignedVolumeName
                    });
                }
                state.UpdateReseedRecoveryAction(ReseedState.InPlaceReseed);
            }
            catch (DatabaseVolumeInfoException ex2)
            {
                ex = ex2;
            }
            this.LogExecuteCompleted(state, ex);
            return(ex);
        }
Esempio n. 2
0
        // Token: 0x06001954 RID: 6484 RVA: 0x00068C68 File Offset: 0x00066E68
        private bool IsVolumeRecentlyAssigned(IEnumerable <CopyStatusClientCachedEntry> targetDbSet, out MountedFolderPath volumeName)
        {
            bool flag = false;

            volumeName = MountedFolderPath.Empty;
            CopyStatusClientCachedEntry[] array = (from status in targetDbSet
                                                   orderby status.CopyStatus.LastDatabaseVolumeNameTransitionTime descending
                                                   select status).ToArray <CopyStatusClientCachedEntry>();
            DateTime lastDatabaseVolumeNameTransitionTime = array[0].CopyStatus.LastDatabaseVolumeNameTransitionTime;

            if (lastDatabaseVolumeNameTransitionTime != ReplayState.ZeroFileTime)
            {
                if (lastDatabaseVolumeNameTransitionTime > base.Context.TargetCopyStatus.CopyStatus.LastStatusTransitionTime)
                {
                    flag       = true;
                    volumeName = new MountedFolderPath(array[0].CopyStatus.LastDatabaseVolumeName);
                }
                base.TraceDebug("IsVolumeRecentlyAssigned(): A previous auto-reseed (maybe of a different database copy) had assigned a new spare volume '{3}' at '{0} UTC'. LastStatusTransitionTime = '{1} UTC', recentlyAssigned = {2}", new object[]
                {
                    lastDatabaseVolumeNameTransitionTime,
                    base.Context.TargetCopyStatus.CopyStatus.LastStatusTransitionTime,
                    flag,
                    volumeName
                });
            }
            return(flag);
        }
Esempio n. 3
0
        // Token: 0x06001955 RID: 6485 RVA: 0x00068D58 File Offset: 0x00066F58
        private bool DoesMountPointNeedToBeFixed(IEnumerable <CopyStatusClientCachedEntry> targetDbSet, out MountedFolderPath volumeName)
        {
            volumeName = MountedFolderPath.Empty;
            RpcDatabaseCopyStatus2 copyStatus = base.Context.TargetCopyStatus.CopyStatus;

            if (FailedSuspendedCopyAutoReseedWorkflow.DoesCopyHaveMountPointConfigured(copyStatus))
            {
                return(false);
            }
            CopyStatusClientCachedEntry copyStatusClientCachedEntry = targetDbSet.FirstOrDefault((CopyStatusClientCachedEntry status) => status.Result == CopyStatusRpcResult.Success && FailedSuspendedCopyAutoReseedWorkflow.DoesCopyHaveMountPointConfigured(status.CopyStatus));

            if (copyStatusClientCachedEntry == null)
            {
                base.TraceError("Database copy is missing a mount point, but no other copies in the grouping have mount points either.", new object[0]);
                return(false);
            }
            volumeName = new MountedFolderPath(copyStatusClientCachedEntry.CopyStatus.DatabaseVolumeName);
            return(true);
        }
        protected override Exception ExecuteInternal(AutoReseedWorkflowState state)
        {
            Exception         ex                        = null;
            bool              flag                      = false;
            IVolumeManager    volumeManager             = base.Context.VolumeManager;
            IADDatabase       database                  = base.Context.Database;
            MountedFolderPath databaseMountedFolderPath = VolumeManager.GetDatabaseMountedFolderPath(base.Context.Dag.AutoDagDatabasesRootFolderPath, database.Name);

            if (MountPointUtil.IsDirectoryAccessibleMountPoint(databaseMountedFolderPath.Path, out ex))
            {
                flag = true;
            }
            else
            {
                ReplayCrimsonEvents.AutoReseedNeverMountedActiveMissingVolume.Log <string>(database.Name);
                if (volumeManager.FixActiveDatabaseMountPoint(database, base.Context.Databases, base.Context.AdConfig, out ex, true))
                {
                    flag = true;
                    volumeManager.UpdateVolumeInfoCopyState(database.Guid, base.Context.ReplicaInstanceManager);
                    ReplayCrimsonEvents.AutoReseedNeverMountedActiveAllocatedVolume.Log <string, string>(database.Name, base.Context.TargetCopyStatus.CopyStatus.LogVolumeName);
                }
                else
                {
                    AutoReseedWorkflow.Tracer.TraceError <string, string>((long)this.GetHashCode(), "DiskReclaimer: UpdateVolumeForNeverMountedActives() failed to fix up active database: '{0}' mountpoint. Error: {1}", database.Name, AmExceptionHelper.GetExceptionMessageOrNoneString(ex));
                    ReplayCrimsonEvents.AutoReseedFixActiveMountPointError.Log <string, string>(database.Name, AmExceptionHelper.GetExceptionMessageOrNoneString(ex));
                }
            }
            if (!flag)
            {
                AutoReseedWorkflow.Tracer.TraceError <string, string>((long)this.GetHashCode(), "DiskReclaimer: UpdateVolumeForNeverMountedActives() active database: '{0}' does not have a mountpoint. Skip issuing Store Mount. Error: {1}", database.Name, AmExceptionHelper.GetExceptionMessageOrNoneString(ex));
                return(ex);
            }
            ex = AmRpcClientHelper.AdminMountDatabaseWrapper(database);
            if (ex != null)
            {
                AutoReseedWorkflow.Tracer.TraceError <string, string>((long)this.GetHashCode(), "DiskReclaimer: UpdateVolumeForNeverMountedActives() failed to mount active database: '{0}' mountpoint. Error: {1}", database.Name, ex.Message);
                ReplayCrimsonEvents.AutoReseedMountActiveDatabaseError.Log <string, string>(database.Name, ex.Message);
            }
            return(ex);
        }
Esempio n. 5
0
        public void UpdateVolumeInfo()
        {
            DatabaseVolumeInfo databaseVolumeInfo = this.DatabaseVolumeInfo;
            MountedFolderPath  mountedFolderPath  = databaseVolumeInfo.DatabaseVolumeName;

            if (MountedFolderPath.IsNullOrEmpty(mountedFolderPath) && this.m_replayState.VolumeInfoIsValid)
            {
                mountedFolderPath = new MountedFolderPath(this.m_replayState.DatabaseVolumeName);
            }
            DatabaseVolumeInfo instance = DatabaseVolumeInfo.GetInstance(this.m_instance.Configuration);

            lock (this.m_instance)
            {
                this.DatabaseVolumeInfo = instance;
                this.m_replayState.SetVolumeInfoIfValid(instance);
                if (!MountedFolderPath.IsNullOrEmpty(instance.DatabaseVolumeName) && !MountedFolderPath.IsEqual(instance.DatabaseVolumeName, mountedFolderPath))
                {
                    this.m_replayState.LastDatabaseVolumeName = mountedFolderPath.Path;
                    this.m_replayState.LastDatabaseVolumeNameTransitionTime = DateTime.UtcNow;
                }
            }
        }
Esempio n. 6
0
        // Token: 0x06001952 RID: 6482 RVA: 0x00068A6C File Offset: 0x00066C6C
        internal static LocalizedString CheckDatabaseLogPaths(AutoReseedContext context)
        {
            string path = Path.Combine(context.Dag.AutoDagDatabasesRootFolderPath.PathName, context.TargetCopyStatus.CopyStatus.DBName);
            string path2;
            string path3;

            VolumeManager.GetDatabaseLogEdbFolderNames(context.Database.Name, out path2, out path3);
            MountedFolderPath mountedFolderPath  = new MountedFolderPath(Path.Combine(path, path2));
            MountedFolderPath mountedFolderPath2 = new MountedFolderPath(Path.Combine(path, path3));
            MountedFolderPath mountedFolderPath3 = new MountedFolderPath(context.Database.LogFolderPath.PathName);
            MountedFolderPath mountedFolderPath4 = new MountedFolderPath(Path.GetDirectoryName(context.Database.EdbFilePath.PathName));

            if (!mountedFolderPath3.Equals(mountedFolderPath))
            {
                return(ReplayStrings.AutoReseedInvalidLogFolderPath(mountedFolderPath3.RawString, mountedFolderPath.RawString));
            }
            if (!mountedFolderPath4.Equals(mountedFolderPath2))
            {
                return(ReplayStrings.AutoReseedInvalidEdbFolderPath(mountedFolderPath4.RawString, mountedFolderPath2.RawString));
            }
            return(LocalizedString.Empty);
        }
Esempio n. 7
0
        // Token: 0x0600195E RID: 6494 RVA: 0x000696C0 File Offset: 0x000678C0
        private LocalizedString RunPrereqsForAssignSpare(AutoReseedWorkflowState state)
        {
            this.TraceBeginPrereqs(state);
            if (state.ReseedRecoveryActionRetryCount >= RegistryParameters.AutoReseedDbFailedAssignSpareRetryCountMax)
            {
                int autoReseedDbFailedAssignSpareRetryCountMax = RegistryParameters.AutoReseedDbFailedAssignSpareRetryCountMax;
                base.TraceError("RunPrereqsForAssignSpare(): Failing 'AssignSpare' prereqs since ReseedRecoveryActionRetryCount ({0}) exceeds AutoReseedDbFailedAssignSpareRetryCountMax ({1}). Workflow will try InPlaceReseed stage next.", new object[]
                {
                    state.ReseedRecoveryActionRetryCount,
                    autoReseedDbFailedAssignSpareRetryCountMax
                });
                ReplayCrimsonEvents.AutoReseedWorkflowDbSpareRetryExceeded.Log <string, Guid, string, string, int>(base.Context.Database.Name, base.Context.Database.Guid, base.WorkflowName, base.WorkflowLaunchReason, autoReseedDbFailedAssignSpareRetryCountMax);
                state.UpdateReseedRecoveryAction(ReseedState.InPlaceReseed);
                return(ReplayStrings.AutoReseedFailedSeedRetryExceeded(autoReseedDbFailedAssignSpareRetryCountMax));
            }
            state.UpdateReseedRecoveryAction(ReseedState.AssignSpare);
            if (string.IsNullOrEmpty(base.Context.TargetCopyStatus.CopyStatus.DatabaseVolumeName) || string.IsNullOrEmpty(base.Context.TargetCopyStatus.CopyStatus.LogVolumeName))
            {
                return(ReplayStrings.AutoReseedFailedToFindTargetVolumeName(AmExceptionHelper.GetMessageOrNoneString(base.Context.TargetCopyStatus.CopyStatus.VolumeInfoLastError)));
            }
            MountedFolderPath mountedFolderPath = new MountedFolderPath(base.Context.TargetCopyStatus.CopyStatus.LogVolumeName);
            MountedFolderPath other             = new MountedFolderPath(base.Context.TargetCopyStatus.CopyStatus.DatabaseVolumeName);

            if (!mountedFolderPath.Equals(other))
            {
                return(ReplayStrings.AutoReseedLogAndDbNotOnSameVolume);
            }
            IEnumerable <CopyStatusClientCachedEntry> enumerable = this.FindTargetDbSetFromDatabaseGroup(base.Context);

            if (enumerable == null)
            {
                enumerable = this.FindTargetDbSetFromNeighbors(base.Context);
                if (enumerable == null)
                {
                    return(ReplayStrings.AutoReseedFailedToFindVolumeName);
                }
            }
            MountedFolderPath mountedFolderPath2;

            if (this.IsVolumeRecentlyAssigned(enumerable, out mountedFolderPath2))
            {
                ReplayCrimsonEvents.AutoReseedWorkflowDbSpareRecentlyAssigned.Log <string, Guid, string, string>(base.Context.Database.Name, base.Context.Database.Guid, base.WorkflowName, base.WorkflowLaunchReason);
                state.AssignedVolumeName = mountedFolderPath2.Path;
                state.UpdateReseedRecoveryAction(ReseedState.InPlaceReseed);
            }
            else if (this.DoesMountPointNeedToBeFixed(enumerable, out mountedFolderPath2))
            {
                base.TraceDebug("Database copy is missing a mount point, and it will be fixed up to point to volume '{0}'", new object[]
                {
                    mountedFolderPath2
                });
                this.m_volumeForMissingMountPoint = mountedFolderPath2;
            }
            else
            {
                string databaseNames = FailedSuspendedCopyAutoReseedWorkflow.GetDatabaseNames(enumerable);
                if (!enumerable.All((CopyStatusClientCachedEntry status) => !status.IsActive))
                {
                    return(ReplayStrings.AutoReseedNotAllCopiesPassive(databaseNames));
                }
                if (!enumerable.All((CopyStatusClientCachedEntry status) => status.Result == CopyStatusRpcResult.Success && status.CopyStatus.CopyStatus == CopyStatusEnum.FailedAndSuspended))
                {
                    return(ReplayStrings.AutoReseedNotAllCopiesOnVolumeFailedSuspended(databaseNames));
                }
            }
            this.m_targetDbSet = enumerable;
            return(LocalizedString.Empty);
        }