Documentation
¶
Index ¶
- Variables
- func FindTrimFile(dir string, replicaID uint32, lsn int64) (string, error)
- func JournalsAfter(snapshotDir, walDir string, signature int64) ([]string, error)
- func PatchInstanceUUID(src, dst, newUUID string) error
- func SignatureOf(path string) (int64, error)
- func TruncateAt(src, dst string, replicaID uint32, lsn int64) error
- type ClusterMember
- type SnapshotNames
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidUUID = errors.New("xlog: invalid instance UUID") ErrTrimFileNotFound = errors.New("xlog: no xlog file contains the recovery point") ErrLSNOverflow = errors.New("xlog: lsn out of range for int64<->uint64 conversion") ErrInPlaceWidthMismatch = errors.New( "xlog: on-disk UUID width differs from replacement; use distinct src and dst") )
Functions ¶
func FindTrimFile ¶
FindTrimFile returns the .xlog in dir whose transaction stream includes the point (replicaID, lsn).
func JournalsAfter ¶
JournalsAfter returns the .snap files in snapshotDir and the .xlog files in walDir that start strictly after signature — the part of a backup that reaches past a recovery point. The two are separate arguments because Tarantool keeps snapshots and journals in directories of their own (snapshot.dir and wal.dir); passing one directory twice is the case where they are configured to the same place.
func PatchInstanceUUID ¶
PatchInstanceUUID rewrites the Instance field in the src header writing to dst.
func SignatureOf ¶
SignatureOf returns a journal file's start position: the vclock signature its name encodes and its meta header repeats.
func TruncateAt ¶
TruncateAt copies transactions from src to dst up to and including the one that reaches the recovery point (replicaID, lsn), and drops everything after it. A transaction is never split: one straddling the point is kept whole. When no transaction reaches the point, everything is kept.
Truncation is positional, not per-replica. A recovery point marks a place in the log, so every transaction ahead of it belongs to the state it describes, whichever replica wrote it. A master's journal does carry rows from the other members of its replicaset — a vclock like {1: 1502, 2: 230} is the normal case — and filtering by "rows of replicaID up to lsn" would drop all of those, including ones committed long before the point.
The meta header is carried over verbatim. A journal file's VClock is the position it *starts* at, and its name is that vclock's signature, so dropping a tail never moves it: rewriting VClock to the kept content's end would desynchronize the header from the file name, which dir.OpenDir rejects (ErrSignatureMismatch) and Tarantool treats as fatal in xdir_open_cursor (src/box/xlog.c:451).
Types ¶
type ClusterMember ¶
type ClusterMember struct {
// ID is the numeric id the replicaset knows the member by.
ID uint32
// UUID is the member's instance UUID, in the 36-char form Tarantool
// stores it in.
UUID string
// Name is the member's instance name, empty for a member the replicaset
// registered without one.
Name string
}
ClusterMember is one row of _cluster as a snapshot records it.
func MembershipAt ¶
func MembershipAt(snapshot string, journals []string) ([]ClusterMember, error)
MembershipAt answers: what does a replay of exactly these files end with? It folds the _cluster a snapshot carries with the _cluster changes the journals after it hold, in the order given -- the membership an instance restored onto them boots into, the one restore apply verifies a --patch-uuid against. A replace or insert writes the member its tuple names, a delete forgets the member its key names, and an update names a member the replicaset had registered nameless.
func MembershipUpTo ¶
func MembershipUpTo( snapshot string, journals []string, upto format.VClock, ) ([]ClusterMember, error)
MembershipUpTo answers: what does the range the freeze closed end with? It is the MembershipAt fold clamped at upto: a row whose LSN is strictly greater than upto[row.ReplicaID] is skipped, and a replica id absent from upto counts as 0, so every row of a replica the freeze never saw is dropped -- that replica wrote nothing inside the frozen range, and any of its rows in the files lie past the freeze. The clamp keeps out what a pinned journal gains after the freeze: the files keep growing until the backup is finalized, and rows past the frozen vclock are outside the promise the backup's fragment makes. This is the membership a backup's data restores; MembershipAt stays the unclamped answer restore apply uses.
func ReadCluster ¶
func ReadCluster(path string) ([]ClusterMember, error)
ReadCluster returns the _cluster membership a snapshot file records: every member the replicaset had when the snapshot was taken, the instance the backup was taken on included. The snapshot's other spaces are not decoded for their bodies.
type SnapshotNames ¶
type SnapshotNames struct {
// InstanceUUID is the UUID the snapshot's header carries -- the instance
// the data belongs to, and what `tt restore apply --patch-uuid` stamps.
InstanceUUID string
// InstanceName is the name of the _cluster row whose UUID is the header's,
// empty when no row carries that UUID or the row carries no name.
InstanceName string
// ReplicasetUUID and ReplicasetName are the _schema entries, empty when
// the snapshot holds none.
ReplicasetUUID string
ReplicasetName string
// Members is the _cluster the snapshot was taken with.
Members []ClusterMember
}
SnapshotNames is what a snapshot alone says about whose data it is: the instance UUID of its header, the _cluster it was taken with, and the replicaset UUID and name its _schema holds.
It is the very set of facts Tarantool's configuration reads before it lets an instance start on a data directory (snapshot.get_names), and it reads them from the newest snapshot only: the journals after it are replayed by box.cfg, which runs after that check has passed. A name a journal gives the instance therefore does not count for starting, however surely the replay ends with it.
func ReadSnapshotNames ¶
func ReadSnapshotNames(path string) (SnapshotNames, error)
ReadSnapshotNames reads the names and UUIDs a snapshot records, the way Tarantool's configuration does before an instance starts on it. Rows past _cluster are not read: a snapshot is ordered by space id, and the system spaces it needs come first.