syncstate

package
v0.3.25 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

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

State tracks which partitions a node is waiting to receive data for. Used to delay rebalance ACK until initial sync is complete.

Each tracked partition records when it first became pending. A partition counts as pending only while its escape deadline has not elapsed: one that never receives data (legitimately empty on the source) escapes once its deadline passes and stays escaped, no matter how often the routing table is reconciled, because Reconcile preserves the original timestamps. Cluster churn faster than the escape delay therefore cannot starve the rebalance ACK, and expired entries are kept (not deleted) so a subsequent Reconcile cannot resurrect them with a fresh clock.

func New

func New() *State

New creates a new sync state.

func (*State) Done

func (s *State) Done() <-chan struct{}

Done returns a channel that closes when initial sync is complete.

func (*State) Expired added in v0.3.19

func (x *State) Expired(partID uint64) bool

Expired reports whether partID is tracked and has outlived its escape deadline. Such a partition no longer holds back PendingEmpty.

func (*State) IsDone

func (s *State) IsDone() bool

IsDone returns true if initial sync is complete.

func (*State) MarkReceived

func (x *State) MarkReceived(partID uint64)

MarkReceived marks partition partID as having received data, whether or not it is tracked yet: a mark that precedes the Reconcile of an ongoing install keeps that Reconcile from tracking the partition.

func (*State) PendingEmpty

func (s *State) PendingEmpty() bool

PendingEmpty returns true if no partition is effectively pending receive: every tracked partition either received data or outlived its escape deadline.

func (*State) Reconcile added in v0.3.14

func (x *State) Reconcile(partitionIDs []uint64, escape time.Duration, scannedAt time.Time)

Reconcile rebuilds the tracked set from the given partition IDs, which were found empty by a scan taken at scannedAt. Call when the routing table is updated. Partitions already tracked keep their original timestamp (their escape clock never restarts, even after it has expired), new ones start now, entries not in partitionIDs are dropped, and a partition that received data after scannedAt is not tracked: it was delivered while the table was being installed, see receivedAt.

escape is the per-partition deadline after which a tracked partition that received no data stops counting as pending; escape <= 0 disables expiry, so only MarkReceived clears entries.

Closes the previous Done channel to wake any waiters so they can re-check or wait on the new cycle. If nothing is effectively pending, signals done immediately.

Jump to

Keyboard shortcuts

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