private void HandleReadError(FileIOonSourceException wrappedEx) { Exception innerException = wrappedEx.InnerException; bool flag = false; if (innerException is CorruptLogDetectedException) { flag = true; } else if (innerException is IOException) { int hresult = 0; if (FileOperations.IsCorruptedIOException(innerException as IOException, out hresult)) { flag = true; int num; FileOperations.ConvertHResultToWin32(hresult, out num); ReplayEventLogConstants.Tuple_FatalIOErrorEncountered.LogEvent(this.Database.Identity, new object[] { this.Database.DatabaseName, wrappedEx.FileFullPath, innerException.Message, num, innerException.ToString() }); } } if (flag) { this.HandleCorruptLog(innerException); return; } this.HandleSourceReadError(wrappedEx); }
public FileIOonSourceException GetE00Generation(out long e00Gen, string e00Filename) { Exception ex = null; FileIOonSourceException result = null; e00Gen = 0L; try { e00Gen = EseHelper.GetLogfileGeneration(e00Filename); ExTraceGlobals.MonitoredDatabaseTracer.TraceDebug <long, string>((long)this.GetHashCode(), "E00 Gen is 0x{0:x} for {1}", e00Gen, e00Filename); } catch (EsentErrorException ex2) { ex = ex2; } catch (IOException ex3) { ex = ex3; } catch (UnauthorizedAccessException ex4) { ex = ex4; } if (ex != null) { ExTraceGlobals.MonitoredDatabaseTracer.TraceError <string, Exception>((long)this.GetHashCode(), "Could not get generation of {0}: {1}", e00Filename, ex); result = new FileIOonSourceException(Environment.MachineName, e00Filename, ex.Message, ex); } return(result); }
private LogCopyServerContext.SendLogStatus SendE00() { string text = this.Database.BuildLogFileName(0L); long num = 0L; FileIOonSourceException ex; if (this.m_dismountWorker == null) { ex = this.Database.GetE00Generation(out num, text); } else { ex = this.m_dismountWorker.LastE00ReadException; } if (ex != null) { bool flag = true; Exception innerException = ex.InnerException; if (innerException != null && innerException is EsentFileAccessDeniedException && !AmStoreServiceMonitor.WasKillTriggered()) { if (this.m_dismountWorker == null) { LogCopyServerContext.Tracer.TraceDebug((long)this.GetHashCode(), "SendE00(): E00 still in use so starting a DismountDatabaseOrKillStore() in background..."); this.m_dismountWorker = new DismountBackgroundWorker(new DismountBackgroundWorker.DismountDelegate(this.DismountDatabaseOrKillStore)); this.m_dismountWorker.LastE00ReadException = ex; this.m_dismountWorker.Start(); } if (this.m_dismountWorker.CompletedEvent.WaitOne(1000)) { if (this.m_dismountWorker.DismountException == null) { flag = false; LogCopyServerContext.Tracer.TraceDebug((long)this.GetHashCode(), "SendE00(): DismountDatabaseOrKillStore() operation completed successfully"); } else { LogCopyServerContext.Tracer.TraceError <Exception>((long)this.GetHashCode(), "SendE00(): DismountDatabaseOrKillStore() operation completed but encountered an exception: {0}", this.m_dismountWorker.DismountException); } this.m_dismountWorker.Dispose(); this.m_dismountWorker = null; } else if ((ExDateTime.Now - this.m_dismountWorker.StartTime).TotalMilliseconds < (double)(RegistryParameters.AcllDismountOrKillTimeoutInSec2 * 1000)) { return(LogCopyServerContext.SendLogStatus.KeepChannelAlive); } } if (!flag) { this.Database.ProbeForMoreLogs(this.m_currentLogGeneration); return(LogCopyServerContext.SendLogStatus.KeepTrying); } this.HandleSourceReadError(ex); return(LogCopyServerContext.SendLogStatus.StopForException); } else if (num != this.m_currentLogGeneration) { LogCopyServerContext.Tracer.TraceDebug <long, long>((long)this.GetHashCode(), "SendE00 finds e00 at 0x{0:X} but expected 0x{1:X}", num, this.m_currentLogGeneration); if (num > this.m_currentLogGeneration) { this.Database.SyncWithE00(num); return(LogCopyServerContext.SendLogStatus.KeepTrying); } AcllFailedException e = new AcllFailedException(ReplayStrings.LogCopierE00InconsistentError(num, this.m_currentLogGeneration)); this.SendException(e); return(LogCopyServerContext.SendLogStatus.StopForException); } else { Exception ex2 = null; try { using (SafeFileHandle safeFileHandle = LogCopy.OpenLogForRead(text)) { CopyLogReply copyLogReply = new CopyLogReply(this.Channel); copyLogReply.ThisLogGeneration = 0L; copyLogReply.EndOfLogGeneration = num; copyLogReply.EndOfLogUtc = DateTime.UtcNow; CheckSummer summer = null; if (this.Channel.ChecksumDataTransfer) { summer = new CheckSummer(); } this.Channel.SendLogFileTransferReply(copyLogReply, text, safeFileHandle, this.SourceDatabasePerfCounters, summer); } } catch (IOException ex3) { ex2 = new FileIOonSourceException(Environment.MachineName, text, ex3.Message, ex3); } catch (UnauthorizedAccessException ex4) { ex2 = new FileIOonSourceException(Environment.MachineName, text, ex4.Message, ex4); } catch (FileIOonSourceException ex5) { ex2 = ex5; } if (ex2 != null) { this.HandleSourceReadError(ex2); return(LogCopyServerContext.SendLogStatus.StopForException); } return(LogCopyServerContext.SendLogStatus.SentE00); } }