public EsentErrorException Verify(string logfile, byte[] logInMemory) { EsentErrorException ex = null; lock (this) { this.AssertNotTerminated(); try { UnpublishedApi.ChecksumLogFromMemory(this.Sesid, logfile, this.m_basename, logInMemory); LogChecksummer.Tracer.TraceDebug <string>((long)this.GetHashCode(), "LogChecksummer({0}) verified.", logfile); } catch (EsentLogFileCorruptException ex2) { ex = ex2; } catch (EsentErrorException ex3) { ex = ex3; } if (ex != null) { LogChecksummer.Tracer.TraceError <string, EsentErrorException>((long)this.GetHashCode(), "LogChecksummer({0}) failed:{1}", logfile, ex); } } return(ex); }
public void Dump(string logfile) { this.AssertNotTerminated(); this.m_dbutil.szDatabase = logfile; ExTraceGlobals.EseutilWrapperTracer.TraceDebug <string>((long)this.GetHashCode(), "Dumping {0}", logfile); UnpublishedApi.JetDBUtilities(this.Dbutil); ExTraceGlobals.EseutilWrapperTracer.TraceDebug <string>((long)this.GetHashCode(), "Dumping of logfile {0} detected no errors", logfile); }
public void Initialize(long logGeneration, string logPath, string prefix, string suffix) { string text = Path.Combine(logPath, EseHelper.MakeLogfileName(prefix, suffix, logGeneration)); this.Initialized = false; try { JET_LOGINFOMISC logInfo; UnpublishedApi.JetGetLogFileInfo(text, out logInfo, JET_LogInfo.Misc2); LocalizedString localizedString; this.Examine(logInfo, text, out localizedString); } catch (EsentErrorException ex) { LogContinuityChecker.Tracer.TraceError <string, EsentErrorException>((long)this.GetHashCode(), "LogContinuityChecker failed to init with '{0}': {1}", text, ex); throw new LogInspectorFailedGeneralException(text, ex.Message, ex); } }
public EsentErrorException Verify(string logfile) { lock (this) { this.AssertNotTerminated(); this.m_dbutil.szDatabase = logfile; try { ExTraceGlobals.EseutilWrapperTracer.TraceDebug <string>((long)this.GetHashCode(), "Verifying {0}", logfile); UnpublishedApi.JetDBUtilities(this.Dbutil); ExTraceGlobals.EseutilWrapperTracer.TraceDebug <string>((long)this.GetHashCode(), "Verification of logfile {0} detected no errors", logfile); ExTraceGlobals.PFDTracer.TracePfd <int, string>((long)this.GetHashCode(), "PFD CRS {0} Verification of logfile {1} detected no errors", 31211, logfile); } catch (EsentErrorException ex) { ExTraceGlobals.EseutilWrapperTracer.TraceError <string, EsentErrorException>((long)this.GetHashCode(), "Verification of logfile {0} detected corruption: {1}", logfile, ex); return(ex); } } return(null); }
public static Exception Verify(string fileName, string logFilePrefix, long expectedGen, JET_SIGNATURE?expectedLogSignature) { LogVerifier logVerifier = new LogVerifier(logFilePrefix); EsentErrorException ex = logVerifier.Verify(fileName); if (ex != null) { return(ex); } JET_LOGINFOMISC jet_LOGINFOMISC; UnpublishedApi.JetGetLogFileInfo(fileName, out jet_LOGINFOMISC, JET_LogInfo.Misc2); if ((long)jet_LOGINFOMISC.ulGeneration != expectedGen) { return(new FileCheckLogfileGenerationException(fileName, (long)jet_LOGINFOMISC.ulGeneration, expectedGen)); } if (expectedLogSignature != null && !jet_LOGINFOMISC.signLog.Equals(expectedLogSignature)) { return(new FileCheckLogfileSignatureException(fileName, jet_LOGINFOMISC.signLog.ToString(), expectedLogSignature.ToString())); } return(null); }
// Token: 0x06001D67 RID: 7527 RVA: 0x00084D0C File Offset: 0x00082F0C private Exception VerifyLog(string fullLocalFileName, long expectedGen) { Exception ex = null; try { ReplayStopwatch replayStopwatch = new ReplayStopwatch(); replayStopwatch.Start(); using (SafeFileHandle safeFileHandle = LogCopy.OpenLogForRead(fullLocalFileName)) { long arg = replayStopwatch.ElapsedMilliseconds; LogRepair.Tracer.TracePerformance <string, long>((long)this.GetHashCode(), "VerifyLog({0}): Open took: {1} ms", fullLocalFileName, arg); using (FileStream fileStream = LogCopy.OpenFileStream(safeFileHandle, true)) { FileInfo fileInfo = new FileInfo(fullLocalFileName); long elapsedMilliseconds; try { if (fileInfo.Length != 1048576L) { throw new IOException(string.Format("Unexpected log file size: '{0}' has 0x{1:X} bytes.", fullLocalFileName, fileInfo.Length)); } elapsedMilliseconds = replayStopwatch.ElapsedMilliseconds; int num = fileStream.Read(this.m_verifierLogDataBuf, 0, 1048576); if (num != 1048576) { LogRepair.Tracer.TraceError <int, int, string>((long)this.GetHashCode(), "VerifyLog. Expected {0} but got {1} bytes from {2}", 1048576, num, fullLocalFileName); throw new IOException(ReplayStrings.UnexpectedEOF(fullLocalFileName)); } arg = replayStopwatch.ElapsedMilliseconds - elapsedMilliseconds; LogRepair.Tracer.TracePerformance <string, long>((long)this.GetHashCode(), "VerifyLog({0}): Read took: {1} ms", fullLocalFileName, arg); } catch (IOException ex2) { throw new CorruptLogDetectedException(fullLocalFileName, ex2.Message, ex2); } elapsedMilliseconds = replayStopwatch.ElapsedMilliseconds; EsentErrorException ex3 = this.EseLogVerifier.Verify(fullLocalFileName, this.m_verifierLogDataBuf); if (ex3 != null) { LogRepair.Tracer.TraceError <string, EsentErrorException>((long)this.GetHashCode(), "ESELogVerifier({0}) failed: {1}", fullLocalFileName, ex3); if (ex3 is EsentLogFileCorruptException) { throw new CorruptLogDetectedException(fullLocalFileName, ex3.Message, ex3); } throw ex3; } else { JET_LOGINFOMISC jet_LOGINFOMISC; UnpublishedApi.JetGetLogFileInfo(fullLocalFileName, out jet_LOGINFOMISC, JET_LogInfo.Misc2); if ((long)jet_LOGINFOMISC.ulGeneration != expectedGen) { throw new FileCheckLogfileGenerationException(fullLocalFileName, (long)jet_LOGINFOMISC.ulGeneration, expectedGen); } if (this.m_logfileSignature == null) { this.m_logfileSignature = new JET_SIGNATURE?(jet_LOGINFOMISC.signLog); } if (!jet_LOGINFOMISC.signLog.Equals(this.m_logfileSignature)) { throw new FileCheckLogfileSignatureException(fullLocalFileName, jet_LOGINFOMISC.signLog.ToString(), this.m_logfileSignature.ToString()); } arg = replayStopwatch.ElapsedMilliseconds - elapsedMilliseconds; LogRepair.Tracer.TracePerformance <string, long>((long)this.GetHashCode(), "VerifyLog({0}): Verify took: {1} ms", fullLocalFileName, arg); return(null); } } } } catch (IOException ex4) { ex = ex4; } catch (UnauthorizedAccessException ex5) { ex = ex5; } catch (EsentErrorException ex6) { ex = ex6; } catch (CorruptLogDetectedException ex7) { ex = ex7; } catch (FileCheckException ex8) { ex = ex8; } if (ex != null) { LogRepair.Tracer.TraceError <string, Exception>((long)this.GetHashCode(), "VerifyLog({0}): failed with {1}", fullLocalFileName, ex); } return(ex); }
public void Write(JET_EMITDATACTX emitCtx, byte[] databuf, int startOffset) { if (!this.m_jetConsumerInitialized) { throw new GranularReplicationTerminatedException("Already terminated"); } try { StopwatchStamp stamp = StopwatchStamp.GetStamp(); long num = (long)emitCtx.lgposLogData.lGeneration; int grbitOperationalFlags = (int)emitCtx.grbitOperationalFlags; bool flag = false; if (BitMasker.IsOn(grbitOperationalFlags, 16)) { flag = true; } UnpublishedApi.JetConsumeLogData(this.m_jetConsumer, emitCtx, databuf, startOffset, (int)emitCtx.cbLogData, ShadowLogConsumeGrbit.FlushData); if (flag) { GranularWriter.Tracer.TraceDebug <string, long>((long)this.GetHashCode(), "WriteGranular({0}): 0x{1:X} is complete", this.DatabaseName, num); if (this.m_lowestClosedGeneration == 0L) { this.m_lowestClosedGeneration = num; } string text = this.FormFullGranuleName(num); FileInfo fileInfo = new FileInfo(text); fileInfo.LastWriteTimeUtc = emitCtx.logtimeEmit; if (this.m_granularCompletionsDisabled) { string destFileName = this.FormInspectorLogfileName(num); File.Move(text, destFileName); this.TrackInspectorGeneration(num, emitCtx.logtimeEmit); this.m_lowestClosedGeneration = num + 1L; } this.m_currentGenerationState = GranularWriter.GranularLogState.Expected; this.m_currentGeneration = num + 1L; } else if (BitMasker.IsOn(grbitOperationalFlags, 8)) { this.m_currentGenerationState = GranularWriter.GranularLogState.Open; this.m_currentGeneration = num; this.m_lastTimeFromServer = new DateTime?(emitCtx.logtimeEmit); } long elapsedTicks = stamp.ElapsedTicks; this.m_perfmonCounters.RecordBlockModeConsumerWriteLatency(elapsedTicks); GranularWriter.Tracer.TracePerformance((long)this.GetHashCode(), "WriteGranular({0},0x{1:X}.0x{2:X}) EmitSeq=0x{3:X} took {4} uSec", new object[] { this.DatabaseName, emitCtx.lgposLogData.lGeneration, emitCtx.lgposLogData.isec, emitCtx.qwSequenceNum, StopwatchStamp.TicksToMicroSeconds(elapsedTicks) }); } catch (EsentErrorException ex) { GranularWriter.Tracer.TraceError <EsentErrorException>((long)this.GetHashCode(), "JetConsumeLogData threw {0}", ex); this.m_jetConsumerHealthy = false; throw new GranularReplicationTerminatedException(ex.Message, ex); } catch (IOException ex2) { GranularWriter.Tracer.TraceError <IOException>((long)this.GetHashCode(), "IOException: {0}", ex2); this.m_jetConsumerHealthy = false; throw new GranularReplicationTerminatedException(ex2.Message, ex2); } }
internal void SendLog(long logGen, NetworkChannel channel, SourceDatabasePerformanceCountersInstance perfCounters) { ReplayStopwatch replayStopwatch = new ReplayStopwatch(); replayStopwatch.Start(); string text = this.BuildLogFileName(logGen); Exception ex = null; try { using (SafeFileHandle safeFileHandle = LogCopy.OpenLogForRead(text)) { try { JET_LOGINFOMISC jet_LOGINFOMISC; UnpublishedApi.JetGetLogFileInfo(text, out jet_LOGINFOMISC, JET_LogInfo.Misc2); if (logGen != 0L && (long)jet_LOGINFOMISC.ulGeneration != logGen) { FileCheckLogfileGenerationException ex2 = new FileCheckLogfileGenerationException(text, (long)jet_LOGINFOMISC.ulGeneration, logGen); CorruptLogDetectedException ex3 = new CorruptLogDetectedException(text, ex2.Message, ex2); throw new FileIOonSourceException(Environment.MachineName, text, ex3.Message, ex3); } JET_SIGNATURE?jet_SIGNATURE = null; lock (this.m_sigLock) { if (this.m_logfileSignature == null) { this.m_logfileSignature = new JET_SIGNATURE?(jet_LOGINFOMISC.signLog); } jet_SIGNATURE = this.m_logfileSignature; } if (!jet_LOGINFOMISC.signLog.Equals(jet_SIGNATURE)) { FileCheckLogfileSignatureException ex4 = new FileCheckLogfileSignatureException(text, jet_LOGINFOMISC.signLog.ToString(), jet_SIGNATURE.Value.ToString()); CorruptLogDetectedException ex5 = new CorruptLogDetectedException(text, ex4.Message, ex4); throw new FileIOonSourceException(Environment.MachineName, text, ex5.Message, ex5); } } catch (EsentLogFileCorruptException ex6) { CorruptLogDetectedException ex7 = new CorruptLogDetectedException(text, ex6.Message, ex6); throw new FileIOonSourceException(Environment.MachineName, text, ex7.Message, ex7); } EndOfLog currentEndOfLog = this.CurrentEndOfLog; CopyLogReply copyLogReply = new CopyLogReply(channel); copyLogReply.ThisLogGeneration = logGen; copyLogReply.EndOfLogGeneration = currentEndOfLog.Generation; copyLogReply.EndOfLogUtc = currentEndOfLog.Utc; CheckSummer summer = null; if (channel.ChecksumDataTransfer) { summer = new CheckSummer(); } channel.SetupLogChecksummer(this.Config.LogFilePrefix); channel.SendLogFileTransferReply(copyLogReply, text, safeFileHandle, perfCounters, summer); MonitoredDatabase.Tracer.TracePerformance <long>((long)this.GetHashCode(), "CopyLogFile finished streaming after {0}ms.", replayStopwatch.ElapsedMilliseconds); } } catch (IOException ex8) { ex = ex8; } catch (UnauthorizedAccessException ex9) { ex = ex9; } catch (EsentErrorException ex10) { ex = ex10; } if (ex != null) { ExTraceGlobals.MonitoredDatabaseTracer.TraceError <string, Exception>((long)this.GetHashCode(), "SendLog({0}) failed: {1}", text, ex); throw new FileIOonSourceException(Environment.MachineName, text, ex.Message, ex); } }
// Token: 0x0600095C RID: 2396 RVA: 0x0002BF38 File Offset: 0x0002A138 public static long DumpCheckpoint(string checkpointFile) { int logGenFromCheckpointFileInfo = UnpublishedApi.GetLogGenFromCheckpointFileInfo(checkpointFile); return((long)logGenFromCheckpointFileInfo); }
// Token: 0x06000969 RID: 2409 RVA: 0x0002C435 File Offset: 0x0002A635 public static long GetLogfileGeneration(string logfilePath, out JET_LOGINFOMISC logInfo) { UnpublishedApi.JetGetLogFileInfo(logfilePath, out logInfo, JET_LogInfo.Misc2); return((long)logInfo.ulGeneration); }