public void UpdateFileHeaderAfterDataFileSync(JournalFile file, long maxTransactionId) { var txHeaders = stackalloc TransactionHeader[2]; var readTxHeader = &txHeaders[0]; var lastReadTxHeader = txHeaders[1]; var txPos = 0; while (true) { if (file.ReadTransaction(txPos, readTxHeader) == false) { break; } if (readTxHeader->HeaderMarker != Constants.TransactionHeaderMarker) { break; } if (readTxHeader->TransactionId > maxTransactionId) { break; } lastReadTxHeader = *readTxHeader; var compressedPages = (readTxHeader->CompressedSize / AbstractPager.PageSize) + (readTxHeader->CompressedSize % AbstractPager.PageSize == 0 ? 0 : 1); txPos += compressedPages + 1; } Debug.Assert(_lastSyncedJournal != -1); Debug.Assert(_lastSyncedTransactionId != -1); _waj._headerAccessor.Modify(header => { header->TransactionId = lastReadTxHeader.TransactionId; header->LastPageNumber = lastReadTxHeader.LastPageNumber; header->Journal.LastSyncedJournal = _lastSyncedJournal; header->Journal.LastSyncedTransactionId = _lastSyncedTransactionId; header->Root = lastReadTxHeader.Root; header->FreeSpace = lastReadTxHeader.FreeSpace; header->PreviousTransactionCrc = _waj.Shipper.PreviousTransactionCrc; _waj._updateLogInfo(header); }); }
public void UpdateFileHeaderAfterDataFileSync(JournalFile file, long oldestActiveTransaction) { var txHeaders = stackalloc TransactionHeader[2]; var readTxHeader = &txHeaders[0]; var lastReadTxHeader = txHeaders[1]; var txPos = 0; while (true) { if (file.ReadTransaction(txPos, readTxHeader) == false) { break; } if (readTxHeader->HeaderMarker != Constants.TransactionHeaderMarker) { break; } if (readTxHeader->TransactionId + 1 == oldestActiveTransaction) { break; } lastReadTxHeader = *readTxHeader; int totalSize = readTxHeader->CompressedSize + sizeof(TransactionHeader); int compressedPages = (totalSize / _waj._env.Options.PageSize) + (totalSize % _waj._env.Options.PageSize == 0 ? 0 : 1); // We skip to the next transaction header. txPos += compressedPages; } Debug.Assert(_lastSyncedJournal != -1); Debug.Assert(_lastSyncedTransactionId != -1); _waj._headerAccessor.Modify(header => { header->TransactionId = lastReadTxHeader.TransactionId; header->LastPageNumber = lastReadTxHeader.LastPageNumber; header->Journal.LastSyncedJournal = _lastSyncedJournal; header->Journal.LastSyncedTransactionId = _lastSyncedTransactionId; header->Root = lastReadTxHeader.Root; _waj._updateLogInfo(header); }); }
public void UpdateFileHeaderAfterDataFileSync(JournalFile file, long oldestActiveTransaction) { var txHeaders = stackalloc TransactionHeader[2]; var readTxHeader = &txHeaders[0]; var lastReadTxHeader = txHeaders[1]; var txPos = 0; while (true) { if (file.ReadTransaction(txPos, readTxHeader) == false) break; if (readTxHeader->HeaderMarker != Constants.TransactionHeaderMarker) break; if (readTxHeader->TransactionId + 1 == oldestActiveTransaction) break; lastReadTxHeader = *readTxHeader; var compressedPages = (readTxHeader->CompressedSize / AbstractPager.PageSize) + (readTxHeader->CompressedSize % AbstractPager.PageSize == 0 ? 0 : 1); txPos += compressedPages + 1; } Debug.Assert(_lastSyncedJournal != -1); Debug.Assert(_lastSyncedTransactionId != -1); _waj._headerAccessor.Modify(header => { header->TransactionId = lastReadTxHeader.TransactionId; header->LastPageNumber = lastReadTxHeader.LastPageNumber; header->Journal.LastSyncedJournal = _lastSyncedJournal; header->Journal.LastSyncedTransactionId = _lastSyncedTransactionId; header->Root = lastReadTxHeader.Root; header->FreeSpace = lastReadTxHeader.FreeSpace; header->PreviousTransactionCrc = _waj.Shipper.PreviousTransactionCrc; _waj._updateLogInfo(header); }); }