Documentation
¶
Overview ¶
Package checkpoint provides checkpoint management for XxSql storage engine.
Index ¶
- Constants
- type Checkpoint
- type CheckpointStats
- type Manager
- func (m *Manager) Create() (*Checkpoint, error)
- func (m *Manager) DeleteCheckpoint() error
- func (m *Manager) GetLastCheckpoint() *Checkpoint
- func (m *Manager) GetRecoveryInfo() (*RecoveryInfo, error)
- func (m *Manager) NeedsCheckpoint() (bool, error)
- func (m *Manager) Recover() error
- func (m *Manager) SetBufferPool(bp *buffer.BufferPool)
- func (m *Manager) SetRecoveryHandler(handler RecoveryHandler)
- func (m *Manager) SetWALManager(wm *wal.Manager)
- func (m *Manager) Start() error
- func (m *Manager) Stats() CheckpointStats
- func (m *Manager) Stop()
- func (m *Manager) TruncateWAL() error
- type ManagerConfig
- type RecoveryHandler
- type RecoveryInfo
- type TableRecoveryInfo
Constants ¶
const ( // CheckpointFileExt is the extension for checkpoint files. CheckpointFileExt = ".xckpt" // CheckpointMetaFile is the checkpoint metadata file. CheckpointMetaFile = "checkpoint.meta" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checkpoint ¶
type Checkpoint struct {
ID uint64
LSN wal.LSN
Timestamp int64
TableCount int
RowCount uint64
PageCount uint64
ActiveTxns []uint64
Metadata map[string]string
}
Checkpoint represents a database checkpoint.
type CheckpointStats ¶
type CheckpointStats struct {
AutoEnabled bool `json:"auto_enabled"`
Interval string `json:"interval"`
LastCheckpointID uint64 `json:"last_checkpoint_id"`
LastCheckpointLSN uint64 `json:"last_checkpoint_lsn"`
LastCheckpointTime string `json:"last_checkpoint_time"`
PageCount uint64 `json:"page_count"`
RowCount uint64 `json:"row_count"`
}
CheckpointStats holds checkpoint statistics.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages checkpoint operations.
func NewManager ¶
func NewManager(config ManagerConfig) *Manager
NewManager creates a new checkpoint manager.
func (*Manager) Create ¶
func (m *Manager) Create() (*Checkpoint, error)
Create creates a new checkpoint.
func (*Manager) DeleteCheckpoint ¶
DeleteCheckpoint removes checkpoint files.
func (*Manager) GetLastCheckpoint ¶
func (m *Manager) GetLastCheckpoint() *Checkpoint
GetLastCheckpoint returns the last checkpoint.
func (*Manager) GetRecoveryInfo ¶
func (m *Manager) GetRecoveryInfo() (*RecoveryInfo, error)
GetRecoveryInfo returns recovery information.
func (*Manager) NeedsCheckpoint ¶
NeedsCheckpoint returns true if a checkpoint is needed.
func (*Manager) SetBufferPool ¶
func (m *Manager) SetBufferPool(bp *buffer.BufferPool)
SetBufferPool sets the buffer pool.
func (*Manager) SetRecoveryHandler ¶
func (m *Manager) SetRecoveryHandler(handler RecoveryHandler)
SetRecoveryHandler sets the recovery handler for WAL replay.
func (*Manager) SetWALManager ¶
SetWALManager sets the WAL manager.
func (*Manager) Stats ¶
func (m *Manager) Stats() CheckpointStats
Stats returns checkpoint statistics.
func (*Manager) TruncateWAL ¶
TruncateWAL truncates the WAL after a successful checkpoint.
type ManagerConfig ¶
type ManagerConfig struct {
DataDir string
WALManager *wal.Manager
BufferPool *buffer.BufferPool
Interval time.Duration
MaxWALSize int64
AutoEnabled bool
}
ManagerConfig holds checkpoint manager configuration.
type RecoveryHandler ¶
type RecoveryHandler interface {
// ApplyInsert applies an insert operation during recovery.
ApplyInsert(tableName string, data []byte) error
// ApplyUpdate applies an update operation during recovery.
ApplyUpdate(tableName string, data []byte) error
// ApplyDelete applies a delete operation during recovery.
ApplyDelete(tableName string, data []byte) error
// ApplyPageWrite applies a page write operation during recovery.
ApplyPageWrite(pageID uint64, data []byte) error
}
RecoveryHandler defines the interface for handling WAL record recovery.
type RecoveryInfo ¶
type RecoveryInfo struct {
CheckpointLSN wal.LSN
CurrentLSN wal.LSN
Tables []TableRecoveryInfo
}
RecoveryInfo holds information needed for recovery.