recovery

package
v0.0.0-...-0601960 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const HEADER_SIZE uint32 = 20

Variables

This section is empty.

Functions

This section is empty.

Types

type LogManager

type LogManager struct {
	// contains filtered or unexported fields
}

*

  • LogManager maintains a separate thread that is awakened whenever the log buffer is full or whenever a timeout
  • happens. When the thread is awakened, the log buffer's content is written into the disk log file.

func NewLogManager

func NewLogManager(disk_manager *disk.DiskManager) *LogManager

func (*LogManager) ActivateLogging

func (log_manager *LogManager) ActivateLogging()

* set enable_logging = true * Start a separate thread to execute flush to disk operation periodically * The flush can be triggered when the log buffer is full or buffer pool * manager wants to force flush (it only happens when the flushed page has a * larger LSN than persistent LSN)

func (*LogManager) AppendLogRecord

func (log_manager *LogManager) AppendLogRecord(log_record *LogRecord) types.LSN

* append a log record into log buffer * return: lsn that is assigned to this log record

func (*LogManager) DeactivateLogging

func (log_manager *LogManager) DeactivateLogging()

* Stop and join the flush thread, set enable_logging = false

func (*LogManager) Flush

func (log_manager *LogManager) Flush()

func (*LogManager) GetNextLSN

func (log_manager *LogManager) GetNextLSN() types.LSN

func (*LogManager) GetPersistentLSN

func (log_manager *LogManager) GetPersistentLSN() types.LSN

func (*LogManager) IsEnabledLogging

func (log_manager *LogManager) IsEnabledLogging() bool

func (*LogManager) SetNextLSN

func (log_manager *LogManager) SetNextLSN(lsnVal types.LSN)

type LogRecord

type LogRecord struct {
	// the length of log record(for serialization, in bytes)
	Size uint32 //0
	// must have fields
	Lsn             types.LSN     //INVALID_LSN
	Txn_id          types.TxnID   //INVALID_TXN_ID
	Prev_lsn        types.LSN     //INVALID_LSN
	Log_record_type LogRecordType // {LogRecordType::INVALID}

	// case1: for delete opeartion, delete_tuple for UNDO opeartion
	Delete_rid   page.RID
	Delete_tuple tuple.Tuple

	// case2: for insert opeartion
	Insert_rid   page.RID
	Insert_tuple tuple.Tuple

	// case3: for update opeartion
	Update_rid page.RID
	Old_tuple  tuple.Tuple
	New_tuple  tuple.Tuple

	// case4: for new table page opeartion
	Prev_page_id types.PageID
	Page_id      types.PageID

	// case5: for deallocate page operation
	Deallocate_page_id types.PageID

	// case6: for reuse page operation
	Reuse_page_id types.PageID
}

func NewLogRecordDeallocatePage

func NewLogRecordDeallocatePage(page_id types.PageID) *LogRecord

func NewLogRecordGracefulShutdown

func NewLogRecordGracefulShutdown() *LogRecord

func NewLogRecordInsertDelete

func NewLogRecordInsertDelete(txn_id types.TxnID, prev_lsn types.LSN, log_record_type LogRecordType, rid page.RID, tuple *tuple.Tuple) *LogRecord

constructor for INSERT/DELETE type

func NewLogRecordNewPage

func NewLogRecordNewPage(txn_id types.TxnID, prev_lsn types.LSN, log_record_type LogRecordType, prev_page_id types.PageID, page_id types.PageID) *LogRecord

constructor for NEW_TABLE_PAGE type

func NewLogRecordReusePage

func NewLogRecordReusePage(page_id types.PageID) *LogRecord

func NewLogRecordTxn

func NewLogRecordTxn(txn_id types.TxnID, prev_lsn types.LSN, log_record_type LogRecordType) *LogRecord

constructor for Transaction type(BEGIN/COMMIT/ABORT)

func NewLogRecordUpdate

func NewLogRecordUpdate(txn_id types.TxnID, prev_lsn types.LSN, log_record_type LogRecordType, update_rid page.RID,
	old_tuple tuple.Tuple, new_tuple tuple.Tuple) *LogRecord

constructor for UPDATE type

func (*LogRecord) GetDeleteRID

func (log_record *LogRecord) GetDeleteRID() page.RID

func (*LogRecord) GetInsertRID

func (log_record *LogRecord) GetInsertRID() page.RID

func (*LogRecord) GetInserteTuple

func (log_record *LogRecord) GetInserteTuple() tuple.Tuple

func (*LogRecord) GetLSN

func (log_record *LogRecord) GetLSN() types.LSN

func (*LogRecord) GetLogHeaderData

func (log_record *LogRecord) GetLogHeaderData() []byte

func (*LogRecord) GetLogRecordType

func (log_record *LogRecord) GetLogRecordType() LogRecordType

func (*LogRecord) GetNewPageRecord

func (log_record *LogRecord) GetNewPageRecord() types.PageID

func (*LogRecord) GetPrevLSN

func (log_record *LogRecord) GetPrevLSN() types.LSN

func (*LogRecord) GetSize

func (log_record *LogRecord) GetSize() uint32

func (*LogRecord) GetTxnId

func (log_record *LogRecord) GetTxnId() types.TxnID

type LogRecordType

type LogRecordType int32
const (
	INVALID LogRecordType = iota
	INSERT
	MARKDELETE
	APPLYDELETE
	ROLLBACKDELETE
	UPDATE
	BEGIN
	COMMIT
	ABORT
	/** Creating a new page in the table heap. */
	NEW_TABLE_PAGE
	DEALLOCATE_PAGE
	REUSE_PAGE
	// this log represents last shutdown of the system is graceful
	// and this log is located at the end of log file
	GRACEFUL_SHUTDOWN
)

* The type of the log record.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL