Documentation
¶
Overview ¶
Package chain builds recovery chains from backup manifests.
Index ¶
- func LoadPartial(ctx context.Context, store storage.Storage, opts ...Option) (*Chain, []Unreadable, error)
- type Chain
- func (c *Chain) ClusterPoints() []ClusterPoint
- func (c *Chain) Groups() []Group
- func (c *Chain) Latest() *Entry
- func (c *Chain) Manifests() []*backup.ClusterManifest
- func (c *Chain) PlanFor(point ClusterPoint) (Plan, error)
- func (c *Chain) Problems() []*Problem
- func (c *Chain) Resolve(target time.Time) Resolution
- type ClusterPoint
- type Entry
- type Group
- type Option
- type Plan
- type Position
- type Problem
- type ProblemKind
- type Resolution
- type Selection
- type ShardPlan
- type Status
- type Unreadable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadPartial ¶
func LoadPartial( ctx context.Context, store storage.Storage, opts ...Option, ) (*Chain, []Unreadable, error)
LoadPartial builds the chain from the manifests it could read and returns the ones it could not, so that a diagnostic caller (tt backup verify) reports a single broken object instead of going blind on the whole storage.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain is the in-memory view of all manifests in one storage.
func Build ¶
func Build(manifests []*backup.ClusterManifest, opts ...Option) (*Chain, error)
Build groups manifests, attaches own and inherited chain problems, and stitches cluster recovery points.
func Load ¶
Load reads every stored manifest and builds a fully marked chain. A manifest that cannot be read or decoded fails the whole load: a chain silently missing a link would send its caller down a broken recovery path. Callers that diagnose the storage rather than recover from it use LoadPartial.
func (*Chain) ClusterPoints ¶
func (c *Chain) ClusterPoints() []ClusterPoint
ClusterPoints returns cluster recovery points ordered by effective timestamp.
func (*Chain) Manifests ¶
func (c *Chain) Manifests() []*backup.ClusterManifest
Manifests returns every loaded manifest, including problematic ones.
func (*Chain) PlanFor ¶
func (c *Chain) PlanFor(point ClusterPoint) (Plan, error)
PlanFor builds per-replicaset backup paths for a cluster recovery point, or errors if p is not a point produced by this chain.
type ClusterPoint ¶
type ClusterPoint struct {
// Name is the manager-generated common point name.
Name string
// Timestamp is the earliest timestamp among the shard points.
Timestamp time.Time
// Topology of the segment this point was stitched in, constant within it.
// It lists every backed-up replicaset, including those a selection left out
// of Shards; a consumer that cares only about the restored ones narrows it
// by the keys of Shards. Consumers compare it against the live cluster;
// chain does not.
Topology backup.Topology
// Shards maps a replicaset UUID to its position at this point.
Shards map[string]Position
}
ClusterPoint joins equally named points from every replicaset in a segment.
type Entry ¶
type Entry struct {
// Manifest is the original cluster manifest.
Manifest *backup.ClusterManifest
// Problems is empty only when this manifest is usable for recovery.
Problems []*Problem
}
Entry is one manifest and the chain problems that make it unusable.
type Group ¶
type Group struct {
// Entries starts with the full backup and follows previous_backup_id.
Entries []*Entry
}
Group is a cascade-deletion unit rooted at one full backup.
type Option ¶
type Option func(*buildOptions)
Option tunes how a chain is built.
func WithSelection ¶
WithSelection stitches cluster points over the selected replicasets only: a point name becomes a cluster point once it is present on each selected replicaset, whatever the others carry, and the point holds positions for the selected ones alone. Grouping and chain problems are unaffected - every manifest is still read whole.
type Plan ¶
type Plan struct {
// Point is the recovery target.
Point ClusterPoint
// Shards maps a replicaset UUID to the backup path needed for it.
Shards map[string]ShardPlan
}
Plan describes all backups required to recover one cluster point.
type Position ¶
type Position struct {
// ReplicaID is the source instance identifier in the replicaset.
ReplicaID uint32
// LSN is the xlog position on that replica.
LSN uint64
}
Position is a recovery position inside one replicaset.
type Problem ¶
type Problem struct {
// Kind classifies the problem.
Kind ProblemKind
// BackupID identifies the manifest whose recovery path is affected.
BackupID string
// Inherited reports that the problem originated in an ancestor.
Inherited bool
// Detail identifies the missing, conflicting, or mismatched link.
Detail string
}
Problem is a chain problem attached to one manifest.
type ProblemKind ¶
type ProblemKind int
ProblemKind identifies a manifest's place in a broken chain.
const ( ProblemOrphan ProblemKind = iota ProblemFork ProblemVclockMismatch ProblemInvalidManifest )
type Resolution ¶
type Resolution struct {
// Status explains whether Point can be used.
Status Status
// Point is selected for StatusOK, or the last healthy point before a break.
Point *ClusterPoint
// Before and After are nearest points around an unresolved target time.
Before *ClusterPoint
After *ClusterPoint
}
Resolution is the result of resolving a requested recovery time.
type Selection ¶
type Selection struct {
// contains filtered or unexported fields
}
Selection narrows the replicasets a cluster point is stitched over. It is expressed as a set of instance names because a manifest knows instances and replicaset UUIDs, while the operator names replicasets the way the cluster config does. A nil *Selection covers every replicaset.
func SelectInstances ¶
SelectInstances builds a selection from instance names. A replicaset is selected when at least one of its topology instances carries one of them.
type ShardPlan ¶
type ShardPlan struct {
// Backups starts with a full backup and continues with incrementals.
Backups []*backup.ClusterManifest
// TrimTo limits the final incremental to the requested position.
TrimTo *Position
}
ShardPlan is an ordered backup path for one replicaset.
type Status ¶
type Status int
Status describes the result of resolving a requested recovery time.
func (Status) MarshalJSON ¶
MarshalJSON encodes a status as its string.
type Unreadable ¶
type Unreadable struct {
// Key is the storage key of the manifest.
Key string
// Err explains why the manifest could not be used.
Err error
}
Unreadable is a listed manifest that could not be turned into a chain entry.