mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
Merge PR #372
This commit is contained in:
commit
ab3b203064
3 files changed
+166
No files matched your search
@@ -103,6 +103,32 @@ Two kinds of config are **expected to violate**:
|
||||
|
||||
Each `.cfg` names its spec on its first line.
|
||||
|
||||
## Exhausted bounds
|
||||
|
||||
One row per spec: a configuration that TLC explored completely (breadth-first,
|
||||
no error, queue empty), the bounds of that configuration, its distinct state
|
||||
count, and what the model leaves out. A pass means "no violation exists within
|
||||
these bounds", nothing more. A spec is added to this directory together with
|
||||
its row; `internal/invcheck` checks that each row names an existing spec and
|
||||
configuration and fills every cell. Specs that predate this table are listed
|
||||
in `internal/invcheck/testdata/specs-without-bounds.txt`; the list only
|
||||
shrinks. The sections below hold the full results, the negative
|
||||
configurations and the counterexamples.
|
||||
|
||||
| Spec | Configuration | Bounds | Distinct states | Not modelled |
|
||||
|---|---|---|---|---|
|
||||
| `ForkDelete.tla` | `cfg/ForkDelete_safe_na_P2_D1E2G5.cfg` | deadline D=1, skew E=2, apply bound P=2, grace G=5 (the boundary G = D + E + P), check-then-publish fork, three clocks | 15,730,209 | guest I/O; GC as more than one atomic step; more than one fork per parent read |
|
||||
| `FrozenDetachBudget.tla` | `cfg/FrozenDetachBudget.cfg` | one externally frozen attempt; time in tenths of a second | 439 | physical latency; the external controller's re-freeze limit; fencing and CAS races during the cut |
|
||||
| `GCClockSkew.tla` | `GCClockSkew_safe.cfg` | G=3, S=1, Q=1, Born=10, MaxT=17 | 96 | the root scan, copy settlement and higher-epoch guards; clocks outside the configured skew |
|
||||
| `GCDeleteProgress.tla` | `GCDeleteProgress_safe.cfg` | three ordered candidates, the first DELETE rejected | 4 | root and epoch admission; elapsed coverage; persistence |
|
||||
| `HeadReopenBelt.tla` | `cfg/HeadReopenBelt.cfg` | one HEAD, one old server-held CAS, one reopen, one new acknowledged image, one nonempty base | 12 | storage I/O and durability; WAL recovery; an empty root with a delayed first exclusive create |
|
||||
| `PlainDetach.tla` | `cfg/PlainDetach.cfg` | up to two I/O readers, frontend close | 10 | HEAD publication; authority; physical I/O; wall-clock bounds; failure settlement |
|
||||
| `PlainSealReplay.tla` | `cfg/PlainSealReplay.cfg` | one seal request, process memory kept or lost, seven read observations of HEAD | 42 | the controller's pending record and its boot refusal; the hand-over; RPC delivery |
|
||||
| `RestoreIndependence.tla` | `cfg/RestoreIndependence_nc_safe_n4.cfg` | no-claim design, the largest of the safe configurations (`n4`) | 2,752,518 | guest writes to the target while it takes ownership; GC that takes time; more than one restore per snapshot |
|
||||
| `ScopedMaintenanceGC.tla` | `ScopedMaintenanceGC_safe.cfg` | three keys across two volumes, one foreign-only root | 10 | the complete mark and the grace timing (in `RetentionGCTiming`); density and metadata-RPC cost |
|
||||
| `SealedReopen.tla` | `cfg/SealedReopen.cfg` | one sealed HEAD of the same holder and epoch, one reopen | 2 | the hand-over and its liveness; RPC delivery; any other holder or epoch |
|
||||
| `WorkspaceMoveOutcome.tla` | `cfg/WorkspaceMoveOutcome.cfg` | one volume, seven error causes, one failed write, one reply | 135 | authority changes; journal durability; lease safety; RPC delivery; reload |
|
||||
|
||||
## Specs at a glance
|
||||
|
||||
State counts are distinct states for exhaustive passes. "N-step trace" is the
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package invcheck
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// specsWithoutBoundsLeft is the number of specs in docs/spec that have no
|
||||
// row yet in the "Exhausted bounds" table of docs/spec/README.md. It only
|
||||
// goes down: a new spec arrives with its row.
|
||||
const specsWithoutBoundsLeft = 21
|
||||
|
||||
var stateCount = regexp.MustCompile(`\d`)
|
||||
|
||||
// A published spec says what was checked: docs/spec/README.md has an
|
||||
// "Exhausted bounds" table with, for each spec, one configuration that TLC
|
||||
// explored completely, the bounds of that configuration, its distinct state
|
||||
// count, and what the model leaves out. Specs that predate the table are
|
||||
// listed in testdata/specs-without-bounds.txt, and that list only shrinks.
|
||||
func TestPublicSpecsStateTheirBounds(t *testing.T) {
|
||||
root := repoRoot(t)
|
||||
specDir := filepath.Join(root, "docs", "spec")
|
||||
|
||||
entries, err := os.ReadDir(specDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
specs := map[string]bool{}
|
||||
for _, e := range entries {
|
||||
if !e.IsDir() && strings.HasSuffix(e.Name(), ".tla") {
|
||||
specs[e.Name()] = true
|
||||
}
|
||||
}
|
||||
|
||||
raw, err := os.ReadFile(filepath.Join(specDir, "README.md"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
doc := strings.ReplaceAll(string(raw), "\r\n", "\n")
|
||||
start := strings.Index(doc, "\n## Exhausted bounds\n")
|
||||
if start < 0 {
|
||||
t.Fatal("docs/spec/README.md: heading \"## Exhausted bounds\" not found")
|
||||
}
|
||||
section := doc[start+1:]
|
||||
if end := strings.Index(section[1:], "\n## "); end >= 0 {
|
||||
section = section[:end+1]
|
||||
}
|
||||
|
||||
withRow := map[string]bool{}
|
||||
for _, line := range strings.Split(section, "\n") {
|
||||
if !strings.HasPrefix(line, "| `") {
|
||||
continue
|
||||
}
|
||||
cells := strings.Split(strings.Trim(line, "|"), "|")
|
||||
if len(cells) != 5 {
|
||||
t.Errorf("Exhausted bounds: a row has %d cells, want 5 (spec, configuration, bounds, distinct states, not modelled): %s", len(cells), line)
|
||||
continue
|
||||
}
|
||||
for i := range cells {
|
||||
cells[i] = strings.TrimSpace(cells[i])
|
||||
}
|
||||
spec := strings.Trim(cells[0], "`")
|
||||
cfg := strings.Trim(cells[1], "`")
|
||||
if !specs[spec] {
|
||||
t.Errorf("Exhausted bounds: %s is not a file in docs/spec", spec)
|
||||
continue
|
||||
}
|
||||
if withRow[spec] {
|
||||
t.Errorf("Exhausted bounds: %s has two rows; keep the one configuration that best states the claim", spec)
|
||||
}
|
||||
withRow[spec] = true
|
||||
if _, err := os.Stat(filepath.Join(specDir, filepath.FromSlash(cfg))); err != nil {
|
||||
t.Errorf("Exhausted bounds: %s names configuration %q, which is not a file under docs/spec", spec, cfg)
|
||||
}
|
||||
if cells[2] == "" {
|
||||
t.Errorf("Exhausted bounds: %s states no bounds", spec)
|
||||
}
|
||||
if !stateCount.MatchString(cells[3]) {
|
||||
t.Errorf("Exhausted bounds: %s states no distinct state count", spec)
|
||||
}
|
||||
if cells[4] == "" {
|
||||
t.Errorf("Exhausted bounds: %s does not say what is not modelled", spec)
|
||||
}
|
||||
}
|
||||
|
||||
var missing []string
|
||||
for s := range specs {
|
||||
if !withRow[s] {
|
||||
missing = append(missing, s)
|
||||
}
|
||||
}
|
||||
sort.Strings(missing)
|
||||
|
||||
listRaw, err := os.ReadFile(filepath.Join("testdata", "specs-without-bounds.txt"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var listed []string
|
||||
for _, l := range strings.Split(strings.ReplaceAll(string(listRaw), "\r\n", "\n"), "\n") {
|
||||
if l = strings.TrimSpace(l); l != "" && !strings.HasPrefix(l, "#") {
|
||||
listed = append(listed, l)
|
||||
}
|
||||
}
|
||||
sort.Strings(listed)
|
||||
|
||||
if strings.Join(missing, "\n") != strings.Join(listed, "\n") {
|
||||
t.Errorf("specs with no Exhausted bounds row:\n %s\ntestdata/specs-without-bounds.txt lists:\n %s\nA new spec needs a row in docs/spec/README.md; a spec that gained a row leaves the list.",
|
||||
strings.Join(missing, "\n "), strings.Join(listed, "\n "))
|
||||
}
|
||||
if len(listed) != specsWithoutBoundsLeft {
|
||||
t.Errorf("testdata/specs-without-bounds.txt has %d specs, specsWithoutBoundsLeft is %d: lower the constant when a spec leaves the list; it never goes up", len(listed), specsWithoutBoundsLeft)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
# Specs in docs/spec with no row yet in the "Exhausted bounds" table of docs/spec/README.md.
|
||||
# This list only shrinks: add the row, then remove the line and lower specsWithoutBoundsLeft.
|
||||
ChunkLifecycle.tla
|
||||
ChunkLifecycleFixed.tla
|
||||
ControlPlane.tla
|
||||
CutCOW.tla
|
||||
CutCOW2.tla
|
||||
CutCapture.tla
|
||||
CutPipeline.tla
|
||||
HostBudget.tla
|
||||
MaintenanceOwner.tla
|
||||
PrecopyFixedAdmission.tla
|
||||
ReplicaApplyOrder.tla
|
||||
ReplicaPrefixFloor.tla
|
||||
ReplicaReviewGuards.tla
|
||||
ReplicationFailover.tla
|
||||
RetentionGCMulti.tla
|
||||
RetentionGCTiming.tla
|
||||
SmartWALRecovery.tla
|
||||
WALReclaim.tla
|
||||
WALRecovery.tla
|
||||
WALReplica.tla
|
||||
WorkspaceTakeover.tla
|
||||
Reference in new issue
Block a user