I15 starting-indexer-answers: the starting indexer answers away while its start's read of the trunk holds the view, and says its start's phases
KeptTrunk.Unread and current answer the fault away naming "the trunk's revision <n>" while the start's read holds the view, and never wait behind it; the verb revision asks it first; the tools' watched copies (seat-definitions, config readers) ask WatchedStates.Unread before they read and are watched from the bundle's start. The indexer's start says each step as a phase of mesh-sdk's ProcessReader (BeginPhase, EndPhase), kept at start-phase of the state first-views. Rows: a unit test of the held read, one of the watched copy, and TestIndexerWhole's phases and held-read case. Builds: design 47 H2 H-A-708 (1) (2), H-A-717 DQ-54, H-A-733 (2)
This commit is contained in:
@@ -72,9 +72,19 @@ type watchedSource struct {
|
||||
state string
|
||||
}
|
||||
|
||||
func (s watchedSource) Keys() ([]string, error) { return s.w.Keys(s.state) }
|
||||
// Each read asks Unread first, so a call made before the copy has its state answers the fault away at once (design 47 H2
|
||||
// H-A-708 (2)); the bundle's own start keeps the waiting read (main).
|
||||
func (s watchedSource) Keys() ([]string, error) {
|
||||
if err := s.w.Unread(s.state); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.w.Keys(s.state)
|
||||
}
|
||||
|
||||
func (s watchedSource) Get(key string) (*views.Entry, bool, error) {
|
||||
if err := s.w.Unread(s.state); err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
v, ok, err := s.w.Get(s.state, key)
|
||||
if err != nil || !ok {
|
||||
return nil, false, err
|
||||
@@ -82,4 +92,9 @@ func (s watchedSource) Get(key string) (*views.Entry, bool, error) {
|
||||
return &views.Entry{Value: v}, true, nil
|
||||
}
|
||||
|
||||
func (s watchedSource) Values() (map[string][]byte, error) { return s.w.Values(s.state) }
|
||||
func (s watchedSource) Values() (map[string][]byte, error) {
|
||||
if err := s.w.Unread(s.state); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.w.Values(s.state)
|
||||
}
|
||||
|
||||
@@ -194,6 +194,11 @@ func main() {
|
||||
}
|
||||
follow.Start(context.Background())
|
||||
watched := stdio.NewWatchedStates()
|
||||
// The copies the handlers read are watched from the start, beside the answers: a handler asks Unread first and is answered
|
||||
// the fault away until its state is in (design 47 H2 H-A-708 (2)).
|
||||
for _, state := range []string{index.SeatDefinitionsState, "manifests"} {
|
||||
go watched.Follow(state, nil)
|
||||
}
|
||||
tools = append(tools, catalogTools(trunk.State, kept, watched)...)
|
||||
// The seat mesh-catalog's verb revision, a first view of the catalog half answered in this runtime of its own to exactly
|
||||
// the parts whose entry declares it (novox/hq ADR 0663).
|
||||
|
||||
@@ -62,6 +62,9 @@ func configReadersTool(watched *stdio.WatchedStates, modules views.Source) stdio
|
||||
}
|
||||
}
|
||||
kept := map[string]meshcatalog.ManifestsByDigestValue{}
|
||||
if err := watched.Unread("manifests"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
raws, err := watched.Values("manifests")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("the manifests state cannot be read: %w", err)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/busretry"
|
||||
|
||||
"mesh-delivery-indexer/internal/index"
|
||||
)
|
||||
|
||||
// Design 47 H2 H-A-708 (2): a handler on a watched copy asks Unread first, so the verb seat-definitions, asked before the copy
|
||||
// has its state (the watch not handing its values yet), answers the fault away at once and answers its values after.
|
||||
func TestASeatDefinitionsReadIsAnsweredAwayUntilItsStateIsWatched(t *testing.T) {
|
||||
release := make(chan struct{})
|
||||
w := stdio.WatchedStatesOver(func(state string, handle func(stdio.StateChange) error) error {
|
||||
<-release
|
||||
return handle(stdio.StateChange{State: state, Key: "git.trunk", Op: stdio.OpPut, Value: []byte(`{"digest":"d"}`), Revision: 1, Current: true})
|
||||
}, nil)
|
||||
src := watchedSource{w, index.SeatDefinitionsState}
|
||||
var away *busretry.Away
|
||||
if _, err := src.Keys(); !errors.As(err, &away) {
|
||||
t.Fatalf("Keys before the copy is asked for = %v, want away", err)
|
||||
}
|
||||
go w.Follow(index.SeatDefinitionsState, nil) // the bundle's start asks for the copy
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for {
|
||||
_, err := src.Values()
|
||||
if errors.As(err, &away) && away.Part == "the state "+index.SeatDefinitionsState {
|
||||
break // asked for and not handed yet
|
||||
}
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatalf("Values while the watch is held = %v, want away naming the state", err)
|
||||
}
|
||||
runtime.Gosched()
|
||||
}
|
||||
close(release)
|
||||
for {
|
||||
keys, err := src.Keys()
|
||||
if err == nil {
|
||||
if len(keys) != 1 || keys[0] != "git.trunk" {
|
||||
t.Fatalf("Keys after the copy has its state = %v, want its one key", keys)
|
||||
}
|
||||
return
|
||||
}
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatalf("Keys still %v after the watch handed its values", err)
|
||||
}
|
||||
runtime.Gosched()
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"time"
|
||||
@@ -397,12 +398,34 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
}
|
||||
return ix.SeedModulesFrom(ctx, r.Definitions(), stepsVia(calls.CallKeptWhileOpen, ix.SeedEntryHeld, logger.Printf))
|
||||
}
|
||||
// The indexer's one pull of its durable on the shared events stream (process.EventHub): every handler is registered
|
||||
// before it starts.
|
||||
hub := process.NewEventHub(logger.Printf)
|
||||
reader := &views.ProcessReader{Module: cred.Module, Call: calls.Call, Logf: logger.Printf, Hub: hub,
|
||||
Findings: func() views.WireWriter { return writer }}
|
||||
// Each step of the start says when it begins and how long it took, so a start that does not end is read in the journal
|
||||
// and not guessed (lead-47 2026-11-16: two starts on novox ran 25 minutes at one CPU with no line).
|
||||
// Each is also the phase the start is in, said in the reader's journal and kept for the first-view tool (design 47 H2
|
||||
// H-A-708 (1), H-A-717 DQ-54), and ended only by its own end, so a pass that runs beside the start's (the publish at
|
||||
// start) never ends another's.
|
||||
var phaseMu sync.Mutex
|
||||
phase := ""
|
||||
step := func(name string) func() {
|
||||
began := time.Now()
|
||||
logger.Printf("start: %s", name)
|
||||
return func() { logger.Printf("start: %s done in %s", name, time.Since(began).Round(time.Millisecond)) }
|
||||
phaseMu.Lock()
|
||||
phase = name
|
||||
phaseMu.Unlock()
|
||||
reader.BeginPhase(name)
|
||||
return func() {
|
||||
logger.Printf("start: %s done in %s", name, time.Since(began).Round(time.Millisecond))
|
||||
phaseMu.Lock()
|
||||
defer phaseMu.Unlock()
|
||||
if phase == name {
|
||||
phase = ""
|
||||
reader.EndPhase()
|
||||
}
|
||||
}
|
||||
}
|
||||
// A module of the current trunk graph with no registration is registered once at the start, as a kept trunk revision
|
||||
// registers one entering the graph (design 47 H H-A-262, H-A-264 (1)); said loudly, whatever it answers.
|
||||
@@ -452,11 +475,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
buildModules.refresh()
|
||||
// The assignments is the seat mesh-module-assigner's: read through its holder's first view and views family, never its bucket (DLV-F1r).
|
||||
assignmentsErrs := make(chan error)
|
||||
// The indexer's one pull of its durable on the shared events stream (process.EventHub): every handler is registered
|
||||
// before it starts.
|
||||
hub := process.NewEventHub(logger.Printf)
|
||||
reader := &views.ProcessReader{Module: cred.Module, Call: calls.Call, Logf: logger.Printf, Hub: hub,
|
||||
Findings: func() views.WireWriter { return writer }}
|
||||
// The holder function (A-302): the seat-holders view of the claimant of mesh-module-assigner in the indexer's own catalog,
|
||||
// followed again at each refresh of the build modules (a seat list change, a catalog revision).
|
||||
seatHolders := &seatHoldersFollow{ctx: ctx, ix: ix, reader: reader, logf: logger.Printf}
|
||||
|
||||
@@ -26,7 +26,9 @@ import (
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/busretry"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
|
||||
"mesh-delivery-indexer/internal/index"
|
||||
)
|
||||
@@ -412,7 +414,7 @@ func TestIndexerWhole(t *testing.T) {
|
||||
)
|
||||
var forge *forgeCommits
|
||||
var heard *takeIns
|
||||
var pins, held, takeinsKV, regs, runs jetstream.KeyValue
|
||||
var pins, held, takeinsKV, regs, runs, status jetstream.KeyValue
|
||||
js, ctx, candidates, _, restart := startIndexerRun(t, func(context.Context, buildLog) {}, func(ctx context.Context, js jetstream.JetStream) {
|
||||
heard = hearTakeIns(t, js.Conn())
|
||||
forge = serveCommits(t, js.Conn())
|
||||
@@ -423,8 +425,8 @@ func TestIndexerWhole(t *testing.T) {
|
||||
for _, b := range []struct {
|
||||
state string
|
||||
kv *jetstream.KeyValue
|
||||
}{{index.HeldState, &held}, {index.TakeInsState, &takeinsKV}, {index.RunsState, &runs}} {
|
||||
if *b.kv, err = js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, b.state), History: 1}); err != nil {
|
||||
}{{index.HeldState, &held}, {index.TakeInsState, &takeinsKV}, {index.RunsState, &runs}, {views.StatusState, &status}} {
|
||||
if *b.kv, err = js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, b.state), History: 64}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -649,6 +651,66 @@ func TestIndexerWhole(t *testing.T) {
|
||||
if hq := heard.next(t, "delta", 2); len(hq.Entries) != 0 || hq.Revision != 2 {
|
||||
t.Errorf("the move of novox/hq on delta said %+v, want revision 2 with no movers", hq)
|
||||
}
|
||||
|
||||
// Design 47 H2 H-A-708 (1), H-A-717 DQ-54: the start's phases are kept at start-phase of the state first-views, and the
|
||||
// start's last phase ended is null.
|
||||
untilKey(t, ctx, status, views.StartPhaseKey, func(v []byte) bool { return string(v) == "null" })
|
||||
phases, err := status.History(ctx, views.StartPhaseKey)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var said []string
|
||||
for _, e := range phases {
|
||||
var p *views.StartPhase
|
||||
if json.Unmarshal(e.Value(), &p) == nil && p != nil {
|
||||
said = append(said, p.Name)
|
||||
}
|
||||
}
|
||||
for _, want := range []string{"following the assignments", "computing the fingerprints"} {
|
||||
if !slices.Contains(said, want) {
|
||||
t.Errorf("the start's phases kept %q, want %q among them", said, want)
|
||||
}
|
||||
}
|
||||
|
||||
// Design 47 H2 H-A-708 (2) (AC-I15): while the start's read of the trunk is held, the verb revision, asked of the tools'
|
||||
// view of the trunk, answers the fault away naming the trunk's revision within seconds, never waiting behind the read.
|
||||
hold := &holdEntries{Objects: objects, reading: make(chan struct{}), release: make(chan struct{})}
|
||||
kept := &index.KeptTrunk{}
|
||||
readEnded := make(chan error, 1)
|
||||
go func() { readEnded <- kept.Reread(ctx, hold) }()
|
||||
<-hold.reading
|
||||
answered := make(chan error, 1)
|
||||
go func() {
|
||||
_, err := toolNamed(t, []stdio.Tool{index.RevisionTool(hold, kept)}, meshcatalog.Seat+"."+meshcatalog.VerbRevision).Run(map[string]any{})
|
||||
answered <- err
|
||||
}()
|
||||
select {
|
||||
case err := <-answered:
|
||||
var away *busretry.Away
|
||||
if !errors.As(err, &away) || !strings.HasPrefix(away.Part, "the trunk's revision ") {
|
||||
t.Errorf("revision while the start's read is held answered %v, want away naming the trunk's revision", err)
|
||||
}
|
||||
case <-time.After(waitBound):
|
||||
t.Error("revision waited behind the start's read of the trunk")
|
||||
}
|
||||
close(hold.release)
|
||||
if err := <-readEnded; err != nil {
|
||||
t.Errorf("the held read of the trunk ended with %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// holdEntries is the indexer's objects whose first read of an entry waits until release is closed: a read of the trunk held.
|
||||
type holdEntries struct {
|
||||
index.Objects
|
||||
reading, release chan struct{}
|
||||
once sync.Once
|
||||
}
|
||||
|
||||
func (h *holdEntries) Get(ctx context.Context, name string) ([]byte, error) {
|
||||
if strings.HasPrefix(name, "entry.") {
|
||||
h.once.Do(func() { close(h.reading); <-h.release })
|
||||
}
|
||||
return h.Objects.Get(ctx, name)
|
||||
}
|
||||
|
||||
// toolNamed is the tool of that name.
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
runner "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph"
|
||||
"git.novox.be/novox/mesh-sdk/go/busretry"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
"git.novox.be/novox/mesh-sdk/go/process"
|
||||
@@ -223,9 +224,17 @@ func newestOf(ctx context.Context, o Objects, branch string) (meshcatalog.Catalo
|
||||
// while the newest is newer than the one that failed; the same revision failing twice is the read's failure. Progress bounds
|
||||
// the loop. No revision kept is false.
|
||||
func readNewestOf(ctx context.Context, o Objects, branch string) (meshcatalog.CatalogRevision, []meshcatalog.CatalogEntry, bool, error) {
|
||||
return readNewestOfSaying(ctx, o, branch, nil)
|
||||
}
|
||||
|
||||
// readNewestOfSaying is readNewestOf telling said the revision each pass found as the newest, before it reads its entries.
|
||||
func readNewestOfSaying(ctx context.Context, o Objects, branch string, said func(revision int64)) (meshcatalog.CatalogRevision, []meshcatalog.CatalogEntry, bool, error) {
|
||||
var failed int64
|
||||
for {
|
||||
newest, any, err := newestOf(ctx, o, branch)
|
||||
if err == nil && any && said != nil {
|
||||
said(newest.Revision)
|
||||
}
|
||||
if err == nil && !any {
|
||||
return newest, nil, false, nil
|
||||
}
|
||||
@@ -649,11 +658,16 @@ type KeptTrunk struct {
|
||||
read sync.Mutex // one re-read at a time; a read of the view never holds it
|
||||
mu sync.Mutex
|
||||
started bool
|
||||
at int64
|
||||
mods Store
|
||||
held Store
|
||||
rev meshcatalog.CatalogRevision
|
||||
entries []meshcatalog.CatalogEntry
|
||||
// reading is whether a read of the trunk runs now, readingRev the revision it reads (0 while the newest is not known
|
||||
// yet) and readingSince when it began: a call that meets the start's read says them as the fault away (Unread).
|
||||
reading bool
|
||||
readingRev int64
|
||||
readingSince time.Time
|
||||
at int64
|
||||
mods Store
|
||||
held Store
|
||||
rev meshcatalog.CatalogRevision
|
||||
entries []meshcatalog.CatalogEntry
|
||||
// manifests are the manifests the revision's entries carry whole, as JSON, by their digest as a module's value names it
|
||||
// (A-487c: the verbs module and provides answer them from here, never from the manifests state).
|
||||
manifests map[string]string
|
||||
@@ -668,13 +682,25 @@ func (k *KeptTrunk) Reread(ctx context.Context, o Objects) error {
|
||||
|
||||
func (k *KeptTrunk) reread(ctx context.Context, o Objects) error {
|
||||
began := time.Now()
|
||||
k.mu.Lock()
|
||||
k.reading, k.readingRev, k.readingSince = true, 0, began
|
||||
k.mu.Unlock()
|
||||
defer func() {
|
||||
k.mu.Lock()
|
||||
k.reading = false
|
||||
k.mu.Unlock()
|
||||
}()
|
||||
fail := func(err error) error {
|
||||
if k.Say != nil {
|
||||
k.Say("the view of the trunk is BEHIND, its re-read failed after %s (the view held stays, the next heard catalog-revision reads again): %v", time.Since(began).Round(time.Millisecond), err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
newest, entries, any, err := readNewestOf(ctx, o, TrunkBranch)
|
||||
newest, entries, any, err := readNewestOfSaying(ctx, o, TrunkBranch, func(revision int64) {
|
||||
k.mu.Lock()
|
||||
k.readingRev = revision
|
||||
k.mu.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return fail(err)
|
||||
}
|
||||
@@ -762,13 +788,40 @@ func (t TrunkStates) view() (modules, nodes Store, at int64, err error) {
|
||||
return t.Kept.current(context.Background(), t.Objects)
|
||||
}
|
||||
|
||||
// current is the view held; before the start's read it reads the newest revision once.
|
||||
// Unread is the fault away (busretry.Away, design 47 H2 H-A-708 (2)) naming "the trunk's revision <n>" with "not read yet
|
||||
// since <time>" while the start's read of the trunk holds the view, nil when the view is held or no read runs (a call then
|
||||
// reads it once, as current does). A handler asks it before it reads, so a call made while the indexer starts is answered
|
||||
// at once.
|
||||
func (k *KeptTrunk) Unread() error {
|
||||
k.mu.Lock()
|
||||
defer k.mu.Unlock()
|
||||
if k.started || !k.reading {
|
||||
return nil
|
||||
}
|
||||
return k.away()
|
||||
}
|
||||
|
||||
// away is the fault of a read of the trunk that runs now; the caller holds mu.
|
||||
func (k *KeptTrunk) away() error {
|
||||
part := "the trunk's newest revision"
|
||||
if k.readingRev != 0 {
|
||||
part = fmt.Sprintf("the trunk's revision %d", k.readingRev)
|
||||
}
|
||||
return &busretry.Away{Part: part, Words: "not read yet since " + k.readingSince.UTC().Format("15:04:05")}
|
||||
}
|
||||
|
||||
// current is the view held; before the start's read it reads the newest revision once, and while a read runs it answers
|
||||
// the fault away (Unread) and never waits behind it.
|
||||
func (k *KeptTrunk) current(ctx context.Context, o Objects) (Store, Store, int64, error) {
|
||||
k.mu.Lock()
|
||||
started := k.started
|
||||
k.mu.Unlock()
|
||||
if !started {
|
||||
k.read.Lock()
|
||||
if !k.read.TryLock() {
|
||||
k.mu.Lock()
|
||||
defer k.mu.Unlock()
|
||||
return nil, nil, 0, k.away()
|
||||
}
|
||||
k.mu.Lock()
|
||||
started = k.started
|
||||
k.mu.Unlock()
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-sdk/go/busretry"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
@@ -315,3 +316,67 @@ func TestTheNewestRevisionReadersReadAgainWhenTheRevisionIsRemovedUnderThem(t *t
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// heldRead is a bucket whose read of an entry waits until release is closed: the start's read of the trunk held.
|
||||
type heldRead struct {
|
||||
*memObjects
|
||||
reading chan struct{}
|
||||
release chan struct{}
|
||||
once atomic.Bool
|
||||
}
|
||||
|
||||
func (h *heldRead) Get(ctx context.Context, name string) ([]byte, error) {
|
||||
if strings.HasPrefix(name, "entry.") && h.once.CompareAndSwap(false, true) {
|
||||
close(h.reading)
|
||||
<-h.release
|
||||
}
|
||||
return h.memObjects.Get(ctx, name)
|
||||
}
|
||||
|
||||
// Design 47 H2 H-A-708 (2) (AC-I15): while the start's read of the trunk is held, the view and the verb revision answer the fault
|
||||
// away naming the trunk's revision at once, never wait behind the read; once it ends they answer, and with no read running a
|
||||
// call reads the view once, as before.
|
||||
func TestAViewOfTheTrunkAnswersAwayWhileTheStartsReadIsHeld(t *testing.T) {
|
||||
mem := newMemObjects(0)
|
||||
data, _ := json.Marshal(meshcatalog.CatalogEntry{Module: "avahi", Repository: catalogueRepo, None: "not built"})
|
||||
rev := meshcatalog.CatalogRevision{Revision: 7, Kind: "trunk", Entries: []meshcatalog.EntryRef{{Module: "avahi", Digest: "d7"}}}
|
||||
if err := KeepRevision(context.Background(), mem, rev, map[string][]byte{"d7": data}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
objects := &heldRead{memObjects: mem, reading: make(chan struct{}), release: make(chan struct{})}
|
||||
kept := &KeptTrunk{}
|
||||
if err := kept.Unread(); err != nil {
|
||||
t.Fatalf("Unread before any read = %v, want none: a call reads once with no read running", err)
|
||||
}
|
||||
started := make(chan error, 1)
|
||||
go func() { started <- kept.Reread(context.Background(), objects) }()
|
||||
<-objects.reading
|
||||
answered := make(chan error, 3)
|
||||
go func() { _, _, _, err := kept.current(context.Background(), objects); answered <- err }()
|
||||
go func() {
|
||||
_, err := Revision(context.Background(), objects, kept, meshcatalog.RevisionInput{})
|
||||
answered <- err
|
||||
}()
|
||||
go func() { _, _, _, err := kept.Newest(context.Background(), objects); answered <- err }()
|
||||
for range 3 {
|
||||
select {
|
||||
case err := <-answered:
|
||||
var away *busretry.Away
|
||||
if !errors.As(err, &away) || away.Part != "the trunk's revision 7" || !strings.HasPrefix(away.Words, "not read yet since ") {
|
||||
t.Errorf("a call met by the start's read answered %v, want away naming the trunk's revision 7", err)
|
||||
}
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("a call waited behind the start's read of the trunk")
|
||||
}
|
||||
}
|
||||
close(objects.release)
|
||||
if err := <-started; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := kept.Unread(); err != nil {
|
||||
t.Errorf("Unread after the read = %v, want nothing", err)
|
||||
}
|
||||
if a, err := Revision(context.Background(), objects, kept, meshcatalog.RevisionInput{}); err != nil || a.Revision == nil || a.Revision.Revision != 7 {
|
||||
t.Errorf("revision after the read answered %+v (%v), want revision 7", a, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,12 @@ const RevisionInvoke = "seat:" + meshcatalog.Seat + "." + meshcatalog.VerbRevisi
|
||||
// from the bucket. A candidate, a branch and an older number read the bucket.
|
||||
func Revision(ctx context.Context, o Objects, kept *KeptTrunk, in meshcatalog.RevisionInput) (meshcatalog.RevisionAnswer, error) {
|
||||
var out meshcatalog.RevisionAnswer
|
||||
// While the start's read of the trunk holds the view the verb answers the fault away at once (design 47 H2 H-A-708 (2)).
|
||||
if kept != nil {
|
||||
if err := kept.Unread(); err != nil {
|
||||
return out, err
|
||||
}
|
||||
}
|
||||
var trunkEntries, branchEntries []meshcatalog.CatalogEntry
|
||||
newest, ok, err := newestOf(ctx, o, TrunkBranch)
|
||||
cached := false
|
||||
|
||||
Reference in New Issue
Block a user