migration

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: BSD-3-Clause Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package migration moves node-local project data — per-instance kvdbs under /crdt/<hash> and locally-held storage file bytes — into hoarder-hosted instances and the hoarder stash, then scrubs the local copies. It runs at substrate boot (bounded, then background) and is idempotent: every pass re-enumerates what is still local, replays it conditionally (putnx — a value written through the live path is never overwritten), verifies by read-back, and only then deletes. Source data is never deleted before verified read-back; unresolvable namespaces are left intact and reported.

Index

Constants

This section is empty.

Variables

View Source
var (
	// BootTimeout bounds the synchronous boot-time pass; work left when it
	// expires continues in the background (the node serves meanwhile).
	BootTimeout = 10 * time.Minute

	// DrainInterval is the background retry period while local data remains —
	// it picks up instances that become resolvable later (a hoarder meta
	// appears when live traffic first-touches a regex-matched instance) and
	// retries transient failures.
	DrainInterval = 30 * time.Second

	// ReplayWorkers is the per-instance bound on in-flight key replays.
	ReplayWorkers = 8
)

Tunables — exported so tests can shrink them.

Functions

func Entries

func Entries(ctx context.Context, store ds.Batching, hash string) (map[string][]byte, error)

Entries reads every logical key/value of one namespace through the offline view — never announcing heads, never touching the network.

func FileCids

func FileCids(entries map[string][]byte) []string

FileCids extracts the file content CIDs a storage-shaped namespace's metadata records.

func Namespaces

func Namespaces(ctx context.Context, store ds.Batching) ([]string, error)

Namespaces enumerates the kvdb namespaces held in a node datastore — the offline-inspection entry point (tools) over the same logic the boot pass uses.

Types

type InstanceReport

type InstanceReport struct {
	Match string
	Kind  string

	Written    int // keys replayed (absent remotely)
	Existed    int // keys already present remotely with the same value
	Superseded int // keys present remotely with a different value (live write wins)

	FilesStashed      int // locally-held file bytes pushed to the stash this pass
	FilesAwaitingRepl int // locally-held file bytes below the stash replica target
	FilesElsewhere    int // file bytes this node never held (another holder pushes)

	Verified bool // every local key read back through the hoarder path
	Scrubbed bool // local namespace deleted (implies Verified + bytes at target)

	Err string
	// contains filtered or unexported fields
}

InstanceReport is the per-instance outcome of one pass.

type Migrator

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

Migrator owns the migration lifecycle for one substrate node.

func New

func New(ctx context.Context, node peer.Node, hoarder hoarderIface.Client, tns tnsIface.Client) *Migrator

New builds a Migrator. ctx is the service lifetime: Close cancels its child and joins any background work before returning.

func (*Migrator) Boot

func (m *Migrator) Boot() *Report

Boot runs the synchronous boot-time pass, bounded by BootTimeout. A node with no local project data pays one prefix query. Work left at the bound — or instances that need live traffic to become resolvable — continues on the background drain.

func (*Migrator) Close

func (m *Migrator) Close()

Close stops background work and joins it — a canceled drain must not touch the node's store or the clients while the service tears them down.

func (*Migrator) Migrate

func (m *Migrator) Migrate(ctx context.Context) *Report

Migrate runs one full pass: enumerate → resolve → replay → verify → scrub → sweep. Safe to re-run at any time; passes serialize. Nothing local is deleted unless its instance verified read-back through the hoarder path and (for storage bytes) the stash reached its replica target.

type Report

type Report struct {
	Instances   map[string]*InstanceReport
	Unresolved  []string // namespaces with no identity yet — left intact, retried
	SweptKeys   int      // raw namespace keys deleted
	SweptBlocks int      // blockstore blocks deleted
	Err         string
}

Report is the outcome of one Migrate pass.

func (*Report) Empty

func (r *Report) Empty() bool

Empty reports a pass that found nothing to do.

func (*Report) RemainingCount

func (r *Report) RemainingCount() int

RemainingCount is how many local namespaces still hold data after the pass.

func (*Report) Summary

func (r *Report) Summary() string

Summary is a one-line operator-facing digest.

Jump to

Keyboard shortcuts

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