pitr

package
v0.5.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// MetadataStorePath is the path to log metadata catalog.
	MetadataStorePath = "catalog"
)

Variables

This section is empty.

Functions

func Merge

func Merge(metadata LogMetadata) [][]string

Merge reads all metadata and merge time ranges covered by replicated redo logs.

func RunLogReplication

func RunLogReplication(ctx context.Context, dbdClient dbdpb.DatabaseDaemonClient, dest string, hashStore *SimpleStore) error

RunLogReplication starts redo logs replication. It runs below steps repeatedly Read archived redo logs location with dbdClient at very beginning or after a success sync., sync redo logs to dest specified location.

func RunLogRetention

func RunLogRetention(ctx context.Context, retentionDays int, metadataStore *SimpleStore, hashStore *SimpleStore) error

RunLogRetention starts redo logs cleanup.

func RunMetadataUpdate

func RunMetadataUpdate(ctx context.Context, dbdClient dbdpb.DatabaseDaemonClient, hashStore *SimpleStore, metadataStore *SimpleStore) error

RunMetadataUpdate starts metadata update. It runs below steps repeatedly Read archived redo logs view with dbdClient, cumulatively update log metadata into metaStore.

func SetArchiveLag

func SetArchiveLag(ctx context.Context, dbdClient dbdpb.DatabaseDaemonClient) error

SetArchiveLag sets archive lag target parameter in the database if the value is 0.

func StageLogs

func StageLogs(ctx context.Context, destDir string, include func(entry LogMetadataEntry) bool, logPath string) error

StageLogs copies redo logs from src dir to dest dir.

Types

type LogHashEntry

type LogHashEntry struct {
	// Crc32cHash stores the crc32c hash of a redo log.
	Crc32cHash string
	// ReplicaPath stores the path of a replicated redo log.
	ReplicaPath string
	// ModTime stores the mod time of a redo log after replication.
	ModTime time.Time
}

LogHashEntry stores hash information for a redo log.

type LogMetadata

type LogMetadata struct {
	// KeyToLogEntry stores redo logs information in a map.
	// key is used for deduplicate
	KeyToLogEntry map[string]LogMetadataEntry
}

LogMetadata stores metadata information for redo logs.

type LogMetadataEntry

type LogMetadataEntry struct {
	// LogHashEntry stores hash information for a redo log.
	LogHashEntry
	// SrcPath stores the path of a redo log in original environment.
	SrcPath string
	// FirstChange stores the first SCN(inclusive) of a redo log.
	FirstChange string // SCN inclusive
	// NextChange stores the next SCN(exclusive) of a redo log.
	NextChange string
	// 	FirstChange stores the first timestamp (inclusive) of a redo log.
	//	we used TO_CHAR(DATE, 'YYYY-MM-DD"T"HH24:MI:SS"Z"')
	FirstTime time.Time
	// 	NextTime stores the next timestamp (inclusive) of a redo log.
	//	we used TO_CHAR(DATE, 'YYYY-MM-DD"T"HH24:MI:SS"Z"')
	NextTime time.Time
	// CompletionTime stores the timestamp when a redo log was archived.
	CompletionTime string
	// Sequence stores the sequence of a archived redo log.
	Sequence string
	// Incarnation stores the Incarnation of a archived redo log.
	Incarnation string
	// Thread stores the redo thread number
	Thread string
}

LogMetadataEntry stores metadata information for a redo log.

type SimpleStore

type SimpleStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SimpleStore implements a simple data store to read and write golang objects.

func NewSimpleStore

func NewSimpleStore(ctx context.Context, dataDir string) (*SimpleStore, error)

NewSimpleStore returns a SimpleStore, SimpleStore will store data under the specified dataDir. '/' will be appended to the dataDir if it does not end with '/'

func (*SimpleStore) Close

func (s *SimpleStore) Close(ctx context.Context) error

Close closes the storage client of the store.

func (*SimpleStore) Lock

func (s *SimpleStore) Lock()

Lock locks this store.

func (*SimpleStore) Read

func (s *SimpleStore) Read(ctx context.Context, path string, data interface{}) (retErr error)

Read retrieves a golang object from this SimpleStore and decode it into data. This method is unsafe for concurrent use. It's caller's responsibility to call SimpleStore.Lock()/SimpleStore.UnLock() for synchronization between goroutines.

func (*SimpleStore) UnLock

func (s *SimpleStore) UnLock()

UnLock unlocks this store.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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