Documentation ¶
Index ¶
- Constants
- Variables
- func AllAnomaliesImplying(anomalies []string) (res []string)
- func AllImpliedAnomalies(anomalies []string) (res []string)
- func AnomaliesProhibitedBy(models []string) []string
- func FriendlyBoundary(anomalies []string) (not []string, alsoNot []string)
- func MonotonicKeyGraph(history History) (Anomalies, *DirectedGraph, DataExplainer)
- func ProcessGraph(history History, _ ...interface{}) (Anomalies, *DirectedGraph, DataExplainer)
- func RealtimeGraph(history History, _ ...interface{}) (Anomalies, *DirectedGraph, DataExplainer)
- func Set(slice []string) []string
- func WriteCycles(cexp CycleExplainer, exp DataExplainer, dir, filename string, cycles []string)
- type Analyzer
- type Anomalies
- type Anomaly
- type BFSPath
- type CheckResult
- type Circle
- type CombinedExplainer
- type ConsistencyModelName
- type CycleExplainer
- type CycleExplainerResult
- type CyclePredicate
- type CycleTrace
- type DataExplainer
- type DependType
- type DirectedGraph
- func (g *DirectedGraph) Bfs(initV []Vertex, out bool) []Vertex
- func (g *DirectedGraph) BfsIn(initV []Vertex) []Vertex
- func (g *DirectedGraph) BfsOut(initV []Vertex) []Vertex
- func (g *DirectedGraph) Edges(a, b Vertex) []Edge
- func (g *DirectedGraph) FilterRelationships(rels []Rel) *DirectedGraph
- func (g *DirectedGraph) Fork() *DirectedGraph
- func (g *DirectedGraph) In(v Vertex) []Vertex
- func (g *DirectedGraph) IsEmpty() bool
- func (g *DirectedGraph) Link(v Vertex, succ Vertex, rel Rel)
- func (g *DirectedGraph) LinkAllTo(xs []Vertex, y Vertex, rel Rel)
- func (g *DirectedGraph) LinkAllToAll(xs []Vertex, ys []Vertex, rel Rel)
- func (g *DirectedGraph) LinkToAll(x Vertex, ys []Vertex, rel Rel)
- func (g *DirectedGraph) MapVertices(f func(interface{}) interface{}) *DirectedGraph
- func (g *DirectedGraph) Out(v Vertex) []Vertex
- func (g *DirectedGraph) ProjectRelationship(rel Rel) *DirectedGraph
- func (g *DirectedGraph) RenumberGraph() (*DirectedGraph, func(interface{}) interface{})
- func (g DirectedGraph) String() string
- func (g *DirectedGraph) StronglyConnectedComponents() []SCC
- func (g *DirectedGraph) UnLink(a, b Vertex)
- func (g *DirectedGraph) UnLinkSelfEdges(xs []Vertex)
- func (g *DirectedGraph) Vertices() []Vertex
- type Edge
- type ExplainResult
- type History
- type ICycleExplainer
- type IntOptional
- type KVEntity
- type MonotonicKeyExplainer
- type Mop
- type MopType
- type MopValueType
- type Op
- type OpBinding
- type OpType
- type PathType
- type ProcessExplainer
- type ProcessResult
- type RealtimeExplainResult
- type RealtimeExplainer
- type Rel
- type RelSet
- type Rels
- type SCC
- type SameKeyOpsByLength
- type Step
- type Vertex
- type Vertices
Constants ¶
const AnonymousMagicNumber = -2
AnonymousMagicNumber is a magic number, means that we don't know the process id of a history event
const NemesisProcessMagicNumber = -1
NemesisProcessMagicNumber is a magic number to stand for nemesis related event on a history
Variables ¶
var Models = MapToDirectedGraph(map[Vertex][]Vertex{ Vertex{"causal-cerone"}: {{"read-atomic"}}, Vertex{"consistent-view"}: {{"cursor-stability"}, {"monotonic-view"}}, Vertex{"conflict-serializable"}: {{"view-serializable"}}, Vertex{"cursor-stability"}: {{"read-committed"}, {"PL-2"}}, Vertex{"forward-consistent-view"}: {{"consistent-view"}, {"PL-1"}}, Vertex{"PL-3"}: {{"repeatable-read"}, {"update-serializable"}}, Vertex{"update-serializable"}: {{"forward-consistent-view"}}, Vertex{"monotonic-atomic-view"}: {{"read-committed"}}, Vertex{"monotonic-view"}: {{"PL-2"}}, Vertex{"monotonic-snapshot-read"}: {{"PL-2"}}, Vertex{"parallel-snapshot-isolation"}: {{"causal-cerone"}}, Vertex{"prefix"}: {{"causal-cerone"}}, Vertex{"read-committed"}: {{"read-uncommitted"}}, Vertex{"repeatable-read"}: {{"cursor-stability"}, {"monotonic-atomic-view"}}, Vertex{"serializable"}: {{"repeatable-read"}, {"snapshot-isolation"}, {"view-serializable"}}, Vertex{"session-serializable"}: {{"1SR"}}, Vertex{"snapshot-isolation"}: {{"forward-consistent-view"}, {"monotonic-atomic-view"}, {"monotonic-snapshot-read"}, {"parallel-snapshot-isolation"}, {"prefix"}}, Vertex{"strict-serializable"}: {{"PL-3"}, {"serializable"}, {"linearizable"}, {"snapshot-isolation"}, {"strong-session-serializable"}}, Vertex{"strong-serializable"}: {{"session-serializable"}}, Vertex{"strong-session-serializable"}: {{"serializable"}}, Vertex{"strong-session-snapshot-isolation"}: {{"snapshot-isolation"}}, Vertex{"strong-snapshot-isolation"}: {{"strong-session-snapshot-isolation"}}, Vertex{"linearizable"}: {{"sequential"}}, Vertex{"causal"}: {{"writes-follow-reads"}}, Vertex{"causal"}: {{"writes-follow-reads"}, {"PRAM"}}, Vertex{"PRAM"}: {{"monotonic-reads"}, {"monotonic-writes"}, {"read-your-writes"}}, }).MapVertices(canonicalModelName)
Models sees https://jepsen.io/consistency for sources.
Functions ¶
func AllAnomaliesImplying ¶
AllAnomaliesImplying yields a set of anomalies which would imply any of those anomalies
func AllImpliedAnomalies ¶
AllImpliedAnomalies yields a set of anomalies implied by those
func AnomaliesProhibitedBy ¶
AnomaliesProhibitedBy takes a collection of consistency models, and returns a set of anomalies
which can't be present if all of those models are to hold
func FriendlyBoundary ¶
FriendlyBoundary takes a set of anomalies, and yields not and alsoNot where not is the weakest set of consistency models invalidated by the given anomaly, and alsoNot is the remaining set of stronger models
func MonotonicKeyGraph ¶
func MonotonicKeyGraph(history History) (Anomalies, *DirectedGraph, DataExplainer)
MonotonicKeyGraph analyzes monotonic key
func ProcessGraph ¶
func ProcessGraph(history History, _ ...interface{}) (Anomalies, *DirectedGraph, DataExplainer)
ProcessGraph analyzes process
func RealtimeGraph ¶
func RealtimeGraph(history History, _ ...interface{}) (Anomalies, *DirectedGraph, DataExplainer)
RealtimeGraph analyzes real-time.
func WriteCycles ¶
func WriteCycles(cexp CycleExplainer, exp DataExplainer, dir, filename string, cycles []string)
WriteCycles ... TODO: implement it.
Types ¶
type Analyzer ¶
type Analyzer func(history History, opts ...interface{}) (Anomalies, *DirectedGraph, DataExplainer)
Analyzer is a function which takes a history and returns a {:graph, :explainer, :anomalies} map; e.g. realtime-graph.
type Anomalies ¶
Anomalies groups anomalies by there names
func (Anomalies) SelectKeys ¶
SelectKeys selects specified keys and return a new Anomalies
type Anomaly ¶
type Anomaly interface {
IAnomaly()
}
Anomaly unifies all kinds of Anomalies, like G1a, G1b, dirty update etc.
type BFSPath ¶
type BFSPath struct {
// contains filtered or unexported fields
}
BFSPath ...
func NewBFSPath ¶
func NewBFSPath(graph *DirectedGraph, start Vertex, sccSet map[Vertex]struct{}) *BFSPath
NewBFSPath ...
type CheckResult ¶
type CheckResult struct { Graph DirectedGraph Explainer DataExplainer Cycles []string // string explaining the cycle Sccs []SCC Anomalies Anomalies }
CheckResult records the check result
func Check ¶
func Check(analyzer Analyzer, history History, opts ...interface{}) CheckResult
Check receives analyzer and a history, returns a map of {graph, explainer, cycles, sccs, anomalies}
type Circle ¶
type Circle struct { // Eg. [2, 1, 2] means a circle: 2 -> 1 -> 2 Path []PathType }
Circle ...
type CombinedExplainer ¶
type CombinedExplainer struct { Explainers []DataExplainer // contains filtered or unexported fields }
CombinedExplainer struct
func NewCombineExplainer ¶
func NewCombineExplainer(explainers []DataExplainer) *CombinedExplainer
NewCombineExplainer builds a CombinedExplainer according to a explainer array
func (*CombinedExplainer) ExplainPairData ¶
func (c *CombinedExplainer) ExplainPairData(p1, p2 PathType) ExplainResult
ExplainPairData find dependencies in a and b
func (*CombinedExplainer) RenderExplanation ¶
func (c *CombinedExplainer) RenderExplanation(result ExplainResult, p1, p2 string) string
RenderExplanation render explanation result
type ConsistencyModelName ¶
type ConsistencyModelName = string
ConsistencyModelName defines the consistency model name
type CycleExplainer ¶
type CycleExplainer struct{}
CycleExplainer provides the step-by-step explanation of the relationships between pairs of operations
func (*CycleExplainer) ExplainCycle ¶
func (c *CycleExplainer) ExplainCycle(explainer DataExplainer, circle Circle) CycleExplainerResult
ExplainCycle for a circle
func (*CycleExplainer) RenderCycleExplanation ¶
func (c *CycleExplainer) RenderCycleExplanation(explainer DataExplainer, cr CycleExplainerResult) string
RenderCycleExplanation ...
type CycleExplainerResult ¶
CycleExplainerResult impls Anomaly
type CyclePredicate ¶
type CyclePredicate func(trace []CycleTrace) bool
CyclePredicate is a predication on a CycleTrace
type CycleTrace ¶
type CycleTrace struct { Rels []Rel // contains filtered or unexported fields }
CycleTrace records a cycle path
type DataExplainer ¶
type DataExplainer interface { // Given a pair of operations a and b, explains why b depends on a, in the // form of a data structure. Returns `nil` if b does not depend on a. ExplainPairData(p1, p2 PathType) ExplainResult // Given a pair of operations, and short names for them, explain why b // depends on a, as a string. `nil` indicates that b does not depend on a. RenderExplanation(result ExplainResult, preName, postName string) string }
DataExplainer ...
type DependType ¶
type DependType string
DependType records the depend type of a relation
const ( // RealtimeDepend ... RealtimeDepend DependType = "realtime" // MonotonicDepend ... MonotonicDepend DependType = "monotonic" // ProcessDepend ... ProcessDepend DependType = "process" // WWDepend ... WWDepend DependType = "ww" // WRDepend ... WRDepend DependType = "wr" // RWDepend ... RWDepend DependType = "rw" )
type DirectedGraph ¶
DirectedGraph is a directed graph type
func DigraphUnion ¶
func DigraphUnion(graphs ...*DirectedGraph) *DirectedGraph
DigraphUnion takes the union of n graphs, merging edges with union
func MapToDirectedGraph ¶
func MapToDirectedGraph(m map[Vertex][]Vertex) *DirectedGraph
MapToDirectedGraph turns a sequence of [node, successors] map into a directed graph
func MonotonicKeyOrder ¶
func MonotonicKeyOrder(history History, k string) *DirectedGraph
MonotonicKeyOrder find dependencies of a process
func NewDirectedGraph ¶
func NewDirectedGraph() *DirectedGraph
NewDirectedGraph returns a empty DirectedGraph
func ProcessOrder ¶
func ProcessOrder(history History, process int) *DirectedGraph
ProcessOrder find dependencies of a process
func (*DirectedGraph) Bfs ¶
func (g *DirectedGraph) Bfs(initV []Vertex, out bool) []Vertex
Bfs searches from a vertices set, returns all vertices searchable out = true means search to downstream vertices from `out` edges out = false means search to upstream vertices from `in` edges
func (*DirectedGraph) BfsIn ¶
func (g *DirectedGraph) BfsIn(initV []Vertex) []Vertex
BfsIn searches from a vertices set, returns all vertices searchable search to upstream vertices from `in` edges
func (*DirectedGraph) BfsOut ¶
func (g *DirectedGraph) BfsOut(initV []Vertex) []Vertex
BfsOut searches from a vertices set, returns all vertices searchable search to downstream vertices from `out` edges
func (*DirectedGraph) Edges ¶
func (g *DirectedGraph) Edges(a, b Vertex) []Edge
Edges returns the edge between two vertices
func (*DirectedGraph) FilterRelationships ¶
func (g *DirectedGraph) FilterRelationships(rels []Rel) *DirectedGraph
FilterRelationships filters a graph g to just those edges which intersect with the given set of
relationships
func (*DirectedGraph) Fork ¶
func (g *DirectedGraph) Fork() *DirectedGraph
Fork implements `forked` semantics on DirectedGraph
func (*DirectedGraph) In ¶
func (g *DirectedGraph) In(v Vertex) []Vertex
In returns inbound vertices to v in graph g
func (*DirectedGraph) IsEmpty ¶
func (g *DirectedGraph) IsEmpty() bool
IsEmpty return true if the graph has no vertices
func (*DirectedGraph) Link ¶
func (g *DirectedGraph) Link(v Vertex, succ Vertex, rel Rel)
Link links two vertices relationship create edge from v => succ
func (*DirectedGraph) LinkAllTo ¶
func (g *DirectedGraph) LinkAllTo(xs []Vertex, y Vertex, rel Rel)
LinkAllTo links all xs to y
func (*DirectedGraph) LinkAllToAll ¶
func (g *DirectedGraph) LinkAllToAll(xs []Vertex, ys []Vertex, rel Rel)
LinkAllToAll links all xs to ys
func (*DirectedGraph) LinkToAll ¶
func (g *DirectedGraph) LinkToAll(x Vertex, ys []Vertex, rel Rel)
LinkToAll links x to all ys
func (*DirectedGraph) MapVertices ¶
func (g *DirectedGraph) MapVertices(f func(interface{}) interface{}) *DirectedGraph
MapVertices takes a function of vertices, returns graph with all
vertices mapped via f
func (*DirectedGraph) Out ¶
func (g *DirectedGraph) Out(v Vertex) []Vertex
Out returns outbound vertices from v in graph g
func (*DirectedGraph) ProjectRelationship ¶
func (g *DirectedGraph) ProjectRelationship(rel Rel) *DirectedGraph
ProjectRelationship filters a graph to just those edges with the given relationship
func (*DirectedGraph) RenumberGraph ¶
func (g *DirectedGraph) RenumberGraph() (*DirectedGraph, func(interface{}) interface{})
RenumberGraph takes a Graph and rewrites each vertex to a unique integer, returning the
rewritten Graph, and a vector of the original vertices for reconstruction.
That means if we apply MapVertices to dg with remap, it can recover to g again
func (DirectedGraph) String ¶
func (g DirectedGraph) String() string
func (*DirectedGraph) StronglyConnectedComponents ¶
func (g *DirectedGraph) StronglyConnectedComponents() []SCC
StronglyConnectedComponents finds all strongly connected components, greater than 1 element
func (*DirectedGraph) UnLink ¶
func (g *DirectedGraph) UnLink(a, b Vertex)
UnLink unlinks vertex a and b
func (*DirectedGraph) UnLinkSelfEdges ¶
func (g *DirectedGraph) UnLinkSelfEdges(xs []Vertex)
UnLinkSelfEdges unlinks edges from a to a
func (*DirectedGraph) Vertices ¶
func (g *DirectedGraph) Vertices() []Vertex
Vertices returns the set of all vertices in graph
type ExplainResult ¶
type ExplainResult interface {
Type() DependType
}
ExplainResult is an interface, contains rwExplainerResult, wwExplainerResult wr ExplainerResult etc
type History ¶
type History []Op
History contains operations
func FilterFailedHistory ¶
FilterFailedHistory ...
func FilterOkOrInfoHistory ¶
FilterOkOrInfoHistory ...
func FilterOutNemesisHistory ¶
FilterOutNemesisHistory ...
func ParseHistory ¶
ParseHistory parse history from elle's row text
func (History) AttachIndexIfNoExists ¶
func (h History) AttachIndexIfNoExists()
AttachIndexIfNoExists add the index for history with it's number in array.
func (History) FilterProcess ¶
FilterProcess filter by process
type ICycleExplainer ¶
type ICycleExplainer interface { ExplainCycle(pairExplainer DataExplainer, circle Circle) CycleExplainerResult RenderCycleExplanation(explainer DataExplainer, cr CycleExplainerResult) string }
ICycleExplainer is an interface
type IntOptional ¶
type IntOptional struct {
// contains filtered or unexported fields
}
IntOptional is an optional int.
func (IntOptional) GetOr ¶
func (i IntOptional) GetOr(defv int) int
GetOr gets the value of return the defv if not present
func (IntOptional) MustGet ¶
func (i IntOptional) MustGet() int
MustGet gets values or panic if isn't present
func (IntOptional) Present ¶
func (i IntOptional) Present() bool
Present returns whether or not the value is present.
func (IntOptional) String ¶
func (i IntOptional) String() string
func (*IntOptional) UnmarshalJSON ¶
func (i *IntOptional) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type MonotonicKeyExplainer ¶
type MonotonicKeyExplainer struct{}
MonotonicKeyExplainer ... Note: MonotonicKey is used on rw_register, so I don't explain it currently.
func (MonotonicKeyExplainer) ExplainPairData ¶
func (e MonotonicKeyExplainer) ExplainPairData(p1, p2 PathType) ExplainResult
ExplainPairData ...
func (MonotonicKeyExplainer) RenderExplanation ¶
func (e MonotonicKeyExplainer) RenderExplanation(result ExplainResult, preName, postName string) string
RenderExplanation render explanation
type Op ¶
type Op struct { Index IntOptional `json:"index,omitempty"` Process IntOptional `json:"process,omitempty"` Time time.Time `json:"time"` Type OpType `json:"type"` Value *[]Mop `json:"value"` Error string `json:"error,omitempty"` }
Op is operation
type PathType ¶
type PathType = Op
PathType type aliases Op
func (PathType) IndexOfMop ¶
IndexOfMop returns the index of mop in op
type ProcessExplainer ¶
type ProcessExplainer struct{}
ProcessExplainer ...
func (ProcessExplainer) ExplainPairData ¶
func (e ProcessExplainer) ExplainPairData(p1, p2 PathType) ExplainResult
ExplainPairData explain pair data
func (ProcessExplainer) RenderExplanation ¶
func (e ProcessExplainer) RenderExplanation(result ExplainResult, preName, postName string) string
RenderExplanation render explanation
type RealtimeExplainResult ¶
RealtimeExplainResult records a real time explain result
type RealtimeExplainer ¶
type RealtimeExplainer struct {
// contains filtered or unexported fields
}
RealtimeExplainer is Realtime order explainer
func (RealtimeExplainer) ExplainPairData ¶
func (r RealtimeExplainer) ExplainPairData(preEnd, postEnd PathType) ExplainResult
ExplainPairData ...
func (RealtimeExplainer) RenderExplanation ¶
func (r RealtimeExplainer) RenderExplanation(result ExplainResult, preName, postName string) string
RenderExplanation ...
type Rel ¶
type Rel string
Rel stands for relation in dependencies
const ( Empty Rel = "" WW Rel = "ww" WR Rel = "wr" RW Rel = "rw" Process Rel = "process" Realtime Rel = "realtime" ExtKey Rel = "ext-key" Version Rel = "version" InitialState Rel = "initial-state" WFR Rel = "write-follow-read" // Note: currently we don't support MonotonicKey MonotonicKey Rel = "monotonic-key" )
Rel enums
func IntersectionRel ¶
IntersectionRel returns the intersection of res1 and res2
type RelSet ¶
type RelSet []Rel
RelSet type aliases []Rel
type SCC ¶
type SCC struct {
Vertices []Vertex
}
SCC indexes all vertices of a strongly connected component
type SameKeyOpsByLength ¶
type SameKeyOpsByLength [][]MopValueType
SameKeyOpsByLength ...
func (SameKeyOpsByLength) Len ¶
func (b SameKeyOpsByLength) Len() int
func (SameKeyOpsByLength) Less ¶
func (b SameKeyOpsByLength) Less(i, j int) bool
func (SameKeyOpsByLength) Swap ¶
func (b SameKeyOpsByLength) Swap(i, j int)
type Step ¶
type Step struct {
Result ExplainResult
}
Step saves a explain result of one step of a cycle
type Vertex ¶
type Vertex struct {
Value interface{}
}
Vertex is a vertex on the directed graph
func FindCycle ¶
func FindCycle(graph *DirectedGraph, scc SCC) []Vertex
FindCycle receives a graph and a scc, finds a short cycle in that component
func FindCycleStartingWith ¶
func FindCycleStartingWith(graph *DirectedGraph, scc SCC, first Rel, rest []Rel) []Vertex
FindCycleStartingWith ...
func FindCycleWith ¶
func FindCycleWith(graph *DirectedGraph, scc SCC, isWith CyclePredicate) []Vertex
FindCycleWith ...